Skip to content

Commit 2c2cc10

Browse files
authored
Merge pull request #62 from Yolean/containerd-registry-config-single-daemonset
Combines two node setup daemonsets into one
2 parents 8a49456 + cef9795 commit 2c2cc10

File tree

5 files changed

+44
-105
lines changed

5 files changed

+44
-105
lines changed

registry/node-update-containerd/daemonset.yaml renamed to registry/containerd-config/daemonset.yaml

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1+
# yaml-language-server: $schema=https://github.com/yannh/kubernetes-json-schema/raw/master/v1.27.9/daemonset.json
12
apiVersion: apps/v1
23
kind: DaemonSet
34
metadata:
4-
name: containerd-registry-http
5+
name: containerd-config
56
spec:
67
selector:
78
matchLabels:
8-
app: containerd-registry-http
9+
app: containerd-config
910
template:
1011
metadata:
1112
labels:
12-
app: containerd-registry-http
13+
app: containerd-config
1314
annotations:
1415
"cluster-autoscaler.kubernetes.io/safe-to-evict": "true"
1516
spec:
@@ -18,63 +19,64 @@ spec:
1819
operator: Exists
1920
hostPID: true
2021
hostNetwork: true
22+
containers:
23+
- name: init-container-did-the-work
24+
image: registry.k8s.io/pause:3.9@sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
2125
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
3528
command:
36-
- bash
29+
- sh
3730
#to troubleshoot use: - -cex
3831
- -ce
3932
- |
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"'
4641
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
5144
touch /results/config-updated
5245
fi
5346
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
5849
touch /results/config-updated
5950
fi
60-
echo "-------------------- file --------------------"
61-
cat $CONFIG_PATH
62-
echo "-------------------- dump --------------------"
63-
nsenter --mount=/proc/1/ns/mnt -- containerd config dump
64-
echo "-------------------- --- --------------------"
6551
if [ -f /results/config-updated ]; then
6652
echo "Configuration has been updated; restarting containerd (not expecting any output) ..."
6753
nsenter --mount=/proc/1/ns/mnt -- systemctl restart containerd
6854
echo "Restart triggered"
69-
else
55+
else
7056
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
7675
terminationGracePeriodSeconds: 30
7776
volumes:
77+
- name: etc-hosts
78+
hostPath:
79+
path: /etc/hosts
7880
- name: etc-containerd
7981
hostPath:
8082
path: /etc/containerd

registry/node-update-hosts/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

registry/node-update-hosts/daemonset.yaml

Lines changed: 0 additions & 54 deletions
This file was deleted.

registry/node-update-hosts/kustomization.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)