-
-
Save 7castle/b3e916f3143f5b6acd2109d621e680c3 to your computer and use it in GitHub Desktop.
DeamonSet for setting inotify config in each nodein k8s
This file contains hidden or 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
#!/bin/sh | |
# This script will be called in privileged mode on each node of the k8s cluster (with the help of a DeamonSet) | |
# This is where you should configure the node if you want to (for example change inotify values). | |
# Nothing guarantees that this script will not run multiple times, so please be sure to make the script idempotent. | |
# Gracefully handle the TERM signal sent when deleting the daemonset | |
trap 'exit' TERM | |
set -ex | |
# Configure inotify to be able to run a lot a containers on each node. | |
# By default each node can run a maximum of 128 files. | |
echo 524288 > /proc/sys/fs/inotify/max_user_instances | |
echo 524288 > /proc/sys/fs/inotify/max_user_watches | |
# Prevent the container from exiting and k8s restarting the daemonset pods | |
while true; do sleep 1; done |
This file contains hidden or 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
FROM alpine | |
COPY configure-node.sh configure-node.sh | |
CMD ["/bin/sh", "configure-node.sh"] |
This file contains hidden or 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
kind: DaemonSet | |
apiVersion: extensions/v1beta1 | |
metadata: | |
name: startup-script | |
labels: | |
app: startup-script | |
spec: | |
template: | |
metadata: | |
labels: | |
app: startup-script | |
spec: | |
hostPID: true | |
containers: | |
- name: startup-script | |
image: YOUR_DOCKER_IMAGE | |
securityContext: | |
privileged: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment