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

fix: nats-server runs as non-root #319

Merged
Merged
Show file tree
Hide file tree
Changes from 15 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
28 changes: 24 additions & 4 deletions .github/workflows/pull-e2e-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ env:

on:
pull_request:
branches: [ "main" ]
branches: ["main"]
paths-ignore:
- 'docs/**'
- '**.md'
- 'sec-scanners-config.yaml'
- "docs/**"
- "**.md"
- "sec-scanners-config.yaml"

jobs:
e2e-upgrade: # This job tests the upgrade of NATS module from latest image of the main branch to the current commit.
Expand Down Expand Up @@ -74,6 +74,26 @@ jobs:
run: |
make e2e-nats-server
- name: Show all StatefulSets in Namespace kyma-system
if: ${{ always() }}
run: |
kubectl get sts -n kyma-system -o yaml
- name: Show all Deployments in Namespace kyma-system
if: ${{ always() }}
run: |
kubectl get deploy -n kyma-system -o yaml
- name: Show all Pods in Namespace kyma-system
if: ${{ always() }}
run: |
kubectl get po -n kyma-system -o yaml
- name: Show all ConfigMaps in Namespace kyma-system
if: ${{ always() }}
run: |
kubectl get cm -n kyma-system -o yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? can we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted the changes.

- name: Cleanup NATS CR
run: |
make e2e-cleanup
9 changes: 9 additions & 0 deletions resources/nats/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ spec:
# reload to the server without restarting the pod.
shareProcessNamespace: true

initContainers:
- name: fix-jetstream-storage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix-jetstream-storage -> change-storage-permissions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

securityContext:
runAsUser: 0
image: alpine:latest
command: ["sh", "-c", "chown -R 1000:10001 {{ .Values.nats.jetstream.fileStorage.storageDirectory }} && chmod -R 755 {{ .Values.nats.jetstream.fileStorage.storageDirectory }} && echo 'Done!'"]
volumeMounts:
- name: {{ include "nats.fullname" . }}-js-pvc
mountPath: {{ .Values.nats.jetstream.fileStorage.storageDirectory }}
#################
# #
# NATS Server #
Expand Down
1 change: 1 addition & 0 deletions resources/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ global:
# #
####################################
podSecurityContext:
runAsUser: 1000
fsGroup: 10001
seccompProfile:
type: RuntimeDefault
Expand Down
Loading