Lab 10.4 - Helmfile y Multi-entornos
Objetivos del Lab
Al final de este laboratorio, usted será capaz de:
- Instalar Helmfile.
- Comprender la estructura de un helmfile.yaml.
- Gestionar múltiples entornos (dev, staging, prod).
- Desplegar aplicaciones con Helmfile.
Duración Estimada
45-60 minutos
Prerrequisitos
- Helm instalado y configurado.
- Cluster Kubernetes local funcional.
- Conocimientos sobre Helm (laboratorios anteriores).
Parte 1: Instalación de Helmfile
Paso 1.1: Instalar Helmfile
En Linux/Mac:
wget https://github.com/helmfile/helmfile/releases/download/v0.153.1/helmfile_0.153.1_linux_amd64.tar.gz
tar -xzf helmfile_0.153.1_linux_amd64.tar.gz
sudo mv helmfile /usr/local/bin/
En Windows (con Chocolatey):
choco install helmfile
Verifique:
helmfile version
Parte 2: Creación de un helmfile.yaml
Paso 2.1: Crear un helmfile.yaml Simple
Cree helmfile.yaml:
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
releases:
- name: nginx
namespace: default
chart: bitnami/nginx
values:
- replicaCount: 2
service:
type: ClusterIP
Paso 2.2: Desplegar con Helmfile
helmfile sync
Parte 3: Multi-entornos
Paso 3.1: Crear la Estructura
Cree carpetas para los entornos:
mkdir -p environments/{dev,staging,prod}
Paso 3.2: Crear helmfile.yaml con Entornos
Cree helmfile.yaml:
environments:
default:
values:
- environments/dev/values.yaml
staging:
values:
- environments/staging/values.yaml
prod:
values:
- environments/prod/values.yaml
releases:
- name: my-app
namespace: {{ .Values.namespace }}
chart: bitnami/nginx
values:
- replicaCount: {{ .Values.replicaCount }}
Paso 3.3: Crear los Archivos de Valores
Cree environments/dev/values.yaml:
namespace: dev
replicaCount: 1
Cree environments/staging/values.yaml:
namespace: staging
replicaCount: 2
Cree environments/prod/values.yaml:
namespace: prod
replicaCount: 3
Paso 3.4: Desplegar para un Entorno
# Desarrollo
helmfile -e dev sync
# Staging
helmfile -e staging sync
# Producción
helmfile -e prod sync
Parte 4: Gestión con Helmfile
Paso 4.1: Listar los Releases
helmfile list
Paso 4.2: Eliminar
helmfile destroy
Resumen del Lab
En este laboratorio, usted ha utilizado Helmfile para gestionar despliegues multi-entorno. Ha aprendido a estructurar sus configuraciones y a desplegar en diferentes entornos.
Próximos Pasos
Este módulo sobre Helm está ahora completo. Puede continuar con el Módulo 11 sobre Monitoring y Observabilidad.
Módulo 11: Monitoring y Observabilidad
Laboratorio creado el: Diciembre 2024