Skip to content

Commit 0f4c3af

Browse files
authored
cks: Fix when deployed on a nw without internet access (#6418)
* cks: Fix when deployed on a nw without internet access * Revert "cks: Fix when deployed on a nw without internet access" This reverts commit 40e3338. * cks: Fix issue when creating cluster in nw without internet access
1 parent 82e0d5d commit 0f4c3af

File tree

4 files changed

+71
-71
lines changed

4 files changed

+71
-71
lines changed

Diff for: plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node-add.yml

+15-20
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ write_files:
120120
fi
121121
retval=0
122122
set +e
123-
ctr image import "${BINARIES_DIR}/docker/$line"
123+
ctr -n k8s.io image import "${BINARIES_DIR}/docker/$line"
124124
retval=$?
125125
set -e
126126
if [ $retval -eq 0 ]; then
@@ -139,6 +139,15 @@ write_files:
139139
mkdir -p /opt/provider
140140
cp "${BINARIES_DIR}/provider.yaml" /opt/provider/provider.yaml
141141
fi
142+
143+
PAUSE_IMAGE=`ctr -n k8s.io images ls -q | grep "pause" | sort | tail -n 1`
144+
echo $PAUSE_IMAGE
145+
if [ -n "$PAUSE_IMAGE" ]; then
146+
sed -i "s|sandbox_image = .*|sandbox_image = \"$PAUSE_IMAGE\"|g" /etc/containerd/config.toml
147+
fi
148+
systemctl daemon-reload
149+
systemctl restart containerd
150+
142151
umount "${ISO_MOUNT_DIR}" && rmdir "${ISO_MOUNT_DIR}"
143152
if [ "$EJECT_ISO_FROM_OS" = true ] && [ "$iso_drive_path" != "" ]; then
144153
eject "${iso_drive_path}"
@@ -230,28 +239,17 @@ write_files:
230239
sed -i '/\[plugins."io.containerd.grpc.v1.cri".registry.mirrors\]/a '"${registryConfig}"'' /etc/containerd/config.toml
231240
232241
echo "Restarting containerd service"
242+
systemctl daemon-reload
233243
systemctl restart containerd
234244
235-
- path: /etc/systemd/system/setup-kube-system.service
245+
- path: /etc/systemd/system/deploy-kube-system.service
236246
permissions: '0755'
237247
owner: root:root
238248
content: |
239249
[Unit]
240250
Requires=containerd.service
241251
After=containerd.service
242252
243-
[Service]
244-
Type=simple
245-
StartLimitInterval=0
246-
ExecStart=/opt/bin/setup-kube-system
247-
248-
- path: /etc/systemd/system/deploy-kube-system.service
249-
permissions: '0755'
250-
owner: root:root
251-
content: |
252-
[Unit]
253-
After=setup-kube-system.service
254-
255253
[Service]
256254
Type=simple
257255
StartLimitInterval=0
@@ -263,10 +261,7 @@ runcmd:
263261
- chown -R cloud:cloud /home/cloud/.ssh
264262
- containerd config default > /etc/containerd/config.toml
265263
- sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
266-
- systemctl daemon-reload
267-
- systemctl restart containerd
264+
- until [ -f /opt/bin/setup-kube-system ]; do sleep 5; done
265+
- /opt/bin/setup-kube-system
268266
- until [ -f /etc/systemd/system/deploy-kube-system.service ]; do sleep 5; done
269-
- until [ -f /etc/systemd/system/setup-kube-system.service ]; do sleep 5; done
270-
- [ systemctl, start, setup-kube-system ]
271-
- [ systemctl, start, deploy-kube-system ]
272-
267+
- systemctl start deploy-kube-system

Diff for: plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-control-node.yml

+31-31
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ write_files:
140140
fi
141141
retval=0
142142
set +e
143-
ctr image import "${BINARIES_DIR}/docker/$line"
143+
ctr -n k8s.io image import "${BINARIES_DIR}/docker/$line"
144144
retval=$?
145145
set -e
146146
if [ $retval -eq 0 ]; then
@@ -161,6 +161,15 @@ write_files:
161161
mkdir -p /opt/provider
162162
cp "${BINARIES_DIR}/provider.yaml" /opt/provider/provider.yaml
163163
fi
164+
165+
PAUSE_IMAGE=`ctr -n k8s.io images ls -q | grep "pause" | sort | tail -n 1`
166+
echo $PAUSE_IMAGE
167+
if [ -n "$PAUSE_IMAGE" ]; then
168+
sed -i "s|sandbox_image = .*|sandbox_image = \"$PAUSE_IMAGE\"|g" /etc/containerd/config.toml
169+
fi
170+
systemctl daemon-reload
171+
systemctl restart containerd
172+
164173
umount "${ISO_MOUNT_DIR}" && rmdir "${ISO_MOUNT_DIR}"
165174
if [ "$EJECT_ISO_FROM_OS" = true ] && [ "$iso_drive_path" != "" ]; then
166175
eject "${iso_drive_path}"
@@ -210,6 +219,22 @@ write_files:
210219
done
211220
fi
212221
222+
- path: /opt/bin/deploy-kube-system
223+
permissions: '0700'
224+
owner: root:root
225+
content: |
226+
#!/bin/bash -e
227+
228+
if [[ -f "/home/cloud/success" ]]; then
229+
echo "Already provisioned!"
230+
exit 0
231+
fi
232+
233+
if [[ "$PATH" != *:/opt/bin && "$PATH" != *:/opt/bin:* ]]; then
234+
export PATH=$PATH:/opt/bin
235+
fi
236+
237+
MAX_SETUP_CRUCIAL_CMD_ATTEMPTS=3
213238
crucial_cmd_attempts=1
214239
while true; do
215240
if (( "$crucial_cmd_attempts" > "$MAX_SETUP_CRUCIAL_CMD_ATTEMPTS" )); then
@@ -227,17 +252,6 @@ write_files:
227252
crucial_cmd_attempts=$[$crucial_cmd_attempts + 1]
228253
done
229254
230-
- path: /opt/bin/deploy-kube-system
231-
permissions: '0700'
232-
owner: root:root
233-
content: |
234-
#!/bin/bash -e
235-
236-
if [[ -f "/home/cloud/success" ]]; then
237-
echo "Already provisioned!"
238-
exit 0
239-
fi
240-
241255
K8S_CONFIG_SCRIPTS_COPY_DIR=/tmp/k8sconfigscripts/
242256
243257
if [[ $(systemctl is-active setup-kube-system) != "inactive" ]]; then
@@ -287,43 +301,29 @@ write_files:
287301
sed -i '/\[plugins."io.containerd.grpc.v1.cri".registry.mirrors\]/a '"${registryConfig}"'' /etc/containerd/config.toml
288302
289303
echo "Restarting containerd service"
304+
systemctl daemon-reload
290305
systemctl restart containerd
291306
292-
- path: /etc/systemd/system/setup-kube-system.service
307+
- path: /etc/systemd/system/deploy-kube-system.service
293308
permissions: '0755'
294309
owner: root:root
295310
content: |
296311
[Unit]
297312
Requires=containerd.service
298313
After=containerd.service
299314
300-
[Service]
301-
Type=simple
302-
StartLimitInterval=0
303-
ExecStart=/opt/bin/setup-kube-system
304-
305-
- path: /etc/systemd/system/deploy-kube-system.service
306-
permissions: '0755'
307-
owner: root:root
308-
content: |
309-
[Unit]
310-
After=setup-kube-system.service
311-
312315
[Service]
313316
Type=simple
314317
StartLimitInterval=0
315318
Restart=on-failure
316-
ExecStartPre=/usr/bin/curl -k https://127.0.0.1:6443/version
317319
ExecStart=/opt/bin/deploy-kube-system
318320
319321
runcmd:
320322
- chown -R cloud:cloud /home/cloud/.ssh
321323
- containerd config default > /etc/containerd/config.toml
322324
- sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
323-
- systemctl daemon-reload
324-
- systemctl restart containerd
325+
- until [ -f /opt/bin/setup-kube-system ]; do sleep 5; done
326+
- /opt/bin/setup-kube-system
325327
- until [ -f /etc/systemd/system/deploy-kube-system.service ]; do sleep 5; done
326-
- until [ -f /etc/systemd/system/setup-kube-system.service ]; do sleep 5; done
327-
- [ systemctl, start, setup-kube-system ]
328-
- [ systemctl, start, deploy-kube-system ]
328+
- systemctl start deploy-kube-system
329329

Diff for: plugins/integrations/kubernetes-service/src/main/resources/conf/k8s-node.yml

+15-19
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ write_files:
120120
fi
121121
retval=0
122122
set +e
123-
ctr image import "${BINARIES_DIR}/docker/$line"
123+
ctr -n k8s.io image import "${BINARIES_DIR}/docker/$line"
124124
retval=$?
125125
set -e
126126
if [ $retval -eq 0 ]; then
@@ -139,6 +139,15 @@ write_files:
139139
mkdir -p /opt/provider
140140
cp "${BINARIES_DIR}/provider.yaml" /opt/provider/provider.yaml
141141
fi
142+
143+
PAUSE_IMAGE=`ctr -n k8s.io images ls -q | grep "pause" | sort | tail -n 1`
144+
echo $PAUSE_IMAGE
145+
if [ -n "$PAUSE_IMAGE" ]; then
146+
sed -i "s|sandbox_image = .*|sandbox_image = \"$PAUSE_IMAGE\"|g" /etc/containerd/config.toml
147+
fi
148+
systemctl daemon-reload
149+
systemctl restart containerd
150+
142151
umount "${ISO_MOUNT_DIR}" && rmdir "${ISO_MOUNT_DIR}"
143152
if [ "$EJECT_ISO_FROM_OS" = true ] && [ "$iso_drive_path" != "" ]; then
144153
eject "${iso_drive_path}"
@@ -230,28 +239,17 @@ write_files:
230239
sed -i '/\[plugins."io.containerd.grpc.v1.cri".registry.mirrors\]/a '"${registryConfig}"'' /etc/containerd/config.toml
231240
232241
echo "Restarting containerd service"
242+
systemctl daemon-reload
233243
systemctl restart containerd
234244
235-
- path: /etc/systemd/system/setup-kube-system.service
245+
- path: /etc/systemd/system/deploy-kube-system.service
236246
permissions: '0755'
237247
owner: root:root
238248
content: |
239249
[Unit]
240250
Requires=containerd.service
241251
After=containerd.service
242252
243-
[Service]
244-
Type=simple
245-
StartLimitInterval=0
246-
ExecStart=/opt/bin/setup-kube-system
247-
248-
- path: /etc/systemd/system/deploy-kube-system.service
249-
permissions: '0755'
250-
owner: root:root
251-
content: |
252-
[Unit]
253-
After=setup-kube-system.service
254-
255253
[Service]
256254
Type=simple
257255
StartLimitInterval=0
@@ -263,9 +261,7 @@ runcmd:
263261
- chown -R cloud:cloud /home/cloud/.ssh
264262
- containerd config default > /etc/containerd/config.toml
265263
- sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml
266-
- systemctl daemon-reload
267-
- systemctl restart containerd
264+
- until [ -f /opt/bin/setup-kube-system ]; do sleep 5; done
265+
- /opt/bin/setup-kube-system
268266
- until [ -f /etc/systemd/system/deploy-kube-system.service ]; do sleep 5; done
269-
- until [ -f /etc/systemd/system/setup-kube-system.service ]; do sleep 5; done
270-
- [ systemctl, start, setup-kube-system ]
271-
- [ systemctl, start, deploy-kube-system ]
267+
- systemctl start deploy-kube-system

Diff for: plugins/integrations/kubernetes-service/src/main/resources/script/upgrade-kubernetes.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ if [ -d "$BINARIES_DIR" ]; then
9393
output=`ls ${BINARIES_DIR}/docker/`
9494
if [ "$output" != "" ]; then
9595
while read -r line; do
96-
ctr image import "${BINARIES_DIR}/docker/$line"
96+
ctr -n k8s.io image import "${BINARIES_DIR}/docker/$line"
9797
done <<< "$output"
9898
fi
9999
if [ -e "${BINARIES_DIR}/provider.yaml" ]; then
@@ -107,6 +107,12 @@ if [ -d "$BINARIES_DIR" ]; then
107107
cp "${BINARIES_DIR}/autoscaler.yaml" /opt/autoscaler/autoscaler_tmpl.yaml
108108
fi
109109

110+
PAUSE_IMAGE=`ctr -n k8s.io images ls -q | grep "pause" | sort | tail -n 1`
111+
echo $PAUSE_IMAGE
112+
if [ -n "$PAUSE_IMAGE" ]; then
113+
sed -i "s|sandbox_image = .*|sandbox_image = \"$PAUSE_IMAGE\"|g" /etc/containerd/config.toml
114+
fi
115+
110116
tar -f "${BINARIES_DIR}/cni/cni-plugins-"*64.tgz -C /opt/cni/bin -xz
111117
tar -f "${BINARIES_DIR}/cri-tools/crictl-linux-"*64.tar.gz -C /opt/bin -xz
112118

@@ -129,6 +135,9 @@ if [ -d "$BINARIES_DIR" ]; then
129135
systemctl stop kubelet
130136
cp -a ${BINARIES_DIR}/k8s/{kubelet,kubectl} /opt/bin
131137
chmod +x {kubelet,kubectl}
138+
139+
systemctl daemon-reload
140+
systemctl restart containerd
132141
systemctl restart kubelet
133142

134143
if [ "${IS_MAIN_CONTROL}" == 'true' ]; then

0 commit comments

Comments
 (0)