You are on page 1of 1

Static pods

# Create a static pod named static-busybox on the controlplane node that uses the busybox image and the command sleep 1000.

kubectl run --restart=Never \


--image=busybox static-busybox \
--dry-run=client -oyaml --command -- sleep 1000 \
> /etc/kubernetes/manifests/static-busybox.yaml

# Create a static pod on node01 called nginx-critical with image nginx and make sure that it is recreated/restarted
# automatically in case of a failure.
# Use /etc/kubernetes/manifests as the Static Pod path for example.

ssh node01

#-> Edit /var/lib/kubelet/config.yaml


ps -ef | grep kubelet #--> --config=/var/lib/kubelet/config.yaml

echo "staticPodPath: /etc/kubernetes/manifests" >> /var/lib/kubelet/config.yaml

#-> Create staic pod yaml file nginx-critical.yaml


kubectl run --restart=Always --image=nginx nginx-critical --dry-run=client -oyaml
> /etc/kubernetes/manifests/nginx-critical-node01.yaml

cat <<EOF >/etc/kubernetes/manifests/nginx-critical.yaml


apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx-critical
name: nginx-critical
spec:
containers:
- image: nginx
name: nginx-critical
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
EOF

#-> update image for pod kube-contro1ler-manager-controlplane STATIC POD

cd /etc/kubernetes/manifests

grep contro1ler kube-controller-manager.yaml | wc -l

sed -i 's/contro1ler/controller/g' kube-controller-manager.yaml

kubectl delete pod kube-controller-manager-controlplane -n kube-system

You might also like