Tag Archivio per: Kubernetes



Una de las ventajas de utilizar un Despliegue es la posibilidad de realizar actualizaciones rodantes. Las rolling updates nos permiten desempolvar la configuración de los pods de forma paulatino.

La organización de modernización es la opción más importante para configurar las actualizaciones rodantes. En la definición del Despliegue, spec.strategy.type tiene dos títulos posibles:

  • RollingUpdate: Los nuevos pods se añaden gradualmente y los antiguos se eliminan gradualmente.
  • Divertir: Todos los pods antiguos se terminan de una vez antiguamente de añadir nuevos pods.

Hay 2 opciones más al desempolvar el despliegue utilizando RollingUpdate.

  • maxSurge: El número de pods que se pueden crear por encima del número deseado de pods durante una modernización.
  • maxUnavailable: El número de pods que pueden no estar disponibles durante el proceso de modernización.

Utilizando las actualizaciones rodantes del despliegue podemos desempolvar la imagen utilizada por un despliegue. El estado del despliegue se guardia, lo que nos permite retroceder a cualquier lectura precedente del despliegue.

Cuando una aplicación equivocación oportuno a una imagen incorrecta o el despliegue es inestable, podemos querer revertir el Despliegue. Por defecto, todo el historial de despliegue del Despliegue se guardia en el sistema y se puede utilizar después para revertirlo en caso de despliegue inestable. Podemos utilizar este historial para hacer un rollback en cualquier momento que queramos.

Para aprender más sobre Rolling update y Rollback, recepción la documentación oficial de Kubernetes aquí.

En este artículo, actualizaremos el despliegue con la organización de modernización por defecto y revertiremos el despliegue. Para revertir el despliegue, utilizaremos la imagen incorrecta en una de las actualizaciones del despliegue.

Requisitos previos

  1. Cluster Kubernetes con al menos 1 nodo trabajador.
    Si quieres cultivarse a crear un clúster de Kubernetes. Esta breviario te ayudará a crear un cluster de Kubernetes con 1 Experto y 2 Nodos en Instancias EC2 de AWS Ubuntu.

¿Qué vamos a hacer?

  1. Modernización y reversión

Modernización y retroceso

Crea un archivo de definición de despliegue para Nginx. En él, hemos especificado la lectura de Nginx como «nginx:1.14.2».

vim my-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rolling-update-demo
  labels:
    app: nginx
spec:
  replicas: 4
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

Definición de mi despliegue

Comprobemos los pods existentes y creemos un despliegue.

kubectl get pods
kubectl create -f my-deployment.yml

Obtén los detalles del despliegue que acabamos de crear. Este despliegue ha creado 4 pods y está controlado por el conjunto de réplicas.

kubectl get deployments
kubectl get pods
kubectl  get replicaset

crear un despliegue

En la captura de pantalla precedente, puedes ver que tenemos 1 despliegue bajo el cual tenemos 1 replicaset y 4 pods controlados por el replicaset.

Ahora vamos a cambiar la lectura de Nginx de «nginx:1.14.2» a «nginx:1.61.1».

vim my-deployment.yml

editar-imagen-en-el-despliegue

Aplica el cambio al despliegue y obtén los detalles de los pods, el conjunto de réplicas y el despliegue.

kubectl apply -f my-deployment.yml
kubectl get pods
kubectl get deployments
kubectl get replicaset

aplicar-cambio-en-el-despliegue

En la captura de pantalla precedente, se puede ver que se ha creado un nuevo conjunto de réplicas y tiene 4 pods bajo él. Pero seguimos viendo el antiguo replicaset con 0 pods.

Ahora, si volvemos a cambiar la lectura de Nginx pero esta vez damos una Interpretación de Nginx errónea, el despliegue fallará ya que la Imagen de Nginx no existe para la lectura errónea.

vim my-deployment.yml

cambiar-imagen-con-versión-incorrecta

Apliquemos el cambio al despliegue.

kubectl apply -f my-deployment.yml
kubectl get pods
kubectl get deployments

Ahora, intentemos obtener los detalles del conjunto de réplicas.

kubectl get replicaset

aplicar-cambio-erróneo-en-el-despliegue

En la captura de pantalla precedente, se puede ver que los nuevos Pods están fallando con el error «ErrImagePull». Los pods están fallando porque la imagen de Nginx no existe para la lectura «ngin:1.1.1».

Ahora, si queremos retornar a las imágenes anteriores que funcionaban, podemos hacer un rollback.

Para hacer un rollback, primero podemos obtener el historial de rollouts de las implantaciones utilizando el venidero comando.

kubectl rollout history deployments rolling-update-demo

Ahora, utilizando el venidero comando con «–revision=2» podemos comprobar los detalles del despliegue que tenemos en «–revision=2»

kubectl rollout history deployments rolling-update-demo --revision=2

