Skip to content

Commit

Permalink
fix VDDK validation on k8s
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Mar 5, 2024
1 parent dd39e5c commit 1524f2b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ spec:
{% if k8s_cluster|bool %}
- name: API_TLS_CA
value: /var/run/secrets/{{ inventory_tls_secret_name }}/ca.crt
{% endif %}
- name: OpenShift
{% if k8s_cluster|bool %}
value: false
{% else %}
value: true
{% endif %}
{% if controller_log_level is defined and controller_log_level is number %}
- name: LOG_LEVEL
Expand Down
19 changes: 12 additions & 7 deletions pkg/controller/plan/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,15 @@ func createVddkCheckJob(plan *api.Plan, labels map[string]string, el9 bool, vddk
},
},
}
psc := &core.PodSecurityContext{
SeccompProfile: &core.SeccompProfile{
Type: core.SeccompProfileTypeRuntimeDefault,
},
}
if !Settings.OpenShift {
psc.RunAsNonRoot = ptr.To(true)
psc.RunAsUser = ptr.To(qemuUser)
}
return &batchv1.Job{
ObjectMeta: meta.ObjectMeta{
GenerateName: fmt.Sprintf("vddk-validator-%s", plan.Name),
Expand All @@ -900,13 +909,9 @@ func createVddkCheckJob(plan *api.Plan, labels map[string]string, el9 bool, vddk
Completions: ptr.To[int32](1),
Template: core.PodTemplateSpec{
Spec: core.PodSpec{
SecurityContext: &core.PodSecurityContext{
SeccompProfile: &core.SeccompProfile{
Type: core.SeccompProfileTypeRuntimeDefault,
},
},
RestartPolicy: core.RestartPolicyOnFailure,
InitContainers: initContainers,
SecurityContext: psc,
RestartPolicy: core.RestartPolicyOnFailure,
InitContainers: initContainers,
Containers: []core.Container{
{
Name: "validator",
Expand Down
4 changes: 4 additions & 0 deletions pkg/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
// Global
var Settings = ControllerSettings{}

const OpenShift = "OpenShift"

// Settings
type ControllerSettings struct {
// Roles.
Expand All @@ -29,6 +31,7 @@ type ControllerSettings struct {
Profiler
// Feature gates.
Features
OpenShift bool
}

// Load settings.
Expand Down Expand Up @@ -65,6 +68,7 @@ func (r *ControllerSettings) Load() error {
if err != nil {
return err
}
r.OpenShift = getEnvBool(OpenShift, false)

return nil
}
Expand Down

0 comments on commit 1524f2b

Please sign in to comment.