1
+ # yaml-language-server: $schema=https://github.com/yannh/kubernetes-json-schema/raw/master/v1.27.9/daemonset.json
1
2
apiVersion : apps/v1
2
3
kind : DaemonSet
3
4
metadata :
4
- name : containerd-registry-http
5
+ name : containerd-config
5
6
spec :
6
7
selector :
7
8
matchLabels :
8
- app : containerd-registry-http
9
+ app : containerd-config
9
10
template :
10
11
metadata :
11
12
labels :
12
- app : containerd-registry-http
13
+ app : containerd-config
13
14
annotations :
14
15
" cluster-autoscaler.kubernetes.io/safe-to-evict " : " true"
15
16
spec :
@@ -18,63 +19,64 @@ spec:
18
19
operator : Exists
19
20
hostPID : true
20
21
hostNetwork : true
22
+ containers :
23
+ - name : init-container-did-the-work
24
+ image : registry.k8s.io/pause:3.9@sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
21
25
initContainers :
22
- - name : update
23
- image : ubuntu:22.04@sha256:27cb6e6ccef575a4698b66f5de06c7ecd61589132d5a91d098f7f3f9285415a9
24
- volumeMounts :
25
- - name : etc-containerd
26
- mountPath : /etc/containerd
27
- readOnly : false
28
- - name : results
29
- mountPath : /results
30
- env :
31
- - name : CONFIG_PATH
32
- value : /etc/containerd/config.toml
33
- securityContext :
34
- privileged : true
26
+ - name : config
27
+ image : ghcr.io/yolean/busybox:1.36.1-glibc@sha256:25e9fcbd3799fce9c0ec978303d35dbb18a6ffb1fc76fc9b181dd4e657e2cd13
35
28
command :
36
- - bash
29
+ - sh
37
30
# to troubleshoot use: - -cex
38
31
- -ce
39
32
- |
40
- CONTAINERD_VERSION=$(nsenter --mount=/proc/1/ns/mnt -- containerd -v)
41
- case "$CONTAINERD_VERSION" in
42
- *"containerd 1.4."*) CRI_PLUGIN='plugins.cri' ;;
43
- *) CRI_PLUGIN='plugins."io.containerd.grpc.v1.cri"' ;;
44
- esac
45
- echo "CONTAINERD_VERSION=$CONTAINERD_VERSION CRI_PLUGIN=$CRI_PLUGIN"
33
+ echo "" | tee -a /host-etc/hosts
34
+ grep builds-registry.ystack.svc.cluster.local /host-etc/hosts || \
35
+ echo "$BUILDS_REGISTRY_PORT_80_TCP_ADDR builds-registry.ystack.svc.cluster.local" | tee -a /host-etc/hosts
36
+ grep prod-registry.ystack.svc.cluster.local /host-etc/hosts || \
37
+ echo "$PROD_REGISTRY_PORT_80_TCP_ADDR prod-registry.ystack.svc.cluster.local" | tee -a /host-etc/hosts
38
+
39
+ CONFIG_PATH=/etc/containerd/config.toml
40
+ CRI_PLUGIN='plugins."io.containerd.grpc.v1.cri"'
46
41
if ! grep builds-registry.ystack.svc.cluster.local $CONFIG_PATH; then
47
- echo "[$CRI_PLUGIN.registry.mirrors.\"builds-registry.ystack.svc.cluster.local\"]" >> $CONFIG_PATH
48
- echo ' endpoint = ["http://builds-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
49
- echo "[$CRI_PLUGIN.registry.mirrors.\"builds-registry.ystack.svc.cluster.local:80\"]" >> $CONFIG_PATH
50
- echo ' endpoint = ["http://builds-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
42
+ echo "[$CRI_PLUGIN.registry.mirrors.\"builds-registry.ystack.svc.cluster.local\"]" >> $CONFIG_PATH
43
+ echo ' endpoint = ["http://builds-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
51
44
touch /results/config-updated
52
45
fi
53
46
if ! grep prod-registry.ystack.svc.cluster.local $CONFIG_PATH; then
54
- echo "[$CRI_PLUGIN.registry.mirrors.\"prod-registry.ystack.svc.cluster.local\"]" >> $CONFIG_PATH
55
- echo ' endpoint = ["http://prod-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
56
- echo "[$CRI_PLUGIN.registry.mirrors.\"prod-registry.ystack.svc.cluster.local:80\"]" >> $CONFIG_PATH
57
- echo ' endpoint = ["http://prod-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
47
+ echo "[$CRI_PLUGIN.registry.mirrors.\"prod-registry.ystack.svc.cluster.local\"]" >> $CONFIG_PATH
48
+ echo ' endpoint = ["http://prod-registry.ystack.svc.cluster.local"]' >> $CONFIG_PATH
58
49
touch /results/config-updated
59
50
fi
60
- echo "-------------------- file --------------------"
61
- cat $CONFIG_PATH
62
- echo "-------------------- dump --------------------"
63
- nsenter --mount=/proc/1/ns/mnt -- containerd config dump
64
- echo "-------------------- --- --------------------"
65
51
if [ -f /results/config-updated ]; then
66
52
echo "Configuration has been updated; restarting containerd (not expecting any output) ..."
67
53
nsenter --mount=/proc/1/ns/mnt -- systemctl restart containerd
68
54
echo "Restart triggered"
69
- else
55
+ else
70
56
echo "No configration change"
71
- fi
72
- echo "Done"
73
- containers :
74
- - name : init-container-did-the-work
75
- image : k8s.gcr.io/pause:3.6@sha256:3d380ca8864549e74af4b29c10f9cb0956236dfb01c40ca076fb6c37253234db
57
+ fi
58
+ echo "----------------------- /etc/hosts ------------------------"
59
+ cat /host-etc/hosts
60
+ echo "-------------------- containerd config --------------------"
61
+ nsenter --mount=/proc/1/ns/mnt -- containerd config dump
62
+ echo "-------------------------- done ---------------------------"
63
+ securityContext :
64
+ runAsUser : 0
65
+ privileged : true
66
+ volumeMounts :
67
+ - name : etc-hosts
68
+ mountPath : /host-etc/hosts
69
+ readOnly : false
70
+ - name : etc-containerd
71
+ mountPath : /etc/containerd
72
+ readOnly : false
73
+ - name : results
74
+ mountPath : /results
76
75
terminationGracePeriodSeconds : 30
77
76
volumes :
77
+ - name : etc-hosts
78
+ hostPath :
79
+ path : /etc/hosts
78
80
- name : etc-containerd
79
81
hostPath :
80
82
path : /etc/containerd
0 commit comments