@@ -35,7 +35,10 @@ import (
3535
3636const (
3737 // ServiceCommand -
38- ServiceCommand = "/usr/local/bin/kolla_set_configs && /usr/local/bin/kolla_start"
38+ ServiceCommand = "/usr/local/bin/kolla_start"
39+
40+ // InitContainerCommand -
41+ InitContainerCommand = "/usr/local/bin/container-scripts/init.sh"
3942)
4043
4144// Deployment func
@@ -45,8 +48,6 @@ func Deployment(
4548 labels map [string ]string ,
4649 annotations map [string ]string ,
4750) (* appsv1.Deployment , error ) {
48- runAsUser := int64 (0 )
49- initVolumeMounts := octavia .GetInitVolumeMounts ()
5051
5152 livenessProbe := & corev1.Probe {
5253 // TODO might need tuning
@@ -133,6 +134,11 @@ func Deployment(
133134
134135 serviceName := fmt .Sprintf ("%s-api" , octavia .ServiceName )
135136
137+ initArgs := []string {
138+ "-c" ,
139+ InitContainerCommand ,
140+ }
141+
136142 deployment := & appsv1.Deployment {
137143 ObjectMeta : metav1.ObjectMeta {
138144 Name : serviceName ,
@@ -149,32 +155,46 @@ func Deployment(
149155 Labels : labels ,
150156 },
151157 Spec : corev1.PodSpec {
158+ SecurityContext : & corev1.PodSecurityContext {
159+ FSGroup : ptr .To (octavia .OctaviaUID ),
160+ },
152161 ServiceAccountName : instance .Spec .ServiceAccount ,
153162 Containers : []corev1.Container {
154163 {
155164 Name : serviceName ,
156165 Command : []string {
157166 "/bin/bash" ,
158167 },
159- Args : args ,
160- Image : instance .Spec .ContainerImage ,
161- SecurityContext : & corev1.SecurityContext {
162- RunAsUser : & runAsUser ,
163- },
164- Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
165- VolumeMounts : volumeMounts ,
166- Resources : instance .Spec .Resources ,
167- ReadinessProbe : readinessProbe ,
168- LivenessProbe : livenessProbe ,
168+ Args : args ,
169+ Image : instance .Spec .ContainerImage ,
170+ SecurityContext : octavia .GetOctaviaSecurityContext (),
171+ Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
172+ VolumeMounts : volumeMounts ,
173+ Resources : instance .Spec .Resources ,
174+ ReadinessProbe : readinessProbe ,
175+ LivenessProbe : livenessProbe ,
169176 },
170177 {
171- Name : fmt .Sprintf ("%s-provider-agent" , serviceName ),
172- Image : instance .Spec .ContainerImage ,
173- Env : env .MergeEnvs ([]corev1.EnvVar {}, agentEnvVars ),
174- VolumeMounts : volumeMountsDriverAgent ,
175- Resources : instance .Spec .Resources ,
176- ReadinessProbe : readinessProbe ,
177- LivenessProbe : livenessProbe ,
178+ Name : fmt .Sprintf ("%s-provider-agent" , serviceName ),
179+ Image : instance .Spec .ContainerImage ,
180+ SecurityContext : octavia .GetOctaviaSecurityContext (),
181+ Env : env .MergeEnvs ([]corev1.EnvVar {}, agentEnvVars ),
182+ VolumeMounts : volumeMountsDriverAgent ,
183+ Resources : instance .Spec .Resources ,
184+ ReadinessProbe : readinessProbe ,
185+ LivenessProbe : livenessProbe ,
186+ },
187+ },
188+ InitContainers : []corev1.Container {
189+ {
190+ Name : "init" ,
191+ Image : instance .Spec .ContainerImage ,
192+ SecurityContext : octavia .GetOctaviaSecurityContext (),
193+ Command : []string {
194+ "/bin/bash" ,
195+ },
196+ Args : initArgs ,
197+ VolumeMounts : octavia .GetInitVolumeMounts (),
178198 },
179199 },
180200 Volumes : volumes ,
@@ -192,15 +212,9 @@ func Deployment(
192212 },
193213 corev1 .LabelHostname ,
194214 )
195- if instance . Spec . NodeSelector != nil && len (instance .Spec .NodeSelector ) > 0 {
215+ if len (instance .Spec .NodeSelector ) > 0 {
196216 deployment .Spec .Template .Spec .NodeSelector = instance .Spec .NodeSelector
197217 }
198218
199- initContainerDetails := octavia.APIDetails {
200- ContainerImage : instance .Spec .ContainerImage ,
201- VolumeMounts : initVolumeMounts ,
202- }
203- deployment .Spec .Template .Spec .InitContainers = octavia .InitContainer (initContainerDetails )
204-
205219 return deployment , nil
206220}
0 commit comments