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
- Deploy a podnamed nginx-448839 using the nginx:alpine image
- Create a namespace named apx-z993845993845
- Create a new deployment named httpd-frontend with 3 replicas using image httpd:2.4-alpine
- Deploy a messaging pod using the redis:alpine image with the labels set to tier=msg
- 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)
- Create a service messaging-service to expose the redis deployment in the marketing namespace within the cluster on port 6379 (use imperative commands)
- 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
- 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
- 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.
- Update pod app-sec-kff3345 to run as Root user and with the SYS_TIME capability: Image Name: Ubuntu, SecurityContext: Capability SYS_TIME
- 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.
- Create a persistent volume with the given specification Volume Name: PV-analytics, Storage 100Mi, Access Modes: Read WriteMany, Host-Path /pv/data-analytics
- 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? - 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.
- En el namespace
exam-ns, crea un Pod llamadowebusando la imagennginx:latest, que se quede en estado “Running”. - En el namespace
exam-ns, crea un Deployment llamadofrontendcon 3 réplicas usando la imagennginx:stable, y expónlo con un Service de tipoClusterIPal puerto 80. - Modifica el Deployment
frontendpara actualizar la imagen anginx:1.21-alpinesin downtime (rolling update). - Crea un ConfigMap llamado
app-configcon una claveLOG_LEVEL=debug, y monta ese ConfigMap como variable de entorno en el Deploymentfrontend. - Crea un Secret genérico llamado
db-secretcon clavepassword=“s3cr3t”. Modifica el Deploymentfrontendpara que consuma esa contraseña como variable de entorno (envFrom o env). - Crea un Pod multi-contenedor en namespace
exam-nsllamadomulti, con dos contenedores:- contenedor
appcon imagenbusyboxque ejecutasleep 3600 - contenedor
sidecarcon imagenbusyboxque también ejecutasleep 3600
Ambos contenedores deben compartir un volumenemptyDirmontado en/data.
- contenedor
- En el Deployment
frontend, define probes de liveness y readiness que chequen HTTP en/healthzpuerto 80 (suponiendo que la app responde). - Crea un PVC (PersistentVolumeClaim) llamado
data-claimcon accesoReadWriteOncey tamaño1Gi. Luego monta ese volumen en el Deploymentfrontenden la ruta/data. - Crea un Job llamado
db-seedque use la imagenalpiney ejecute el comandoecho "seed" > /data/init.txtmontando el PVCdata-claimen/data. - Escala el Deployment
frontenda 5 réplicas. - Evita que pods del Deployment
frontendse programen en nodos con el labeldisallowed=true(usa nodeSelector / tolerations / taints/affinity). - Crea una policy de red (NetworkPolicy) en
exam-nsque solo permita que el Podwebreciba tráfico de Pods con labelrole=frontend. - En el namespace
exam-ns, crea un Service de tipoNodePortque exponga el Deploymentfrontenden el puerto 30080 externo apuntando al puerto 80 del Pod. - Crea un Ingress que dirija
host: app.example.comal Servicefrontendenexam-ns. - Muestra los logs del Pod de
frontendque está generando errores, y filtra por líneas que contengan “error”. - En el Deployment
frontend, pausa el rollout, cámbiale imagen, y luego reanuda el rollout (resume). Luego revisa el historial de rollout. - Crea un CronJob llamado
cleanupque cada día (“*/1 * * *”) ejecutebusybox rm -rf /tmp/*. - Borra forzosamente un Pod que está stuck en estado
Terminatingsin esperar el grace period. - Lista los recursos (pods, deployments, services, etc.) en todos los namespaces, filtra los que están en estado no saludable (CrashLoopBackOff, ImagePullBackOff, etc.).
- Crea una ServiceAccount llamada
app-saenexam-ns, asignale un Role (o ClusterRole) que permitaget,list,watchsobre Pods, y asóciala al Deploymentfrontend.