Estudio de CKAD – Día 1

Voy a ir registrando cada uno de mis ejercicios para generar memoria muscular dia a dia.

Las preguntas que voy a resolver primero seran las siguientes

  1. Deploy a podnamed nginx-448839 using the nginx:alpine image
  2. Create a namespace named apx-z993845993845
  3. Create a new deployment named httpd-frontend with 3 replicas using image httpd:2.4-alpine
  4. Deploy a messaging pod using the redis:alpine image with the labels set to tier=msg
  5. A replicaset rs-d333393 is created. However th epods are not comming up. Identify and fix the issue. Once fixed ensure the replicaset has 4 Ready replicas. (Crear un replicaset con imagenes incorrectas)
  6. Create a service messaging-service to expose the redis deployment in the marketing namespace within the cluster on port 6379 (use imperative commands)
  7. Update the environment variable on the pod webapp-color to use a green background. Env: APP_COLOR=green, PodName webapp-color, label name= webapp-color
  8. Configure a new ConfigMap named cm-3392845. Use the spec given on the below. ConfigName Name: cm-3392845, Data: DB_NAME=SQL3322, Data DB_HOST=sql322.mycompany.com, DATA DB_PORT:3306
  9. Create a new Secret named db-secret-xxdf with the data given. Secret Name: db-secret-xxdf, DB_HOST=sql01, DB_User=root, DB_Password=password123.
  10. Update pod app-sec-kff3345 to run as Root user and with the SYS_TIME capability: Image Name: Ubuntu, SecurityContext: Capability SYS_TIME
  11. Export the logs of the e-com-1123 pod to th efile /opt/outputs/e-com.1123.logs it is in a different namespace. Identify he namespace firt.
  12. Create a persistent volume with the given specification Volume Name: PV-analytics, Storage 100Mi, Access Modes: Read WriteMany, Host-Path /pv/data-analytics
  13. Create a redis deployment using the image redis:alpine with 1 replica and label app=redis. Expose it via a clusterIP service called redis on port 6379. Create a new Ingress Type Networking Policy Called redis-access which allows only the pods with label access=redis to access the deployment.
    Image: redis:alpine
    Deployment created correctly?
    Service Created Correctly?
    Network Policy allows the correctpods?
    Network policy applied on the correct pods?
  14. Create a pod called sega with two containers:
    Container 1: name tails with image busybox and command: sleep 3600
    Container 2: Name sonic with image nginx and Environment variable NGINX_PORT with value 8080.

Cada pregunta es una tarea que debes resolver ejecutando comandos o escribiendo manifiestos Kubernetes.

  1. En el namespace exam-ns, crea un Pod llamado web usando la imagen nginx:latest, que se quede en estado “Running”.
  2. En el namespace exam-ns, crea un Deployment llamado frontend con 3 réplicas usando la imagen nginx:stable, y expónlo con un Service de tipo ClusterIP al puerto 80.
  3. Modifica el Deployment frontend para actualizar la imagen a nginx:1.21-alpine sin downtime (rolling update).
  4. Crea un ConfigMap llamado app-config con una clave LOG_LEVEL=debug, y monta ese ConfigMap como variable de entorno en el Deployment frontend.
  5. Crea un Secret genérico llamado db-secret con clave password=“s3cr3t”. Modifica el Deployment frontend para que consuma esa contraseña como variable de entorno (envFrom o env).
  6. Crea un Pod multi-contenedor en namespace exam-ns llamado multi, con dos contenedores:
    • contenedor app con imagen busybox que ejecuta sleep 3600
    • contenedor sidecar con imagen busybox que también ejecuta sleep 3600
      Ambos contenedores deben compartir un volumen emptyDir montado en /data.
  7. En el Deployment frontend, define probes de liveness y readiness que chequen HTTP en /healthz puerto 80 (suponiendo que la app responde).
  8. Crea un PVC (PersistentVolumeClaim) llamado data-claim con acceso ReadWriteOnce y tamaño 1Gi. Luego monta ese volumen en el Deployment frontend en la ruta /data.
  9. Crea un Job llamado db-seed que use la imagen alpine y ejecute el comando echo "seed" > /data/init.txt montando el PVC data-claim en /data.
  10. Escala el Deployment frontend a 5 réplicas.
  11. Evita que pods del Deployment frontend se programen en nodos con el label disallowed=true (usa nodeSelector / tolerations / taints/affinity).
  12. Crea una policy de red (NetworkPolicy) en exam-ns que solo permita que el Pod web reciba tráfico de Pods con label role=frontend.
  13. En el namespace exam-ns, crea un Service de tipo NodePort que exponga el Deployment frontend en el puerto 30080 externo apuntando al puerto 80 del Pod.
  14. Crea un Ingress que dirija host: app.example.com al Service frontend en exam-ns.
  15. Muestra los logs del Pod de frontend que está generando errores, y filtra por líneas que contengan “error”.
  16. En el Deployment frontend, pausa el rollout, cámbiale imagen, y luego reanuda el rollout (resume). Luego revisa el historial de rollout.
  17. Crea un CronJob llamado cleanup que cada día (“*/1 * * *”) ejecute busybox rm -rf /tmp/*.
  18. Borra forzosamente un Pod que está stuck en estado Terminating sin esperar el grace period.
  19. Lista los recursos (pods, deployments, services, etc.) en todos los namespaces, filtra los que están en estado no saludable (CrashLoopBackOff, ImagePullBackOff, etc.).
  20. Crea una ServiceAccount llamada app-sa en exam-ns, asignale un Role (o ClusterRole) que permita get, list, watch sobre Pods, y asóciala al Deployment frontend.