-
Notifications
You must be signed in to change notification settings - Fork 0
/
novncproxy.go
73 lines (59 loc) · 2.11 KB
/
novncproxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package nova
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
openstackv1beta1 "github.com/ianunruh/openstack-operator/api/v1beta1"
"github.com/ianunruh/openstack-operator/pkg/template"
)
const (
NoVNCProxyComponentLabel = "novncproxy"
)
func NoVNCProxyDeployment(instance *openstackv1beta1.NovaCell, env []corev1.EnvVar, volumes []corev1.Volume) *appsv1.Deployment {
labels := template.Labels(instance.Name, AppLabel, NoVNCProxyComponentLabel)
spec := instance.Spec.NoVNCProxy
volumeMounts := []corev1.VolumeMount{
template.SubPathVolumeMount("etc-nova", "/etc/nova/nova.conf", "nova.conf"),
template.SubPathVolumeMount("etc-nova", "/var/lib/kolla/config_files/config.json", "kolla-nova-novncproxy.json"),
}
deploy := template.GenericDeployment(template.Component{
Namespace: instance.Namespace,
Labels: labels,
Replicas: spec.Replicas,
NodeSelector: spec.NodeSelector,
Containers: []corev1.Container{
{
Name: "novncproxy",
Image: spec.Image,
Command: []string{"/usr/local/bin/kolla_start"},
Env: env,
Ports: []corev1.ContainerPort{
{Name: "http", ContainerPort: 6080},
},
Resources: spec.Resources,
VolumeMounts: volumeMounts,
},
},
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: &appUID,
FSGroup: &appUID,
},
Volumes: volumes,
})
deploy.Name = template.Combine(instance.Name, "novncproxy")
return deploy
}
func NoVNCProxyService(instance *openstackv1beta1.NovaCell) *corev1.Service {
labels := template.Labels(instance.Name, AppLabel, NoVNCProxyComponentLabel)
name := template.Combine(instance.Name, "novncproxy")
svc := template.GenericService(name, instance.Namespace, labels)
svc.Spec.Ports = []corev1.ServicePort{
{Name: "http", Port: 6080},
}
return svc
}
func NoVNCProxyIngress(instance *openstackv1beta1.NovaCell) *netv1.Ingress {
labels := template.Labels(instance.Name, AppLabel, APIComponentLabel)
name := template.Combine(instance.Name, "novncproxy")
return template.GenericIngress(name, instance.Namespace, instance.Spec.NoVNCProxy.Ingress, labels)
}