Fundamentos: De cero a la base

Guía de DevOps para llevar de cero a un clúster Kubernetes local con kind o minikube, desplegar una app con YAML y Helm, dominar kubectl y Helm, y practicar recuperación de fallos.

25 sept 2025 • 6 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Soy ingeniero DevOps y en este artículo te llevo de cero a un clúster local funcionando, desplegando una aplicación con YAML crudo y luego con Helm, además de los modelos mentales y comandos que usarás a diario.

Resumen ejecutivo: crea un clúster Kubernetes local con kind o minikube y verifica con kubectl. Consolida el modelo mental Pods ReplicaSets Deployments Services Controllers. Aplica YAML limpio para Deployment y Service, luego conviértelo a un chart minimal de Helm. Aprende los 12 comandos que uso diariamente con kubectl y Helm. Practica recuperación de fallos comunes como errores de imagen, pods en Pending, Services mal configurados y problemas de contexto.

Prerequisitos básicos: Docker corriendo (requerido por kind y a menudo por minikube), kubectl versión 1.28 o superior recomendado, y Helm.

Instalación resumida por plataformas: macOS usa Homebrew para instalar Docker, kubectl, kind, minikube y helm con brew install o brew install --cask docker. En Linux Debian/Ubuntu usa apt y los repos oficiales para Docker y kubectl, descarga kind y minikube desde sus binarios y usa el script oficial para Helm. En Windows instala Docker Desktop, kubectl, kind, minikube y helm vía choco o usa WSL2 para compatibilidad con herramientas como kind.

Verifica las instalaciones con los comandos kubectl version --client kind version minikube version helm version docker --version.

Modelo mental Kubernetes: Kubernetes reconcilia el estado deseado con el estado real mediante controladores. Pide N réplicas y Deployment gestiona ReplicaSet que gestiona Pods; Services enrutan a endpoints sanos. Buenas prácticas: trata a los Pods como efímeros, despliega con Deployments, no edites Pods a mano, expón tráfico con Services y mantén etiquetas y selectores consistentes. Piensa declarar en vez de scriptar.

Higiene de YAML: los recursos tienen apiVersion kind metadata spec. El 90 por ciento de los errores vienen de indentación, apiVersion errónea o campos fuera de lugar. Usa dos espacios, evita tabs, valida con kubectl explain y kubectl apply --dry-run=client -f. Pinea imágenes para evitar upgrades inesperados.

Fundamentos de kubectl: es la CLI que habla con el API server usando el contexto y namespace actuales. El contexto o namespace equivocado es la causa número uno de recursos 'no encontrados'. Establece un namespace por contexto, usa salida wide y labels, y revisa eventos para debug. Comandos útiles: kubectl config get-contexts kubectl config set-context --current --namespace=dev kubectl get pods -o wide kubectl describe pod nombre kubectl get events --sort-by=.lastTimestamp.

Clúster local: usa kind para clústeres rápidos basados en Docker y minikube si necesitas add-ons como ingress o almacenamiento. Ejemplos de comandos: kind create cluster --name demo kubectl cluster-info y para minikube minikube start minikube status. Nombra clústeres por proyecto y exporta kubeconfig solo para la shell actual si quieres evitar colisiones con entornos remotos.

Helm básico: Helm es el gestor de paquetes de Kubernetes, templatiza YAML en charts y gestiona releases. Evita copiar y pegar YAML por ambiente, parametriza solo lo necesario, valida con helm lint y renderiza con helm template. Comandos esenciales: helm create nombre helm template helm install nombre ./chart -n dev --create-namespace helm upgrade --install helm rollback.

