Skip to content

Commit

Permalink
Merge pull request #114 from dell/techops-cert-csi-failure
Browse files Browse the repository at this point in the history
Bugfix: Pod security violation changes
  • Loading branch information
gilltaran authored Dec 26, 2024
2 parents b7440b6 + 27839a3 commit 6360526
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions pkg/k8sclient/resources/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ func (c *Client) MakePod(config *Config) *v1.Pod {
}
volumes = append(volumes, volume)
}

allowPrivilegeEscalation := false
runAsNonRoot := true
seccompProfileType := v1.SeccompProfileTypeRuntimeDefault
container := v1.Container{
Name: config.ContainerName,
Image: config.ContainerImage,
Expand All @@ -160,7 +162,15 @@ func (c *Client) MakePod(config *Config) *v1.Pod {
Env: config.EnvVars,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &v1.SecurityContext{
Capabilities: &v1.Capabilities{Add: config.Capabilities},
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
Capabilities: &v1.Capabilities{
Drop: []v1.Capability{"ALL"},
Add: config.Capabilities,
},
RunAsNonRoot: &runAsNonRoot,
SeccompProfile: &v1.SeccompProfile{
Type: seccompProfileType,
},
},
}

Expand Down Expand Up @@ -204,6 +214,7 @@ func (c *Client) Create(ctx context.Context, pod *v1.Pod) *Pod {

if err != nil {
funcErr = err
fmt.Println(funcErr)
} else {
log.Debugf("Created Pod %s", newPod.GetName())
}
Expand Down Expand Up @@ -551,7 +562,9 @@ func (c *Client) MakeEphemeralPod(config *Config) *v1.Pod {
},
}
volumes = append(volumes, volume)

allowPrivilegeEscalation := false
runAsNonRoot := true
seccompProfileType := v1.SeccompProfileTypeRuntimeDefault
container := v1.Container{
Name: config.ContainerName,
Image: config.ContainerImage,
Expand All @@ -561,7 +574,15 @@ func (c *Client) MakeEphemeralPod(config *Config) *v1.Pod {
VolumeMounts: volumeMounts,
ImagePullPolicy: "IfNotPresent",
SecurityContext: &v1.SecurityContext{
Capabilities: &v1.Capabilities{Add: config.Capabilities},
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
Capabilities: &v1.Capabilities{
Drop: []v1.Capability{"ALL"},
Add: config.Capabilities,
},
RunAsNonRoot: &runAsNonRoot,
SeccompProfile: &v1.SeccompProfile{
Type: seccompProfileType,
},
},
}

Expand Down

0 comments on commit 6360526

Please sign in to comment.