Skip to content

Commit ff464a8

Browse files
authored
Merge pull request #264589 from jknightly/main
[operator-nexus] ds to customize worker nodes (v2)
2 parents 9b8a7f9 + 02937e2 commit ff464a8

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

articles/operator-nexus/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@
118118
href: howto-kubernetes-cluster-action-restart.md
119119
- name: Customize cluster DNS
120120
href: how-to-customize-kubernetes-cluster-dns.md
121+
- name: Customize Worker Nodes
122+
href: howto-kubernetes-cluster-customize-workers.md
121123
- name: Nexus Virtual Machine
122124
expanded: false
123125
items:
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: "Azure Operator Nexus: Customize Kubernetes worker nodes with a DaemonSet"
3+
description: How-to guide for customizing Kubernetes Worker Nodes with a DaemonSet.
4+
author: joknight
5+
ms.author: joknight
6+
ms.service: azure-operator-nexus
7+
ms.topic: how-to
8+
ms.date: 01/29/2024
9+
ms.custom: template-how-to
10+
---
11+
12+
# Customize worker nodes with a DaemonSet
13+
14+
To meet application requirements, you may need to modify operating system settings, enable a Linux kernel module or install a host-level application package. Use a `DaemonSet` with host privileges to customize worker nodes.
15+
16+
The example `DaemonSet` sets `registry.contoso.com` to bypass the Cloud Services Network proxy for image pulls, installs the SCTP kernel module and sets `fs.inotify.max_user_instances` to `4096`. Finally, the script applies a label to the Kubernetes Node to ensure the DaemonSet only runs once.
17+
18+
19+
```yaml
20+
apiVersion: apps/v1
21+
kind: DaemonSet
22+
metadata:
23+
name: customized
24+
namespace: kube-system
25+
spec:
26+
selector:
27+
matchLabels:
28+
name: customized
29+
template:
30+
metadata:
31+
labels:
32+
name: customized
33+
spec:
34+
affinity:
35+
nodeAffinity:
36+
requiredDuringSchedulingIgnoredDuringExecution:
37+
nodeSelectorTerms:
38+
- matchExpressions:
39+
- key: customized
40+
operator: NotIn
41+
values:
42+
- "1"
43+
tolerations:
44+
- operator: Exists
45+
effect: NoSchedule
46+
containers:
47+
- name: customized
48+
image: mcr.microsoft.com/cbl-mariner/base/core:1.0
49+
command:
50+
- nsenter
51+
- --target
52+
- "1"
53+
- --mount
54+
- --uts
55+
- --ipc
56+
- --net
57+
- --pid
58+
- --
59+
- bash
60+
- -exc
61+
- |
62+
sed -i '/registrycontoso.com/!s/NO_PROXY=/&registry.contoso.com,/' /etc/systemd/system/containerd.service.d/http-proxy.conf
63+
systemctl daemon-reload
64+
systemctl restart containerd
65+
modprobe sctp
66+
sed -i 's/^fs.inotify.max_user_instances.*/fs.inotify.max_user_instances = 4096/' /etc/sysctl.d/90-system-max-limits.conf
67+
kubectl --kubeconfig=/etc/kubernetes/kubelet.conf label node ${HOSTNAME,,} customized=1
68+
sleep infinity
69+
resources:
70+
limits:
71+
memory: 200Mi
72+
requests:
73+
cpu: 100m
74+
memory: 16Mi
75+
securityContext:
76+
privileged: true
77+
hostNetwork: true
78+
hostPID: true
79+
hostIPC: true
80+
terminationGracePeriodSeconds: 0
81+
```
82+
83+
And apply the `Daemonset`:
84+
85+
```bash
86+
kubectl apply -f /path/to/daemonset.yaml
87+
```

0 commit comments

Comments
 (0)