Pregunta 2 - Programación de Pod en Control Plane
Question 2 | Schedule Pod on Controlplane Nodes
Use context: kubectl config use-context k8s-c1-H
Create a single Pod of image httpd:2.4.41-alpine in Namespace default. The Pod should be named pod1 and the container should be named pod1-container. This Pod should only be scheduled on controlplane nodes. Do not add new labels to any nodes.
Vamos a verificar los taints
k get node # encuentra el nodo controlplane
k describe node cluster1-controlplane1 | grep Taint -A1 # obtiene los taints del nodo controlplane
k get node cluster1-controlplane1 --show-labels # obtiene las etiquetas del nodo controlplane
# Creando una plantilla para el pod para aplicarla después
k run pod1 --image=httpd:2.4.41-alpine --dry-run=client -o yaml > 2.yaml
vim 2.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: pod1
name: pod1
spec:
containers:
- image: httpd:2.4.41-alpine
name: pod1-container # cambiar
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
tolerations: # agregar
- effect: NoSchedule # agregar
key: node-role.kubernetes.io/control-plane # agregar
nodeSelector: # agregar
node-role.kubernetes.io/control-plane: "" # agregar
status: {}
La toleration es necesaria, de lo contrario, incluso si seleccionamos el nodo control plane, no se ejecutará.
k -f 2.yaml create
k get pod pod1 -o wide
NAME READY STATUS RESTARTS ... NODE NOMINATED NODE
pod1 1/1 Running 0 ... cluster1-controlplane1 <none>