Skip to content

Commit d79065b

Browse files
informalictajanikow
authored andcommitted
Drop capabilities for most of containers (#500)
1 parent 6829ad7 commit d79065b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

pkg/util/k8sutil/pods.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,10 @@ func arangodInitContainer(name, id, engine, alpineImage string, requireUUID bool
297297
"-c",
298298
command,
299299
},
300-
Name: name,
301-
Image: alpineImage,
302-
VolumeMounts: arangodVolumeMounts(),
300+
Name: name,
301+
Image: alpineImage,
302+
VolumeMounts: arangodVolumeMounts(),
303+
SecurityContext: SecurityContextWithoutCapabilities(),
303304
}
304305
return c
305306
}
@@ -412,6 +413,7 @@ func arangodbexporterContainer(image string, imagePullPolicy v1.PullPolicy, args
412413
Protocol: v1.ProtocolTCP,
413414
},
414415
},
416+
SecurityContext: SecurityContextWithoutCapabilities(),
415417
}
416418
for k, v := range env {
417419
c.Env = append(c.Env, v.CreateEnvVar(k))
@@ -494,6 +496,7 @@ func initLifecycleContainer(image string) (v1.Container, error) {
494496
Image: image,
495497
ImagePullPolicy: v1.PullIfNotPresent,
496498
VolumeMounts: lifecycleVolumeMounts(),
499+
SecurityContext: SecurityContextWithoutCapabilities(),
497500
}
498501
return c, nil
499502
}
@@ -574,7 +577,8 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
574577
}
575578

576579
// Add arangod container
577-
c := arangodContainer(image, imagePullPolicy, args, env, livenessProbe, readinessProbe, lifecycle, lifecycleEnvVars, resources, vct != nil)
580+
c :=
581+
arangodContainer(image, imagePullPolicy, args, env, livenessProbe, readinessProbe, lifecycle, lifecycleEnvVars, resources, vct != nil)
578582
if tlsKeyfileSecretName != "" {
579583
c.VolumeMounts = append(c.VolumeMounts, tlsKeyfileVolumeMounts()...)
580584
}
@@ -831,7 +835,7 @@ func createPod(kubecli kubernetes.Interface, pod *v1.Pod, ns string, owner metav
831835
func SecurityContextWithoutCapabilities() *v1.SecurityContext {
832836
return &v1.SecurityContext{
833837
Capabilities: &v1.Capabilities{
834-
Drop: []v1.Capability{"all"},
838+
Drop: []v1.Capability{"ALL"},
835839
},
836840
}
837841
}

reboot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ func runVolumeInspector(ctx context.Context, kube kubernetes.Interface, ns, name
173173
},
174174
},
175175
},
176+
SecurityContext: k8sutil.SecurityContextWithoutCapabilities(),
176177
},
177178
},
178179
Volumes: []corev1.Volume{

0 commit comments

Comments
 (0)