-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfn.go
92 lines (76 loc) · 2.42 KB
/
cfn.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package heat
import (
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/util/intstr"
openstackv1beta1 "github.com/ianunruh/openstack-operator/api/v1beta1"
"github.com/ianunruh/openstack-operator/pkg/template"
)
const (
CFNComponentLabel = "cfn"
)
func CFNDeployment(instance *openstackv1beta1.Heat, env []corev1.EnvVar, volumes []corev1.Volume) *appsv1.Deployment {
labels := template.Labels(instance.Name, AppLabel, CFNComponentLabel)
spec := instance.Spec.CFN
probe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(8000),
},
},
InitialDelaySeconds: 5,
PeriodSeconds: 10,
TimeoutSeconds: 5,
}
volumeMounts := []corev1.VolumeMount{
template.SubPathVolumeMount("etc-heat", "/etc/heat/heat.conf", "heat.conf"),
template.SubPathVolumeMount("etc-heat", "/var/lib/kolla/config_files/config.json", "kolla-heat-api-cfn.json"),
}
deploy := template.GenericDeployment(template.Component{
Namespace: instance.Namespace,
Labels: labels,
Replicas: spec.Replicas,
NodeSelector: spec.NodeSelector,
Affinity: &corev1.Affinity{
PodAntiAffinity: template.NodePodAntiAffinity(labels),
},
Containers: []corev1.Container{
{
Name: "cfn",
Image: spec.Image,
Command: []string{"/usr/local/bin/kolla_start"},
Env: env,
Ports: []corev1.ContainerPort{
{Name: "http", ContainerPort: 8000},
},
LivenessProbe: probe,
StartupProbe: probe,
Resources: spec.Resources,
VolumeMounts: volumeMounts,
},
},
SecurityContext: &corev1.PodSecurityContext{
RunAsUser: &appUID,
FSGroup: &appUID,
},
Volumes: volumes,
})
deploy.Name = template.Combine(instance.Name, "cfn")
return deploy
}
func CFNService(instance *openstackv1beta1.Heat) *corev1.Service {
labels := template.Labels(instance.Name, AppLabel, CFNComponentLabel)
name := template.Combine(instance.Name, "cfn")
svc := template.GenericService(name, instance.Namespace, labels)
svc.Spec.Ports = []corev1.ServicePort{
{Name: "http", Port: 8000},
}
return svc
}
func CFNIngress(instance *openstackv1beta1.Heat) *netv1.Ingress {
labels := template.Labels(instance.Name, AppLabel, CFNComponentLabel)
name := template.Combine(instance.Name, "cfn")
return template.GenericIngress(name, instance.Namespace, instance.Spec.CFN.Ingress, labels)
}