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

Add securityContext to Knative Eventing core objects #5863

Merged
merged 3 commits into from
Nov 8, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ spec:
value: "8080"
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
Comment on lines +95 to +96
Copy link
Member

Choose a reason for hiding this comment

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

some of this was already done before and got reverted - see: https://github.com/knative/eventing/pull/5629/files

Copy link
Member

Choose a reason for hiding this comment

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

FWIW we reverted because we didn't have time - at the time - to figure out mem/cpu requests that were low enough to work reliably in GitHub actions, the securityContext stuff should IMO be good either way, and I think having resources present - even if low - is better than not having them at all (so being entirely at the mercy of the scheduler happening not to collocate too many jobs on a node).

tl;dr imo we should just make sure this reliably works in GitHub actions, and lower mem/cpu until it does :)

capabilities:
drop:
- all

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ spec:
value: "8080"
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

---

Expand Down
5 changes: 5 additions & 0 deletions config/brokers/mt-channel-broker/deployments/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ spec:

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

ports:
- name: metrics
Expand Down
5 changes: 5 additions & 0 deletions config/channels/in-memory-channel/deployments/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ spec:

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

ports:
- name: metrics
Expand Down
7 changes: 7 additions & 0 deletions config/channels/in-memory-channel/deployments/dispatcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,10 @@ spec:
protocol: TCP
- containerPort: 9090
name: metrics
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
5 changes: 5 additions & 0 deletions config/core/deployments/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ spec:

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

ports:
- name: metrics
Expand Down
8 changes: 8 additions & 0 deletions config/core/deployments/pingsource-mt-adapter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,12 @@ spec:
limits:
cpu: 1000m
memory: 2048Mi
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

serviceAccountName: pingsource-mt-adapter
5 changes: 5 additions & 0 deletions config/core/deployments/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ spec:

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

ports:
- name: https-webhook
Expand Down
8 changes: 8 additions & 0 deletions config/post-install/storage-version-migrator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ spec:
- "sinkbindings.sources.knative.dev"
- "subscriptions.messaging.knative.dev"
- "triggers.eventing.knative.dev"
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

5 changes: 5 additions & 0 deletions config/sugar/500-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:

securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

ports:
- name: metrics
Expand Down
8 changes: 8 additions & 0 deletions config/tools/appender/appender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ spec:
- name: MESSAGE
value: "...your message goes here..."
image: ko://knative.dev/eventing/cmd/appender
# This is needed to run under the "restricted" Pod Security Standard
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
8 changes: 8 additions & 0 deletions config/tools/event-display/event-display.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ spec:
spec:
containers:
- image: ko://knative.dev/eventing/cmd/event_display
# This is needed to run under the "restricted" Pod Security Standard
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
8 changes: 8 additions & 0 deletions config/tools/heartbeats/heartbeats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ spec:
value: "heartbeats"
- name: POD_NAMESPACE
value: "default"
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

sink:
ref:
apiVersion: serving.knative.dev/v1
Expand Down
8 changes: 8 additions & 0 deletions config/tools/recordevents/recordevents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ spec:
value: recorder,logger
- name: EVENT_GENERATORS
value: receiver
# This is needed to run under the "restricted" Pod Security Standard
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all
8 changes: 8 additions & 0 deletions config/tools/websocket-source/websocket-source.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ spec:
containers:
- image: ko://knative.dev/eventing/cmd/websocketsource
name: hue
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- all

sink:
ref:
apiVersion: serving.knative.dev/v1
Expand Down