MCPcopy Create free account
hub / github.com/CrunchyData/postgres-operator / RestrictedSecurityContext

Function RestrictedSecurityContext

internal/initialize/security.go:23–48  ·  view source on GitHub ↗

RestrictedSecurityContext returns a v1.SecurityContext with safe defaults. See https://docs.k8s.io/concepts/security/pod-security-standards/

()

Source from the content-addressed store, hash-verified

21// RestrictedSecurityContext returns a v1.SecurityContext with safe defaults.
22// See https://docs.k8s.io/concepts/security/pod-security-standards/
23func RestrictedSecurityContext() *corev1.SecurityContext {
24 return &corev1.SecurityContext{
25 // Prevent any container processes from gaining privileges.
26 AllowPrivilegeEscalation: Bool(false),
27
28 // Drop any capabilities granted by the container runtime.
29 // This must be uppercase to pass Pod Security Admission.
30 // - https://releases.k8s.io/v1.24.0/staging/src/k8s.io/pod-security-admission/policy/check_capabilities_restricted.go
31 Capabilities: &corev1.Capabilities{
32 Drop: []corev1.Capability{"ALL"},
33 },
34
35 // Processes in privileged containers are essentially root on the host.
36 Privileged: Bool(false),
37
38 // Limit filesystem changes to volumes that are mounted read-write.
39 ReadOnlyRootFilesystem: Bool(true),
40
41 // Fail to start the container if its image runs as UID 0 (root).
42 RunAsNonRoot: Bool(true),
43
44 SeccompProfile: &corev1.SeccompProfile{
45 Type: corev1.SeccompProfileTypeRuntimeDefault,
46 },
47 }
48}

Callers 15

reconcileMoveWALDirMethod · 0.92
reconcileMoveRepoDirMethod · 0.92
addNSSWrapperFunction · 0.92
podFunction · 0.92
InstancePodFunction · 0.92
MakePGBackrestLogDirFunction · 0.92

Calls 1

BoolFunction · 0.70

Tested by 3

TestPodSecurityContextFunction · 0.74