volver a la versión de trabajo con la imagen correcta

En la captura de pantalla precedente, puedes ver que la revisión-2 tiene la lectura de la imagen de Nginx «nginx:1.16.1» que estaba funcionando antiguamente de que actualizáramos nuestro despliegue con la lectura de Nginx «ngin:1.1» que falló.

Ahora, vamos a revertir el despliegue a la última revisión que tenemos antiguamente del presente despliegue fallido.

kubectl get deployments
kubectl rollout undo deployment rolling-update-demo
kubectl get pods
kubectl get replicaset

check-rollback-status

En la captura de pantalla precedente, puedes ver que hemos revertido el final despliegue y ahora tenemos una revisión del despliegue que funcionaba antiguamente de la última modernización.

Para aprender más sobre el despliegue, se puede describir utilizando el venidero comando.

kubectl get deployments
kubectl describe deployment rolling-update-demo

describir-despliegue

Conclusión

En este artículo hemos pasado los pasos para crear un despliegue y actualizarlo. Hemos pasado cómo se puede revertir un despliegue si equivocación por alguna razón, aquí el error que vimos para el despliegue fallido fue «ErrImagePull». Vimos cómo el despliegue mantiene su revisión a la que se puede revertir en caso de que no queramos surtir las últimas actualizaciones en el despliegue.



This article originally appeared on the LF Training Blog. You can access all of the LF Training resources and courses, including Kubernetes certifications, at here

Faseela K. is a platform development engineer with a background in open source networking. As she saw the use of containers growing more than the VMs she was working with, she began studying Kubernetes and eventually decided to pursue a Certified Kubernetes Administrator (CKA). We spoke to her about her experience.

Linux Foundation: What was the experience like taking the CKA exam?

Faseela K: I was actually nervous, as this was the first online certification exam I was taking from home, so there was some uncertainty going in. Would the proctor turn up on time? Will the cloud platform where we are taking the exam get stuck? Will I be able to finish the exam on time? Those and several other such questions ran through my mind. But I turned down all my concerns, had a very smooth exam experience, and was able to finish it without any difficulties.

LF: How did you prepare for the exam?

FK: I am a person who uses Kubernetes in my day to day work, so the topics in the syllabus were íntimo to me. On top of that I did some practice tests and online courses. Preparing for the exam made so many of my day to day work related tasks much easier, and my level of expertise on K8s increased considerably.

LF: How did preparing for and taking CKA help you improve your skills?

FK: Though I work on K8s regularly, the range of concepts and capabilities I was using were minimal. Preparing for CKA helped me touch upon all areas of K8s, and the experience which I already had helped me get a complete end to end view of things. I can troubleshoot Kubernetes issues in a better way now, and go deep into each problem to find a solution.

LF: Tell us more about your current job role. What types of activities are you engaged in and how has the CKA helped with them?

FK: I currently work as a platform development engineer at Cisco, where we develop and maintain an enterprise Kubernetes platform. Troubleshooting, upgrading, networking, and system management of containerized platforms are part of our daily tasks, and CKA has helped me master all these areas with perfection. The training which I took to prepare for the CKA phenomenally transformed my perspective about Kubernetes administration, and this has helped me attain an end to end view of the product. Debugging any issues in the platform has become easier than ever, and the certification has given me even more confidence with fixing issues in a time sensitive manner.

LF: You mentioned to us previously you’d like to take the Certified Kubernetes Application Developer (CKAD) next; what appeals to you about that certification?

FK: I am planning to go deeper into containerized application development in my career, and hence CKAD was appealing to me. In fact, I already completed CKAD and became CKAD certified within less than a month of achieving my CKA certification. The confidence I gained after CKA helped me try the second one also faster.

LF: Tell us about your experience working on the OpenDaylight project. What prompted you to move from focusing on SDN to Kubernetes?

FK: I was previously a member of the Technical Steering Committee of the OpenDaylight project at The Linux Foundation, and made a lot of contributions to OpenDaylight. Working in open source has been the most amazing experience I have ever had in my life, and OpenDaylight gave me exposure to the various activities under LF Networking, while being a part of The Linux Foundation generally helped me engage with some of the top notch brains across organizations.

Coming together from across the globe during various conferences and DDFs, and working together across the company boundaries to solve common SDN problems has given me so much satisfaction. Over a period of time, containers were gaining traction over VMs, and I wanted to get more involved with containerization and platform development, where Kubernetes looked more promising.

LF: What are your future career goals?

FK: I intend to learn more about K8s internal implementation, and also to get involved with projects like istio, servicemesh and networkservicemesh in the future. My dream is to become a cloud native software developer, who promotes containerized application development in a cloud native way.

LF: What technology are you most interested in studying next?

FK: I am currently pursuing a course on the golang programming language. I also plan to take the Certified Kubernetes Security Specialist (CKS) exam if time permits.



Source link