Helm diff using a plugin

helm upgrade diff

3 min read | by Jordi Prats

Just as with kubectl diff, there's a helm plugin that helm us to the the actual differences that it will apply to the kubernetes cluster without much of the clutter that we will find by combining kubectl diff with the yaml output of a helm dry-run

We can find this plugin on github: https://github.com/databus23/helm-diff

By using the Helm plugin manager (> 2.3.x), installation is as simple as this:

helm plugin install https://github.com/databus23/helm-diff 

Once we have it, by just adding diff before the upgrade command we will get all the yaml files with it's differences, for example:

$ helm diff upgrade pet2cattle -f pet2cattle_values.yaml . kube-system, pet2cattle, Deployment (apps) has changed:  # Source: pet2cattle/templates/00-webapp.yaml  apiVersion: apps/v1  kind: Deployment  metadata:  name: pet2cattle  labels:  helm.sh/chart: pet2cattle-2  app.kubernetes.io/name: pet2cattle  app.kubernetes.io/instance: pet2cattle - app.kubernetes.io/version: "3.11" + app.kubernetes.io/version: "3.12"  app.kubernetes.io/managed-by: Helm  spec:  replicas: 1  selector:  matchLabels:  app.kubernetes.io/name: pet2cattle  app.kubernetes.io/instance: pet2cattle  template:  metadata:  labels:  app.kubernetes.io/name: pet2cattle  app.kubernetes.io/instance: pet2cattle  spec:  securityContext:  {}  containers:  - name: pet2cattle  securityContext:  {} - image: "172.18.1.46:5000/p2c:3.11" + image: "172.18.1.46:5000/p2c:3.12"  imagePullPolicy: IfNotPresent  env:  - name: MINIO_URL  value: "http://pet2cattle-minio.kube-system.svc.cluster.local:9000"  - name: MINIO_BUCKET  value: "pet2cattle"  - name: MINIO_ACCESS_KEY  valueFrom:  secretKeyRef:  name: pet2cattle-minio  key: accesskey  - name: MINIO_SECRET_KEY  valueFrom:  secretKeyRef:  name: pet2cattle-minio  key: secretkey  ports:  - name: http  containerPort: 8000  protocol: TCP  livenessProbe:  httpGet:  path: /  port: http  readinessProbe:  httpGet:  path: /  port: http  resources:  {} kube-system, pet2cattle, Service (v1) has changed:  # Source: pet2cattle/templates/10-websvc.yaml (...) 

If you are already familiar with the yaml files it might be too many data so we can also limit the amount of context it provides by using the -C option:

$ helm diff -C 3 upgrade pet2cattle -f pet2cattle_values.yaml . kube-system, pet2cattle, Deployment (apps) has changed: ...  helm.sh/chart: pet2cattle-2  app.kubernetes.io/name: pet2cattle  app.kubernetes.io/instance: pet2cattle - app.kubernetes.io/version: "3.11" + app.kubernetes.io/version: "3.12"  app.kubernetes.io/managed-by: Helm  spec:  replicas: 1 ...  - name: pet2cattle  securityContext:  {} - image: "172.18.1.46:5000/p2c:3.11" + image: "172.18.1.46:5000/p2c:3.12"  imagePullPolicy: IfNotPresent  env:  - name: MINIO_URL ... kube-system, pet2cattle, Service (v1) has changed: ...  helm.sh/chart: pet2cattle-2  app.kubernetes.io/name: pet2cattle  app.kubernetes.io/instance: pet2cattle - app.kubernetes.io/version: "3.11" + app.kubernetes.io/version: "3.12"  app.kubernetes.io/managed-by: Helm  spec:  type: ClusterIP ... (...) 

Posted on 15/01/2021

Categories