@@ -50,7 +50,6 @@ container registry reference installation to proxy and cache images from target
50
50
registries. This may reduce the load of overused public container registries and/or helps
51
51
to avoid rate limiting by individual public registries.
52
52
Currently, SCS container registry is set up to "proxy-cache" the following public container registries:
53
-
54
53
- docker.io
55
54
- ghcr.io
56
55
- quay.io
@@ -73,3 +72,117 @@ the [SCS container registry](https://registry.scs.community)
73
72
as a mirror for it, please open an issue in one of the following
74
73
repositories: [ scs/k8s-cluster-api-provider] ( https://github.com/SovereignCloudStack/k8s-cluster-api-provider ) ,
75
74
[ scs/k8s-harbor] ( https://github.com/SovereignCloudStack/k8s-harbor ) .
75
+
76
+ ## Tutorial: configure an existing cluster to use containerd registry configuration
77
+
78
+ This tutorial is experimental and out of the usual release cycle. We recommend to
79
+ upgrade existing environments (workload clusters) with stable releases which are properly
80
+ tested.
81
+
82
+ This tutorial instructs (advanced) users what needs to be done on the cluster management
83
+ instance without re-deploying it via Terraform. Patches described in this tutorial
84
+ modify existing environment with changes that have been developed within "containerd registry"-related PRs:
85
+ - PR #432
86
+ - PR #447
87
+ - PR #472
88
+
89
+ Warning: This tutorial causes a rolling update (rolling re-deployment) of the control plane and worker nodes.
90
+
91
+ 1 . Log in to the cluster management instance, pull remote changes, and then checkout to relevant commit that
92
+ includes all mentioned PRs.
93
+ ``` bash
94
+ cd k8s-cluster-api-provider/
95
+ git pull
96
+ git checkout b31a79db26c3956b473f026038e71e9aba7819b8
97
+ ```
98
+
99
+ 2 . Backup the config directory of an existing cluster.
100
+ ``` bash
101
+ cd ..
102
+ cp -R < CLUSTER_NAME> < CLUSTER_NAME> .bkp
103
+ ```
104
+
105
+ 3 . Ensure that the directory for containerd registry configs exists and create a default containerd registry
106
+ config file that instructs containerd to use registry.scs.community container registry
107
+ instance as a public mirror of DockerHub.
108
+ Optionally, create another containerd container registry host file in the ` containerd/hosts ` directory.
109
+ You can find working examples of those files [ here] ( https://github.com/SovereignCloudStack/k8s-cluster-api-provider/tree/main/terraform/files/containerd ) .
110
+ ``` bash
111
+ cd < CLUSTER_NAME>
112
+ mkdir -p containerd/hosts
113
+ cat > containerd/hosts/docker.io << EOF
114
+ server = "https://registry-1.docker.io"
115
+
116
+ [host."https://registry.scs.community/v2/docker.io"]
117
+ capabilities = ["pull"]
118
+ override_path = true
119
+ EOF
120
+ # Optionally, create another containerd container registry host file here.
121
+ ```
122
+
123
+ 4 . Injects containerd registry host file(s) (from point 3.) into ` cluster-template.yaml ` .
124
+ Script ` configure_containerd.sh ` does the injection.
125
+ ``` bash
126
+ configure_containerd.sh cluster-template.yaml < CLUSTER_NAME>
127
+ ```
128
+
129
+ 5 . Inject containerd configuration in ` cluster-template.yaml ` . This configuration allows
130
+ containerd to discover registry host file(s).
131
+
132
+ - Create ` containerd_conf_append ` temp file
133
+ ``` bash
134
+ cat > containerd_conf_append << EOF
135
+ cat <<EOT >> /etc/containerd/config.toml
136
+ [plugins."io.containerd.grpc.v1.cri".registry]
137
+ config_path = "/etc/containerd/certs.d"
138
+ EOT
139
+ EOF
140
+ ```
141
+
142
+ - Inject temp file and ` systemctl restart containerd.service ` line into the ` cluster-template.yaml ` (inplace)
143
+ ``` bash
144
+ yq ' select(.kind == "KubeadmControlPlane").spec.kubeadmConfigSpec.preKubeadmCommands |= (
145
+ (.[] | select(. == "apt-get install -y ca-certificates socat*") | key + 1) as $pos |
146
+ .[:$pos] +
147
+ [load_str("containerd_conf_append")] +
148
+ .[$pos:])' -i cluster-template.yaml
149
+
150
+ yq ' select(.kind == "KubeadmControlPlane").spec.kubeadmConfigSpec.preKubeadmCommands |= (
151
+ (.[] | select(. == "systemctl daemon-reload") | key + 1) as $pos |
152
+ .[:$pos] +
153
+ ["systemctl restart containerd.service"] +
154
+ .[$pos:])' -i cluster-template.yaml
155
+
156
+ yq ' select(.kind == "KubeadmConfigTemplate").spec.template.spec.preKubeadmCommands |= (
157
+ (.[] | select(. == "apt-get install -y ca-certificates socat*") | key + 1) as $pos |
158
+ .[:$pos] +
159
+ [load_str("containerd_conf_append")] +
160
+ .[$pos:])' -i cluster-template.yaml
161
+
162
+ yq ' select(.kind == "KubeadmConfigTemplate").spec.template.spec.preKubeadmCommands |= (
163
+ (.[] | select(. == "systemctl daemon-reload") | key + 1) as $pos |
164
+ .[:$pos] +
165
+ ["systemctl restart containerd.service"] +
166
+ .[$pos:])' -i cluster-template.yaml
167
+ ```
168
+
169
+ 6 . The above changes (when point 8. will be applied) of ` KubeadmControlPlane ` will cause a rolling update of control plane nodes.
170
+ As the ` KubeadmConfigTemplate ` has been adjusted we need to increase the generation
171
+ counter of worker machines to ensure that the worker nodes will be rolling updated as well.
172
+ ``` bash
173
+ sed -r ' s/(^WORKER_MACHINE_GEN: genw)([0-9][0-9])/printf "\1%02d" $((\2+1))/ge' -i clusterctl.yaml
174
+ ```
175
+
176
+
177
+ 7 . Workaround: If your environment contains nginx ingress deployed via k8s-cluster-api-provider
178
+ (variable DEPLOY_NGINX_INGRESS=true) disable its update. Nginx-ingress controller has
179
+ been updated to version 1.8.0 in PR #440 . This is a breaking change that includes updates
180
+ of immutable fields. If the above is the case skip this update as follows:
181
+ ``` bash
182
+ sed ' s/DEPLOY_NGINX_INGRESS: true/DEPLOY_NGINX_INGRESS: false/g' -i clusterctl.yaml
183
+ ```
184
+
185
+ 8 . Update the existing cluster.
186
+ ``` bash
187
+ create_cluster.sh test1
188
+ ```
0 commit comments