Skip to content

Commit 5327ee9

Browse files
author
John Knightly
authored
howto customize workers with a daemonset
1 parent 33a4507 commit 5327ee9

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Customize Worker Nodes with a DaemonSet
2+
3+
In order to configure worker nodes to meet specific application needs, it may be required to set certain sysctls, enable a linux module, etc. This is done with a DaemonSet which executes on each worker then applies a label to the worker as to not re-run on that node. This example sets registry.contoso.com to bypass the Cloud Services Network proxy for imagepulls, installs the SCTP kernel module and sets fs.inotify.max_user_instances to 4096, but it can be customized for any commands one might run in Linux.
4+
5+
\```yaml
6+
apiVersion: apps/v1
7+
kind: DaemonSet
8+
metadata:
9+
name: customized
10+
namespace: kube-system
11+
spec:
12+
selector:
13+
matchLabels:
14+
name: customized
15+
template:
16+
metadata:
17+
labels:
18+
name: customized
19+
spec:
20+
affinity:
21+
nodeAffinity:
22+
requiredDuringSchedulingIgnoredDuringExecution:
23+
nodeSelectorTerms:
24+
- matchExpressions:
25+
- key: customized
26+
operator: NotIn
27+
values:
28+
- "1"
29+
tolerations:
30+
- operator: Exists
31+
effect: NoSchedule
32+
containers:
33+
- name: customized
34+
image: mcr.microsoft.com/cbl-mariner/base/core:1.0
35+
command:
36+
- nsenter
37+
- --target
38+
- "1"
39+
- --mount
40+
- --uts
41+
- --ipc
42+
- --net
43+
- --pid
44+
- --
45+
- bash
46+
- -exc
47+
- |
48+
sed -i '/registrycontoso.com/!s/NO_PROXY=/&registry.contoso.com,/' /etc/systemd/system/containerd.service.d/http-proxy.conf
49+
systemctl daemon-reload
50+
systemctl restart containerd
51+
modprobe sctp
52+
sed -i 's/^fs.inotify.max_user_instances.*/fs.inotify.max_user_instances = 4096/' /etc/sysctl.d/90-system-max-limits.conf
53+
kubectl --kubeconfig=/etc/kubernetes/kubelet.conf label node ${HOSTNAME,,} customized=1
54+
sleep infinity
55+
resources:
56+
limits:
57+
memory: 200Mi
58+
requests:
59+
cpu: 100m
60+
memory: 16Mi
61+
securityContext:
62+
privileged: true
63+
hostNetwork: true
64+
hostPID: true
65+
hostIPC: true
66+
terminationGracePeriodSeconds: 0
67+
\```

0 commit comments

Comments
 (0)