-
Notifications
You must be signed in to change notification settings - Fork 207
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
Support unprivileged container #172
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kured | ||
namespace: kube-system | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: kured # Must match `--ds-name` | ||
namespace: kube-system # Must match `--ds-namespace` | ||
spec: | ||
selector: | ||
matchLabels: | ||
name: kured | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
name: kured | ||
spec: | ||
serviceAccountName: kured | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
effect: NoSchedule | ||
hostPID: true # Required to execute reboot syscall | ||
restartPolicy: Always | ||
volumes: | ||
- name: host-opt-kured | ||
hostPath: | ||
path: /opt/kured | ||
type: DirectoryOrCreate | ||
containers: | ||
- name: kured | ||
image: docker.io/weaveworks/kured | ||
# If you find yourself here wondering why there is no | ||
# :latest tag on Docker Hub,see the FAQ in the README | ||
imagePullPolicy: IfNotPresent | ||
volumeMounts: | ||
- name: host-opt-kured | ||
mountPath: /opt/kured | ||
readOnly: true | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
add: ["SYS_BOOT"] | ||
drop: ["ALL"] | ||
env: | ||
- name: UNPRIVILEGED | ||
value: "true" | ||
# Pass in the name of the node on which this pod is scheduled | ||
# for use with drain/uncordon operations and lock acquisition | ||
- name: KURED_NODE_ID | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
command: | ||
- /usr/bin/kured | ||
- --reboot-sentinel=/opt/kured/reboot-required | ||
# - --alert-filter-regexp=^RebootRequired$ | ||
# - --blocking-pod-selector=runtime=long,cost=expensive | ||
# - --blocking-pod-selector=name=temperamental | ||
# - --blocking-pod-selector=... | ||
# - --ds-name=kured | ||
# - --ds-namespace=kube-system | ||
# - --end-time=23:59:59 | ||
# - --lock-annotation=weave.works/kured-node-lock | ||
# - --period=1h | ||
# - --prometheus-url=http://prometheus.monitoring.svc.cluster.local | ||
# - --reboot-days=sun,mon,tue,wed,thu,fri,sat | ||
# - --slack-hook-url=https://hooks.slack.com/... | ||
# - --slack-username=prod | ||
# - --slack-channel=alerting | ||
# - --start-time=0:00 | ||
# - --time-zone=UTC | ||
--- | ||
# kured-sentinel-sync places the sentinel into /opt/kured | ||
# which is a safer place for kured to mount. This can be | ||
# safely replaced by a similar process happening at the host. | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: kured-sentinel-sync # Must match `--ds-name` | ||
namespace: kube-system # Must match `--ds-namespace` | ||
spec: | ||
selector: | ||
matchLabels: | ||
name: kured-sentinel-sync | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
labels: | ||
name: kured-sentinel-sync | ||
spec: | ||
automountServiceAccountToken: false | ||
tolerations: | ||
- key: node-role.kubernetes.io/master | ||
effect: NoSchedule | ||
restartPolicy: Always | ||
volumes: | ||
- name: host-opt-kured | ||
hostPath: | ||
path: /opt/kured | ||
type: DirectoryOrCreate | ||
- name: host-var-run | ||
hostPath: | ||
path: /var/run | ||
type: Directory | ||
containers: | ||
- name: sentinel-sync | ||
image: bash:5.0 | ||
command: [bash, -c] | ||
args: | ||
- |+ | ||
while true | ||
do | ||
if [ -f $REBOOT_SENTINEL ]; then | ||
/bin/touch /opt/kured/reboot-required | ||
else | ||
/bin/rm /opt/kured/reboot-required | ||
fi | ||
/bin/sleep 60 | ||
done | ||
env: | ||
- name: REBOOT_SENTINEL | ||
value: /var/run/reboot-required | ||
volumeMounts: | ||
- name: host-opt-kured | ||
mountPath: /opt/kured | ||
- name: host-var-run | ||
mountPath: /var/run | ||
readOnly: true | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
readOnlyRootFilesystem: true | ||
capabilities: | ||
drop: ["ALL"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there any drawback so that we do not make this deployment the new default?
(Would prefer having it the default)
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.
I don't see any major problem on pushing this to be the default.
The new approach won't break existing workloads and we could update the
yaml
and helm chart to be a seamless replacement.The only down side of the new approach is having two
daemonset
s, which in my opinion is a tiny downside when considering we will finally be able to run kured unprivileged and with a single Linux capability.Shall we get this merged and then a follow up PR to just make it the default so we can hear more feedback just around that possibility?
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.
Yeah sounds reasonable, I tend to make it the default. 👍