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

ansible/helm: add ssc to not allow root previleges #4655

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions changelog/fragments/ansible-helm-ssc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
ansible/v1, helm/v1) Added `securityContext`'s to the manager's Deployment to disallow running as root user.

# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "addition"

# Is this a breaking change?
breaking: false

# NOTE: ONLY USE `pull_request_override` WHEN ADDING THIS
# FILE FOR A PREVIOUSLY MERGED PULL_REQUEST!
#
# The generator auto-detects the PR number from the commit
# message in which this file was originally added.
#
# What is the pull request number (without the "#")?
# pull_request_override: 0


# Migration can be defined to automatically add a section to
# the migration guide. This is required for breaking changes.
migration:
header: (ansible/v1, helm/v1) Add `securityContext`'s to your manager's Deployment.
body: >
In `config/manager/manager.yaml`, add the following security contexts:
```yaml
spec:
Copy link
Member

Choose a reason for hiding this comment

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

Can you indent these from the root field, ex

spec:
  ...
  template:
    ...
    spec:
      securityContext:
        runAsNonRoot: true
      containers:
      - name: manager
        securityContext:
          allowPrivilegeEscalation: false

...
template:
...
spec:
securityContext:
runAsNonRoot: true
containers:
- name: manager
securityContext:
allowPrivilegeEscalation: false
```
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsNonRoot: true
containers:
- name: manager
args:
Expand All @@ -78,6 +80,8 @@ spec:
- name: ANSIBLE_GATHERING
value: explicit
image: {{ .Image }}
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsNonRoot: true
containers:
- image: {{ .Image }}
args:
- "--enable-leader-election"
- "--leader-election-id={{ .ProjectName }}"
name: manager
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
resources: {}
securityContext:
allowPrivilegeEscalation: false
securityContext:
runAsNonRoot: true
terminationGracePeriodSeconds: 10
permissions:
- rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsNonRoot: true
containers:
- name: manager
args:
Expand All @@ -31,6 +33,8 @@ spec:
- name: ANSIBLE_GATHERING
value: explicit
image: controller:latest
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ spec:
requests:
cpu: 100m
memory: 60Mi
securityContext:
allowPrivilegeEscalation: false
securityContext:
runAsNonRoot: true
terminationGracePeriodSeconds: 10
permissions:
- rules:
Expand Down
4 changes: 4 additions & 0 deletions testdata/helm/memcached-operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ spec:
labels:
control-plane: controller-manager
spec:
securityContext:
runAsNonRoot: true
containers:
- image: controller:latest
args:
- "--enable-leader-election"
- "--leader-election-id=memcached-operator"
name: manager
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
Expand Down