Kubernetes: poner Pods en cuarentena
Hoy os voy a explicar cómo poner Pods en cuarentena en Kubernetes y para qué os podría ser interesante.
Imaginaros que tenéis un conjunto de contenedores desplegados con un ReplicaSet, y queréis investigar uno de ellos, pero sin que esto afecte al servicio que el resto de contenedores estén dando en Producción.
Para que ReplicaSet no tenga el poder sobre el contenedor que os interesa, lo colocaremos en cuarentena.
Así que os pongo un ejemplo para que lo veáis más claro, os dejo un ejemplo de ReplicaSet:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
raulunzue@KBMASTER:~$ nano nginx-deployment-elblogdenegu.yml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment-elblogdenegu labels: app: nginx spec: replicas: 6 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 8080 |
Ejecutamos el fichero para crear los contenedores:
1 2 |
raulunzue@kbmaster:~/k8s$ kubectl apply -f nginx-deployment-elblogdenegu.yml deployment.apps/nginx-deployment-elblogdenegu created |
Revisamos que se generan los contenedores:
1 2 3 4 5 6 7 8 |
raulunzue@kbmaster:~/k8s$ kubectl get pods --show-labels NAME READY STATUS RESTARTS AGE LABELS nginx-deployment-elblogdenegu-74b8cb59b8-5x99f 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-l8fhj 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-mm48k 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-nt8mz 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-trbbv 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-wrdf7 1/1 Running 0 54s app=nginx,pod-template-hash=74b8cb59b8 |
Lo que haremos es separar uno de los contenedores, poniéndolo en cuarentena, cambiando la etiqueta de la siguiente forma:
- Colocamos un app=debug
- Y adicionalmente un “overwrite” ya que existe ya la etiqueta
1 2 |
raulunzue@kbmaster:~/k8s$ kubectl label pod nginx-deployment-elblogdenegu-74b8cb59b8-5x99f app=debug --overwrite pod/nginx-deployment-elblogdenegu-74b8cb59b8-5x99f labeled |
1 2 3 4 5 6 7 8 |
raulunzue@kbmaster:~/k8s$ kubectl get pods --show-labels NAME READY STATUS RESTARTS AGE LABELS nginx-deployment-elblogdenegu-74b8cb59b8-5x99f 1/1 Running 0 59s app=debug,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-l8fhj 1/1 Running 0 59s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-mm48k 1/1 Running 0 59s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-nt8mz 1/1 Running 0 59s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-trbbv 1/1 Running 0 59s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-wrdf7 1/1 Running 0 59s app=nginx,pod-template-hash=74b8cb59b8 |
1 2 3 4 5 6 7 8 9 |
raulunzue@kbmaster:~/k8s$ kubectl get pods --show-labels NAME READY STATUS RESTARTS AGE LABELS nginx-deployment-elblogdenegu-74b8cb59b8-5x99f 1/1 Running 0 2m app=debug,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-l8fhj 1/1 Running 0 2m app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-mm48k 1/1 Running 0 2m app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-ms7gn 1/1 Running 0 34s app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-nt8mz 1/1 Running 0 2m app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-trbbv 1/1 Running 0 2m app=nginx,pod-template-hash=74b8cb59b8 nginx-deployment-elblogdenegu-74b8cb59b8-wrdf7 1/1 Running 0 2m app=nginx,pod-template-hash=74b8cb59b8 |
Te ha gustado la entrada SGUENOS EN TWITTER O INVITANOS A UN CAFE?