-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Run Containers as Non-Root, and without Privilege Escalation by default. #400
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,8 +300,11 @@ st2: | |
## Default SecurityContext for pods and containers. | ||
## Overrides available for st2web, st2actionrunner, st2sensorcontainer, st2client pods, and custom packs images. | ||
## | ||
podSecurityContext: {} | ||
securityContext: {} | ||
podSecurityContext: | ||
runAsNonRoot: true | ||
securityContext: | ||
runAsUser: 1000 | ||
allowPrivilegeEscalation: false | ||
Comment on lines
+303
to
+307
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my cluster, I use drop capabilities, re-adding them only for the deployments that need it. So I have: #podSecurityContext:
securityContext:
capabilities:
drop: ["ALL"]
st2actionrunner:
#podSecurityContext:
securityContext:
capabilities:
drop: ["ALL"]
add:
- chown
- fowner # chmod
- fsetid
- setfcap
- setgid
- setuid
- dac_override # allows root to bypass "discretionary access control" (file rwx permission checks)
- kill
- net_raw # ping
- audit_write # sudo
- setpcap
st2web:
#podSecurityContext:
securityContext:
capabilities:
drop: ["ALL"]
add:
- chown
- setgid
- setuid
- dac_override # allows root to bypass "discretionary access control" (file rwx permission checks)
- net_bind_service # bind privileged ports 80 or 443 So, that's a slightly different approach than just running as a non-root user. In particular, if st2web is not running as root, and is using unprivileged ports, then the config could be somewhat simpler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think for For |
||
|
||
## | ||
## StackStorm HA Ingress | ||
|
@@ -377,7 +380,10 @@ st2web: | |
attach: false | ||
# override the default .podSecurityContext or .securityContext here | ||
podSecurityContext: {} | ||
securityContext: {} # NB: nginx requires some capabilities, drop ALL will cause issues. | ||
securityContext: # NB: nginx requires some capabilities, drop ALL will cause issues. | ||
runAsUser: 999 # run as nginx user | ||
runAsGroup: 999 # run as nginx group | ||
allowPrivilegeEscalation: false | ||
# mount extra volumes on the st2web pod(s) (primarily useful for k8s-provisioned secrets) | ||
## Note that Helm templating is supported in 'mount' and 'volume' | ||
extra_volumes: [] | ||
|
@@ -1050,6 +1056,15 @@ mongodb: | |
arbiter: | ||
enabled: false | ||
resources: {} | ||
podSecurityContext: | ||
enabled: true | ||
fsGroup: 1001 | ||
sysctls: [] | ||
containerSecurityContext: | ||
enabled: true | ||
runAsUser: 1001 | ||
runAsNonRoot: true | ||
allowPrivilegeEscalation: false | ||
|
||
## | ||
## RabbitMQ configuration (3rd party chart dependency) | ||
|
@@ -1097,7 +1112,12 @@ rabbitmq: | |
# As RabbitMQ enabled prometheus operator monitoring by default, disable it for non-prometheus users | ||
metrics: | ||
enabled: false | ||
|
||
podSecurityContext: | ||
fsGroup: 1001 | ||
runAsUser: 1001 | ||
runAsNonRoot: true | ||
containerSecurityContext: | ||
allowPrivilegeEscalation: false | ||
## | ||
## Redis HA configuration (3rd party chart dependency) | ||
## | ||
|
@@ -1133,6 +1153,14 @@ redis: | |
usePassword: false | ||
metrics: | ||
enabled: false | ||
securityContext: | ||
enabled: true | ||
fsGroup: 1001 | ||
runAsNonRoot: true | ||
containerSecurityContext: | ||
enabled: true | ||
runAsUser: 1001 | ||
allowPrivilegeEscalation: false | ||
|
||
## | ||
## Settings to be applied to all stackstorm-ha pods | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-d
only preserves symlinks as-is.-a
also copied the mode, including execute bits.We need to make sure to preserve the execute bit on files. Would we have to add
--preserve=mode
to copy that?Also, how will this interact with #245 (Switch from
cp
torsync
with fallback tocp
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please check out #415? I'd like to come up with the minimal set of flags for
cp
andrsync
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Stealthii made these changes (which remains me I should credit him as an author in the commits..), I believe this was to fix issues with running as a non-privileged user. @Stealthii can you comment here / have a look at the above PRs :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cognifloyd I've commented on #415 with a proposed change that should preserve all relevant attributes besides ownership. #415 (comment)
Once verified and if it becomes part of that PR, we can drop the change here and have this PR focus solely on the enablement of non-root runtimes.