Helmfile - Next Level to manage your helm Charts





Helmfile is a new way to manage multiple helm charts adding additional features over helm and kubectl.


Why Helmfile ?

Helmfile is a declarative spec for deploying helm charts. It lets you...

  • Keep a directory of chart value files and maintain changes in version control.

  • Apply CI/CD to configuration changes.

  • Periodically sync to avoid skew in environments.

To avoid upgrades for each iteration of helm, the helmfile executable delegates to helm - as a result, helm must be installed.


How to Install

Download latest release from here

wget https://github.com/roboll/helmfile/releases/download/v0.126.0/helmfile_linux_386
chmod +x helmfile_linux_386
mv helmfile_linux_386 /usr/bin/local/helmfile

Clone example charts

git clone https://github.com/linuxadvise/helmfile

Above sample charts creates following resources -

  1. A deployment set

  2. Service of Ingress type

  3. Secrets

  4. ConfigMaps of Env variables


Chart tree

.
├── charts
│   └── appname
│       ├── charts
│       ├── Chart.yaml
│       ├── templates
│       │   ├── deployment.yaml
│       │   ├── _helpers.tpl
│       │   ├── ingress.yaml
│       │   ├── NOTES.txt
│       │   ├── serviceaccount.yaml
│       │   ├── service.yaml
│       │   └── tests
│       │       └── test-connection.yaml
│       └── values.yaml
├── helmfile.d
│   ├── helmfile.yaml
│   ├── releases
│   │   └── appname.yaml
│   └── values
│       └── appname.yaml.gotmpl
├── README.md


Main folder with templating chart located at helm/charts

Description

The most interesting thing is located here helm/helmfile.d

helmfile.yaml - this file contains path to releases file

helmfiles:
  - "releases/appname.yaml"

releases/appname.yaml - this file contains main parameters for release

releases:
  # Name for release
  - name: "appname"
    # Namespace for application 
    namespace: {{ env "NAMESPACE" | default "appnamespace" }}
    labels:
      # Chart name
      chart: "appname"
      # Component for chart
      component: "appname"
      # Namespace for application 
      namespace: {{ env "NAMESPACE" | default "appnamespace" }}
    # Path to the chart
    chart: "../../charts/appname"
    # Options - wait when release deployed
    wait: true
    # set `false` to uninstall this release on sync.  (default true)
    installed: {{ env "INSTALLED" | default "true" }}
    # Path to variables files
    values:
    - ../values/appname.yaml.gotmpl

values/appname.yaml.gotmpl - this file contains variables for chart

image:
  # Environment variable with contain url for docker image in gcr
  repository: {{ requiredEnv "REPOSITORY_URL" }}
  # Tag for docker image
  tag: {{ requiredEnv "IMAGE_TAG" }}

# Enable service creating
service:
  enabled: true


ingress:
  # Enable ingress creating
  enabled: true
  annotations:
    # Choose ingress controller 
    kubernetes.io/ingress.class: "nginx"
    # Enable ssl redirect 
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    # Choose cluster-issuer
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
  hosts:
    # Domain name for http
    - host: {{ requiredEnv "DOMAIN_NAME" }}
    # Default path 
      paths:
        - /
  tls:
  - hosts:
    # Domain name for https
    - {{ requiredEnv "DOMAIN_NAME" }}
    # Secret name which contains ssl certificate
    secretName: {{ requiredEnv "DOMAIN_NAME" }}-tls-cert


resources:
  limits:
  # CPU limit
    cpu: 500m
  # Memory limit
    memory: 512Mi
  requests:
  # Default CPU 
    cpu: 200m
  # Default memory
    memory: 256Mi

ports:
  - name: http
    # Port for application container
    containerPort: 3000
    protocol: TCP

livenessProbe:
  initialDelaySeconds: 30
  tcpSocket:
    port: 3000
readinessProbe:
  initialDelaySeconds: 30
  tcpSocket:
    port: 3000

# Envirinment variables for application container
env:
  - name: NODE_ENV
    value: "development"
  - name: DB
    value: {{ env "DB" }}


How To Run ?


Check the syntax

# helmfile template 

Apply the chart

# helmfile sync

Hope this helps you get started with dealing with your helm charts in a much more smarter way.










61 views0 comments

Recent Posts

See All
 

Subscribe Form

©2020 by Linux Advise