Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update securityContext fields of testing pods for runAsNonRoot user check #95

Merged
merged 1 commit into from
Oct 25, 2024
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
2 changes: 1 addition & 1 deletion testpmd-container-app/cnfapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LABEL name="NFV Example CNF Application" \
COPY licenses /licenses

# Create custom user to avoid using root account
RUN useradd example-cnf
RUN useradd example-cnf -u 56560

# This is to be able to manage some files that belong to root account
RUN usermod -a -G root example-cnf
Expand Down
2 changes: 1 addition & 1 deletion testpmd-container-app/listener/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ USER root
RUN pip3 install kubernetes

# Create custom user to avoid using root account
RUN useradd example-cnf
RUN useradd example-cnf -u 56560

# This is to be able to manage some files that belong to root account
RUN usermod -a -G root example-cnf
Expand Down
2 changes: 1 addition & 1 deletion testpmd-container-app/testpmd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ LABEL name="NFV Example Testpmd LB Application" \
COPY licenses /licenses

# Create custom user to avoid using root account
RUN useradd example-cnf
RUN useradd example-cnf -u 56560

# This is to be able to manage some files that belong to root account
RUN usermod -a -G root example-cnf
Expand Down
10 changes: 10 additions & 0 deletions testpmd-lb-operator/roles/loadbalancer/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
- cnf-app
- pkt-gen
topologyKey: kubernetes.io/hostname
securityContext:
runAsNonRoot: true
runAsUser: 56560
serviceAccountName: loadbalancer-account
{% if runtime_class_name is defined and runtime_class_name|length %}
runtimeClassName: "{{ runtime_class_name }}"
Expand Down Expand Up @@ -78,6 +81,9 @@ spec:
image: "{{ image_testpmd }}"
imagePullPolicy: "{{ image_pull_policy }}"
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
{% if privileged %}
privileged: true
{% else %}
Expand Down Expand Up @@ -157,6 +163,10 @@ spec:
containerPort: 8096
image: "{{ image_listener }}"
imagePullPolicy: "{{ image_pull_policy }}"
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
resources:
limits:
memory: "512Mi"
Expand Down
6 changes: 6 additions & 0 deletions testpmd-operator/roles/testpmd/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ spec:
values:
- lb-app
topologyKey: kubernetes.io/hostname
securityContext:
runAsNonRoot: true
runAsUser: 56560
serviceAccountName: testpmd-account
{% if runtime_class_name is defined and runtime_class_name | length %}
runtimeClassName: "{{ runtime_class_name }}"
Expand All @@ -61,6 +64,9 @@ spec:
image: "{{ image_testpmd }}"
imagePullPolicy: "{{ image_pull_policy }}"
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
{% if privileged %}
privileged: true
{% else %}
Expand Down
2 changes: 1 addition & 1 deletion trex-container-app/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ENV TREX_DIR="/opt/trex/trex-core/scripts"
ENV TRAFFICGEN_DIR="/opt/trafficgen"

# Create custom user to avoid using root account
RUN useradd example-cnf
RUN useradd example-cnf -u 56560

# This is to be able to manage some files that belong to root account
RUN usermod -a -G root example-cnf
Expand Down
2 changes: 1 addition & 1 deletion trex-container-app/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ENV TREX_DIR="/opt/trex/trex-core/scripts"
ENV TRAFFICGEN_DIR="/opt/trafficgen"

# Create custom user to avoid using root account
RUN useradd example-cnf
RUN useradd example-cnf -u 56560

# This is to be able to manage some files that belong to root account
RUN usermod -a -G root example-cnf
Expand Down
7 changes: 7 additions & 0 deletions trex-operator/roles/app/templates/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
{% endif %}
spec:
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 56560
serviceAccountName: trex-app-account
{% if runtime_class_name is defined and runtime_class_name | length %}
runtimeClassName: "{{ runtime_class_name }}"
Expand All @@ -24,6 +27,10 @@ spec:
- name: trex-app
image: "{{ image_app }}"
imagePullPolicy: "{{ image_pull_policy }}"
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
volumeMounts:
- name: varlog
mountPath: /var/log
Expand Down
10 changes: 10 additions & 0 deletions trex-operator/roles/server/templates/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ spec:
- cnf-app
{% endif %}
topologyKey: kubernetes.io/hostname
securityContext:
runAsNonRoot: true
runAsUser: 56560
serviceAccountName: trex-server-account
{% if runtime_class_name is defined and runtime_class_name | length %}
runtimeClassName: "{{ runtime_class_name }}"
Expand All @@ -79,6 +82,9 @@ spec:
- name: "http-probe"
containerPort: 8096
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
{% if privileged %}
privileged: true
{% else %}
Expand Down Expand Up @@ -151,6 +157,10 @@ spec:
- name: trex-app
image: "{{ image_app }}"
imagePullPolicy: "{{ image_pull_policy }}"
securityContext:
runAsNonRoot: true
runAsUser: 56560
#readOnlyRootFilesystem: true
resources:
limits:
memory: "756Mi"
Expand Down