Mini-lab práctico (20 a 30 minutos) Objetivo: crear clúster, desplegar hello con YAML crudo y luego con Helm y comparar. 1) Crear clúster rápido con kind: kind create cluster --name k90 kubectl cluster-info kubectl get nodes y opcionalmente fijar namespace con kubectl config set-context --current --namespace=dev. 2) YAML crudo: crea un archivo k8s/hello.yaml con Deployment y Service, aplica con kubectl apply -f k8s/hello.yaml, espera con kubectl rollout status deploy/hello, lista servicios con kubectl get svc hello -o wide y prueba con kubectl port-forward svc/hello 8080:80. 3) Helm-ificar: helm create hello-chart, conserva templates/deployment.yaml y templates/service.yaml, ajusta values.yaml con replicaCount imagem repo y tag, renderiza con helm template hello ./hello-chart y compara con diff. Instala con helm install hello ./hello-chart -n dev --create-namespace y prueba igual que con YAML crudo. Actualiza y revierte con helm upgrade hello ./hello-chart --set replicaCount=3, helm history hello y helm rollback hello 1.

Atajos imprescindibles, mi top 12: kubectl config get-contexts, kubectl config set-context --current --namespace=dev, kubectl get pods -o wide, kubectl describe pod nombre, kubectl get events --sort-by=.lastTimestamp, kubectl apply -f archivo.yaml, kubectl rollout status deploy/nombre, kubectl logs deploy/nombre -f, kubectl port-forward svc/nombre 8080:80, helm template nombre chart, helm install nombre chart -f values.yaml, helm upgrade --install nombre chart.

Fallo comunes y recuperación: ImagePullBackOff o ErrImagePull revisa kubectl describe pod y prueba docker pull localmente, añade imagePullSecrets si el registro es privado. Pods en Pending revisa recursos, nodos y PVCs con kubectl describe pod y kubectl get nodes. Services que no enrutan suelen deberse a selectores que no coinciden con labels; compara spec.selector con pod.metadata.labels. Contexto o namespace equivocado arregla con kubectl config current-context y kubectl config set-context. Problemas con Helm por campos inmutables como spec.clusterIP requieren conservar el valor o desinstalar y reinstalar el Service.

Pequeño script de ejemplo para crear o eliminar un clúster kind: el script usa strict mode en bash, toma nombre de clúster por argumento y acción up o down, ejecuta kind create cluster --name CLUSTER y luego kubectl config set-context --current --namespace=dev para fijar namespace. Es útil porque automatiza life cycle, evita errores parciales y reduce tecleo.

Notas prácticas: en macOS si el bash del sistema es antiguo usa zsh o instala bash via Homebrew. En Linux añade tu usuario al grupo docker con usermod -aG docker USUARIO y reloga. En Windows lo mejor es usar WSL2 y asegurar que Docker Desktop tenga backend WSL2.

Sobre Q2BSTUDIO: somos una empresa de desarrollo de software especializada en aplicaciones a medida y software a medida, con experiencia en inteligencia artificial, ciberseguridad y servicios cloud aws y azure. Creamos soluciones a medida para negocios que requieren automatizar procesos, integrar agentes IA y sacar partido a la analítica con herramientas como Power BI. Si buscas desarrollo de aplicaciones robustas consulta nuestra página de desarrollo de aplicaciones y si necesitas infraestructura en la nube revisa nuestros servicios cloud. Ofrecemos servicios de inteligencia de negocio, ia para empresas, agentes IA y soluciones de ciberseguridad y pentesting para proteger tus activos.

Conclusión y siguientes pasos: ya tienes un clúster local para practicar, un Deployment y Service con YAML y un chart minimal de Helm. Próximos temas recomendados: ingress versus NodePort versus LoadBalancer con add-ons locales, actualizaciones continuas y probes de readiness y liveness, gestión de ConfigMaps y Secrets, requests y limits y HPA, y estrategias avanzadas de Helm con layering de values y helmfile. Guarda este artículo, ten a mano los snippets y empieza a iterar para dominar despliegues en Kubernetes mientras aprovechas tecnologías de inteligencia artificial y servicios cloud para potenciar tus soluciones a medida.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat