Skip to content

Commit cad784f

Browse files
committed
Add httpdSecurityContext for keystone deployment
This patch updates the current deployment to pass an httpd securityContext through the common httpdSyncSecurityContext. Signed-off-by: Francesco Pantano <[email protected]>
1 parent 126834f commit cad784f

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

pkg/keystone/deployment.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func Deployment(
4343
annotations map[string]string,
4444
topology *topologyv1.Topology,
4545
) (*appsv1.Deployment, error) {
46-
runAsUser := int64(KeystoneUID)
4746

4847
livenessProbe := &corev1.Probe{
4948
// TODO might need tuning
@@ -134,16 +133,14 @@ func Deployment(
134133
Command: []string{
135134
"/bin/bash",
136135
},
137-
Args: args,
138-
Image: instance.Spec.ContainerImage,
139-
SecurityContext: &corev1.SecurityContext{
140-
RunAsUser: &runAsUser,
141-
},
142-
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
143-
VolumeMounts: volumeMounts,
144-
Resources: instance.Spec.Resources,
145-
ReadinessProbe: readinessProbe,
146-
LivenessProbe: livenessProbe,
136+
Args: args,
137+
Image: instance.Spec.ContainerImage,
138+
SecurityContext: httpdSecurityContext(),
139+
Env: env.MergeEnvs([]corev1.EnvVar{}, envVars),
140+
VolumeMounts: volumeMounts,
141+
Resources: instance.Spec.Resources,
142+
ReadinessProbe: readinessProbe,
143+
LivenessProbe: livenessProbe,
147144
},
148145
},
149146
},

pkg/keystone/funcs.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ func dbSyncSecurityContext() *corev1.SecurityContext {
3434
},
3535
}
3636
}
37+
38+
// httpdSecurityContext -
39+
func httpdSecurityContext() *corev1.SecurityContext {
40+
return &corev1.SecurityContext{
41+
Capabilities: &corev1.Capabilities{
42+
Drop: []corev1.Capability{
43+
"MKNOD",
44+
},
45+
},
46+
RunAsUser: ptr.To(KeystoneUID),
47+
RunAsGroup: ptr.To(KeystoneUID),
48+
}
49+
}

pkg/keystone/volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
func getVolumes(instance *keystonev1.KeystoneAPI) []corev1.Volume {
2626
name := instance.Name
2727
var scriptsVolumeDefaultMode int32 = 0755
28-
var config0640AccessMode int32 = 0640
28+
var config0640AccessMode int32 = 0644
2929

3030
fernetKeys := []corev1.KeyToPath{}
3131
numberKeys := int(*instance.Spec.FernetMaxActiveKeys)

tests/kuttl/tests/keystone_tls/01-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ spec:
7878
secretName: keystone-scripts
7979
- name: config-data
8080
secret:
81-
defaultMode: 416
81+
defaultMode: 420
8282
secretName: keystone-config-data
8383
- name: fernet-keys
8484
secret:

0 commit comments

Comments
 (0)