Containerd: mudanças entre as edições

De Wiki Clusterlab.com.br
Ir para navegação Ir para pesquisar
Sem resumo de edição
Sem resumo de edição
 
(Uma revisão intermediária pelo mesmo usuário não está sendo mostrada)
Linha 1: Linha 1:
Import image into all Containerd nodes within a Kubernetes cluster
=Utils=
==Import image into all Containerd nodes within a Kubernetes cluster==
<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
for BIN in {base64,kubectl,ssh,pv,pigz,docker}; do if [ $(which $BIN | wc -l | awk '{print $1} ') -eq 0 ]; then echo $BIN not found ; return 1; else if [ $(file "$(which $BIN)" 1>&1 >/dev/null;echo $?) -ne 0 ]; then echo $BIN not found; return 1; fi;fi ;done
NODEENPOINT=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | head -n 1)
NODEENPOINT=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | head -n 1)
NODELIST=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | grep -vw ${NODEENPOINT} | tr '\n' ',' | sed -e 's/,$//g')
NODELIST=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | grep -vw ${NODEENPOINT} | tr '\n' ',' | sed -e 's/,$//g')

Edição atual tal como às 13h47min de 8 de setembro de 2025

Utils

Import image into all Containerd nodes within a Kubernetes cluster

for BIN in {base64,kubectl,ssh,pv,pigz,docker}; do if [ $(which $BIN | wc -l | awk '{print $1} ') -eq 0 ]; then echo $BIN not found ; return 1; else if [ $(file "$(which $BIN)" 1>&1 >/dev/null;echo $?) -ne 0 ]; then echo $BIN not found; return 1; fi;fi ;done
NODEENPOINT=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | head -n 1)
NODELIST=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | grep -vw ${NODEENPOINT} | tr '\n' ',' | sed -e 's/,$//g')
ALLNODES=$(kubectl get nodes -o wide --no-headers | awk '{print $6}' | tr '\n' ',' | sed -e 's/,$//g')
SSHUSERNAME=username
docker pull --platform linux/amd64 docker.io/projectname/imagename:1.2.3
docker save docker.io/projectname/imagename:1.2.3| pv| pigz -p 32 -9 > imagename.tgz
cat imagename.tgz | base64 -w 0 | ssh -i ssh.key -l ${SSHUSERNAME} ${NODEENPOINT} "cd /tmp ; base64 -d | gzip -d > imagename.tar; du -sh imagename.tar; md5sum imagename.tar"
ssh -i ssh.key -A  -l ${SSHUSERNAME} ${NODEENPOINT} "for i in {${NODELIST}}; do echo \$i;  scp -o 'StrictHostKeyChecking no' /tmp/imagename.tar ${SSHUSERNAME}@\$i:/tmp ; done"
for NODE in ${NODELIST}; do ssh -n -l ${SSHUSERNAME} $NODE "sudo ctr --namespace=k8s.io  image import --platform linux/amd64 /tmp/imagename.tar ; sudo ctr image ls" ; done

Links