Skip to content

Instantly share code, notes, and snippets.

@7castle
Forked from brendan-rius/Dockerfile
Created May 20, 2019 08:46
Show Gist options
  • Save 7castle/b3e916f3143f5b6acd2109d621e680c3 to your computer and use it in GitHub Desktop.
Save 7castle/b3e916f3143f5b6acd2109d621e680c3 to your computer and use it in GitHub Desktop.
DeamonSet for setting inotify config in each nodein k8s
#!/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
FROM alpine
COPY configure-node.sh configure-node.sh
CMD ["/bin/sh", "configure-node.sh"]
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