Skip to content

Commit 4fddca2

Browse files
authored
fix(#130): add SecurityContext to createInitContainerPatch (#131)
* feat: add SecurityContext to createInitContainerPatch * Update NOTICE.txt
1 parent 2022ca6 commit 4fddca2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2024 Elasticsearch BV
1+
Copyright 2025 Elasticsearch BV
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

patch.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,20 @@ func createVolumePatch(createArray bool) patchOperation {
187187
func createInitContainerPatch(config agentConfig, createArray bool) (patchOperation, error) {
188188
bp := filepath.Base(config.Image)
189189
name := strings.Split(bp, ":")
190+
allowPrivilegeEscalation := false
190191
agentInitContainer := corev1.Container{
191192
Name: name[0],
192193
Image: config.Image,
193194
VolumeMounts: []corev1.VolumeMount{volumeMounts},
194195
// TODO: should this be a default, and then users can modify it
195196
// *if needed*?
196197
Command: []string{"cp", "-v", "-r", config.ArtifactPath, mountPath},
198+
SecurityContext: &corev1.SecurityContext{
199+
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
200+
Capabilities: &corev1.Capabilities{
201+
Drop: []corev1.Capability{"ALL"},
202+
},
203+
},
197204
}
198205

199206
if errs := validation.IsDNS1123Label(agentInitContainer.Name); len(errs) != 0 {

0 commit comments

Comments
 (0)