Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,11 @@ func (w *MeshWebhook) consulDataplaneSidecar(namespace corev1.Namespace, pod cor
}
}
container.SecurityContext = &corev1.SecurityContext{
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
ReadOnlyRootFilesystem: pointer.Bool(true),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,20 +798,22 @@ func TestHandlerConsulDataplaneSidecar_withSecurityContext(t *testing.T) {
tproxyEnabled: false,
openShiftEnabled: false,
expSecurityContext: &corev1.SecurityContext{
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
},
},
"tproxy enabled; openshift disabled": {
tproxyEnabled: true,
openShiftEnabled: false,
expSecurityContext: &corev1.SecurityContext{
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
},
},
"tproxy disabled; openshift enabled": {
Expand All @@ -823,10 +825,11 @@ func TestHandlerConsulDataplaneSidecar_withSecurityContext(t *testing.T) {
tproxyEnabled: true,
openShiftEnabled: true,
expSecurityContext: &corev1.SecurityContext{
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
RunAsUser: pointer.Int64(sidecarUserAndGroupID),
RunAsGroup: pointer.Int64(sidecarUserAndGroupID),
RunAsNonRoot: pointer.Bool(true),
ReadOnlyRootFilesystem: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
},
},
}
Expand Down
2 changes: 2 additions & 0 deletions control-plane/connect-inject/webhook/container_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ func (w *MeshWebhook) containerInit(namespace corev1.Namespace, pod corev1.Pod,
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
ReadOnlyRootFilesystem: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions control-plane/connect-inject/webhook/container_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ func TestHandlerContainerInit_transparentProxy(t *testing.T) {
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
ReadOnlyRootFilesystem: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(false),
}
} else if c.expTproxyEnabled {
expectedSecurityContext = &corev1.SecurityContext{
Expand Down