Skip to content

Commit

Permalink
Merge pull request #12 from qpoint-io/marc-barry/init-as-root
Browse files Browse the repository at this point in the history
Allow the init container to run as root.
  • Loading branch information
marc-barry authored Nov 28, 2023
2 parents 0e47314 + 12ad8f7 commit 3d27d0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions api/v1/egress.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import (

const INIT_IMAGE = "us-docker.pkg.dev/qpoint-edge/public/kubernetes-qtap-init"

var (
RUN_AS_USER int64 = 0 // The root user
RUN_AS_GROUP int64 = 0 // The root group
RUN_AS_NON_ROOT = false // Allow running as root
)

func MutateEgress(pod *corev1.Pod, config *Config) error {
// fetch the init image tag
tag := config.Get("egress-init-tag")
Expand All @@ -21,6 +27,11 @@ func MutateEgress(pod *corev1.Pod, config *Config) error {
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"NET_ADMIN"},
},
// The init container needs to run as root as it modifies the network
// for the pod
RunAsUser: &RUN_AS_USER,
RunAsGroup: &RUN_AS_GROUP,
RunAsNonRoot: &RUN_AS_NON_ROOT,
},
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
sigs.k8s.io/controller-runtime v0.16.3
sigs.k8s.io/yaml v1.3.0
)

require (
Expand Down Expand Up @@ -64,5 +65,4 @@ require (
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

0 comments on commit 3d27d0d

Please sign in to comment.