Skip to content

Commit 632eb84

Browse files
committed
Add restrictive security context to registry pod and init containers
Fixes #7039 Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
1 parent f6829d4 commit 632eb84

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/olm/operator/registry/fbcindex/fbc_registry_pod.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,22 @@ func (f *FBCRegistryPod) Create(ctx context.Context, cfg *operator.Configuration
148148
},
149149
}
150150

151-
// Update the Registry Pod container security context to be restrictive
152-
f.pod.Spec.Containers[0].SecurityContext = &corev1.SecurityContext{
151+
restrictedSecurityContext := &corev1.SecurityContext{
153152
Privileged: pointer.To(false),
154153
ReadOnlyRootFilesystem: pointer.To(false),
155154
AllowPrivilegeEscalation: pointer.To(false),
156155
Capabilities: &corev1.Capabilities{
157156
Drop: []corev1.Capability{"ALL"},
158157
},
159158
}
159+
160+
// Update the Registry Pod container security context to be restrictive
161+
f.pod.Spec.Containers[0].SecurityContext = restrictedSecurityContext
162+
163+
// Update all init containers with the same restrictive security context
164+
for i := range f.pod.Spec.InitContainers {
165+
f.pod.Spec.InitContainers[i].SecurityContext = restrictedSecurityContext
166+
}
160167
}
161168

162169
if f.ImagePullPolicy == "" {

0 commit comments

Comments
 (0)