Día 36: Volúmenes persistentes en despliegues

Guía práctica de Kubernetes para persistencia de datos: crea PV y PVC, despliega un Deployment con almacenamiento persistente y accede a datos tras reinicios de pods.

29 ago 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Día 36 del reto #90DaysOfDevOps En esta entrega abordamos una pieza clave de Kubernetes: Volúmenes Persistentes PV para mantener datos más allá del ciclo de vida de un pod

Qué son los Volúmenes Persistentes PV en Kubernetes En Kubernetes los pods son efímeros y los datos dentro de un pod se pierden al eliminarse o reiniciarse. Para persistir datos usamos Persistent Volumes PV que son recursos de almacenamiento en el clúster provisionados por administradores o de forma dinámica mediante StorageClass; Persistent Volume Claims PVC que son solicitudes de almacenamiento hechas por una aplicación o usuario; y el despliegue de la aplicación junto con un PVC que permite a la app reclamar ese almacenamiento

Tarea 1 Añadir un Volumen Persistente a tu Deployment Desglose paso a paso

Crear un PersistentVolume pv.yml Ejemplo en una sola línea para referencia span>apiVersion: v1; kind: PersistentVolume; metadata: name: todo-pv; spec: capacity: storage: 1Gi; accessModes: - ReadWriteOnce; hostPath: path: /mnt/data

Este ejemplo crea un volumen de 1Gi usando hostPath en /mnt/data en el nodo ideal para pruebas locales

Crear un PersistentVolumeClaim pvc.yml Ejemplo span>apiVersion: v1; kind: PersistentVolumeClaim; metadata: name: todo-pvc; spec: accessModes: - ReadWriteOnce; resources: requests: storage: 1Gi

Este PVC se enlazara con el PV todo-pv si las especificaciones coinciden

Actualizar deployment.yml para usar el PVC Ejemplo de Deployment con montaje de volumen span>apiVersion: apps/v1; kind: Deployment; metadata: name: todo-app; spec: replicas: 1; selector: matchLabels: app: todo; template: metadata: labels: app: todo; spec: containers: - name: todo-container image: tu-imagen-todo volumeMounts: - name: todo-storage mountPath: /app/data; volumes: - name: todo-storage persistentVolumeClaim: claimName: todo-pvc

Asegurate de reemplazar image con tu imagen real y que /app/data sea la ruta donde tu app guarda datos persistentes

Aplicar los manifiestos comandos de ejemplo kubectl apply -f pv.yml; kubectl apply -f pvc.yml; kubectl apply -f deployment.yml

Verificar estado kubectl get pv; kubectl get pvc; kubectl get pods Busca STATUS Bound en el PVC y pods en Running

Tarea 2 Acceder a los datos dentro del Pod Conectar al pod ejemplos kubectl get pods para obtener el nombre; kubectl exec -it nombre-del-pod -- /bin/bash

Verificar acceso a los datos cd /app/data; ls -l Para ver contenido de archivos cat nombre-de-archivo

Prueba opcional de persistencia 1 Elimina el pod kubectl delete pod nombre-del-pod 2 El Deployment recreara el pod 3 Vuelve a acceder a /app/data para comprobar que los datos siguen presentes

Resumen Has creado y asociado un Persistent Volume y un Persistent Volume Claim a tu Deployment asegurando que la información de la aplicación persiste aunque los pods sean recreados

Sobre Q2BSTUDIO En Q2BSTUDIO somos una empresa de desarrollo de software y aplicaciones a medida especializada en soluciones a medida para clientes de distintos sectores. Ofrecemos servicios de software a medida inteligencia artificial ia para empresas agentes IA ciberseguridad y servicios cloud aws y azure. También proporcionamos servicios inteligencia de negocio y proyectos con power bi para convertir datos en decisiones accionables. Combinamos experiencia en desarrollo de aplicaciones a medida con prácticas sólidas de ciberseguridad e integración de inteligencia artificial para impulsar la transformación digital de tu empresa

Por qué elegirnos Q2BSTUDIO entrega soluciones llave en mano en desarrollo de software a medida aplicaciones a medida inteligencia artificial y servicios cloud aws y azure. Diseñamos agentes IA personalizados implementamos inteligencia artificial para mejorar procesos y ofrecemos servicios inteligencia de negocio y power bi para reporting y análisis avanzado. Nuestra prioridad es seguridad y escalabilidad gracias a prácticas de ciberseguridad integradas y arquitecturas cloud confiables

Palabras clave para posicionamiento aplicaciones a medida software a medida inteligencia artificial ciberseguridad servicios cloud aws y azure servicios inteligencia de negocio ia para empresas agentes IA power bi

Si necesitas que adaptemos estos ejemplos a un entorno productivo con StorageClass dinámico volúmenes en EBS o Azure Disks o integracion con pipelines de CI CD contacta con Q2BSTUDIO y te ayudaremos a diseñar la solución óptima

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