DEV Community

Guillermo Garcia
Guillermo Garcia

Posted on • Originally published at ahioros.info on

Helm creando tu repositorio

Antes de enseñarte a cómo hacer tu propio repositorio, primero te voy a enseñar cómo administrar los repositorios.

Buscar en el repositorio de Helm:

helm search hub grafana 
Enter fullscreen mode Exit fullscreen mode

Buscar en los repositorios ya instalados:

helm searh repo grafana 
Enter fullscreen mode Exit fullscreen mode

Para ver los Values de un paquete:

helm show values grafana 
Enter fullscreen mode Exit fullscreen mode

Supongamos que hiciste tu propio archivo de values y lo quieres aplicar en lugar del que trae por el paquete:

helm install -f miarchivo.yaml aplicación paquete 
Enter fullscreen mode Exit fullscreen mode

Crear repositorio con GitHub

1. Creas un nuevo repositorio público en GitHub. 2. Ahora que estas en el repositorio nuevo que creaste, vas a settings -> Pages (en la barra de la izquierda). 
Enter fullscreen mode Exit fullscreen mode

Image description

3. En Branch seleccionas la branch que quieres usar, en este ejemplo usaré main y por último seleccionas el directorio que por default es /(root). 4. Por último le das click en Save. Con esto has creado un repositorio. 
Enter fullscreen mode Exit fullscreen mode

La URL para acceder a tu repositorio es:

https://tuuser.github.io/tu-repositorio/

Por ejemplo:
https://ahioros.github.io/nginx-charts/

Image description

Subir nuestro paquete al repositorio.

En el post anterior creamos nuestro package/paquete de nuestra aplicación. Para que funcione nuestro repositorio debemos crear una carpeta llamada charts y dentro poner nuestro paquete.

Image description

Ahora debemos crear un archivo index.yaml para que helm sepa que charts hay dentro del repositorio.

helm repo index . 
Enter fullscreen mode Exit fullscreen mode

Nota: Hay un espacio y un punto después de index.

El contenido de este index.yaml es:

Image description

Ahora queda subirlo al repositorio de github.

Agregando nuestro repositorio a Helm

Para agregar nuestro repositorio a Helm debemos ejecutar:

helm repo add turepo https://TUURLDETUREPOSITORIO/TUCHARTS helm repo add ahioros https://ahioros.github.io/nginx-charts/ 
Enter fullscreen mode Exit fullscreen mode

Image description

Comprobamos que se ha agregado correctamente nuestro repositorio:

helm search repo turepo helm search repo ahioros 
Enter fullscreen mode Exit fullscreen mode

Image description

Instalando desde tu repositorio

Ahora lo que queda es instalar tus propios paquetes desde tu repositorio recien creado.

Puedes realizar una "instalación fake"

helm install --dry-run nombrepaquete turepo/nombrepaquete helm install --dry-run test ahioros/nginx-chart 
Enter fullscreen mode Exit fullscreen mode

Nota: esto nos instalará el paquete nginx-chart (sin S al final) de nuestro reposirotorio que se llama nginx-charts (con S al final) el paquete cuando sea instalado se llamará test.

Salida:

--- NAME: test LAST DEPLOYED: Tue Aug 27 18:48:41 2024 NAMESPACE: default STATUS: pending-install REVISION: 1 TEST SUITE: None HOOKS: MANIFEST: --- # Source: nginx-chart/templates/namespace.yaml apiVersion: v1 kind: Namespace metadata: name: nginx-chart --- # Source: nginx-chart/templates/lbl-service.yaml apiVersion: v1 kind: Service metadata: name: loadbalancer-test-nginx-chart namespace: nginx-chart spec: ports: - port: 80 targetPort: 80 protocol: TCP type: LoadBalancer selector: app: app.kubernetes.io/name: nginx-chart app.kubernetes.io/instance: test --- # Source: nginx-chart/templates/service.yaml apiVersion: v1 kind: Service metadata: name: test-nginx-chart namespace: nginx-chart spec: selector: app: helm.sh/chart: nginx-chart-1.0.0 app.kubernetes.io/name: nginx-chart app.kubernetes.io/instance: test app.kubernetes.io/version: "1.16.0" app.kubernetes.io/managed-by: Helm ports: - protocol: TCP port: 80 targetPort: 80 --- # Source: nginx-chart/templates/deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: test-nginx-chart namespace: nginx-chart spec: replicas: 2 selector: matchLabels: app: app.kubernetes.io/name: nginx-chart app.kubernetes.io/instance: test template: metadata: labels: app: app.kubernetes.io/name: nginx-chart app.kubernetes.io/instance: test spec: containers: - name: nginx image: nginx:latest ports: - containerPort: 80 NOTES: Nginx se ha desplegado correctamente. Puedes acceder a la aplicación a través de http://IP:80 --- 
Enter fullscreen mode Exit fullscreen mode

Ahora si todo está bien ya puedes instalar tu paquete, solo debes quitar el --dry-run:

helm install nginx-chart ahioros/nginx-chart 
Enter fullscreen mode Exit fullscreen mode

Image description

Podemos verificar nuestra aplicación instalada con kubectl:

kubectl get all -n nginx-chart 
Enter fullscreen mode Exit fullscreen mode

Image description

Listo hasta aquí la guía de Helm, espero que te sirva, si tienes dudas puedes dejarla en los comentarios.

Top comments (0)