@@ -50,8 +50,7 @@ func StatefulSet(
5050 annotations map [string ]string ,
5151 privileged bool ,
5252) (* appsv1.StatefulSet , error ) {
53- runAsUser := int64 (0 )
54-
53+ userID := glance .GlanceUID
5554 startupProbe := & corev1.Probe {
5655 FailureThreshold : 6 ,
5756 PeriodSeconds : 10 ,
@@ -180,6 +179,9 @@ func StatefulSet(
180179 Labels : labels ,
181180 },
182181 Spec : corev1.PodSpec {
182+ SecurityContext : & corev1.PodSecurityContext {
183+ FSGroup : & userID ,
184+ },
183185 ServiceAccountName : instance .Spec .ServiceAccount ,
184186 // When using Cinder we run as privileged, but also some
185187 // commands need to be run on the host using nsenter (eg:
@@ -220,16 +222,14 @@ func StatefulSet(
220222 "-c" ,
221223 string (GlanceServiceCommand ),
222224 },
223- Image : instance .Spec .ContainerImage ,
224- SecurityContext : & corev1.SecurityContext {
225- RunAsUser : & runAsUser ,
226- },
227- Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
228- VolumeMounts : httpdVolumeMount ,
229- Resources : instance .Spec .Resources ,
230- StartupProbe : startupProbe ,
231- ReadinessProbe : readinessProbe ,
232- LivenessProbe : livenessProbe ,
225+ Image : instance .Spec .ContainerImage ,
226+ SecurityContext : glance .HttpdSecurityContext (),
227+ Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
228+ VolumeMounts : httpdVolumeMount ,
229+ Resources : instance .Spec .Resources ,
230+ StartupProbe : startupProbe ,
231+ ReadinessProbe : readinessProbe ,
232+ LivenessProbe : livenessProbe ,
233233 },
234234 {
235235 Name : glance .ServiceName + "-api" ,
@@ -243,12 +243,9 @@ func StatefulSet(
243243 "-c" ,
244244 string (GlanceServiceCommand ),
245245 },
246- Image : instance .Spec .ContainerImage ,
247- SecurityContext : & corev1.SecurityContext {
248- RunAsUser : & runAsUser ,
249- Privileged : & privileged ,
250- },
251- Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
246+ Image : instance .Spec .ContainerImage ,
247+ SecurityContext : glance .APISecurityContext (userID , privileged ),
248+ Env : env .MergeEnvs ([]corev1.EnvVar {}, envVars ),
252249 VolumeMounts : append (glance .GetVolumeMounts (
253250 instance .Spec .CustomServiceConfigSecrets ,
254251 privileged ,
0 commit comments