Skip to content
Published on

Helm Plugins and Testing Strategies: Extensibility and Quality Assurance

Authors

1. Plugin System

1.1 Plugin Structure

# plugin.yaml
name: 'my-plugin'
version: '1.0.0'
usage: 'A custom Helm plugin'
description: 'This plugin does something useful'
command: '$HELM_PLUGIN_DIR/bin/my-plugin'
hooks:
  install: '$HELM_PLUGIN_DIR/scripts/install.sh'
  update: '$HELM_PLUGIN_DIR/scripts/update.sh'
  delete: '$HELM_PLUGIN_DIR/scripts/cleanup.sh'

1.2 Plugin Management

helm plugin install https://github.com/example/helm-my-plugin
helm plugin list
helm plugin update my-plugin
helm plugin uninstall my-plugin

1.3 Key Plugins

helm-diff: Preview changes before upgrade

helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade my-release ./my-chart -f values.yaml
helm diff revision my-release 2 3

helm-secrets: Secure secret management

helm plugin install https://github.com/jkroepke/helm-secrets
helm secrets install my-release ./my-chart -f secrets.yaml
helm secrets enc secrets.yaml

helm-unittest: Chart unit testing

helm plugin install https://github.com/helm-unittest/helm-unittest
helm unittest ./my-chart

2. Chart Testing

2.1 helm test

Built-in test mechanism that runs in-cluster after release:

# templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
  name: {{ include "my-chart.fullname" . }}-test-connection
  annotations:
    "helm.sh/hook": test
spec:
  restartPolicy: Never
  containers:
    - name: wget
      image: busybox
      command: ['wget']
      args: ['{{ include "my-chart.fullname" . }}:{{ .Values.service.port }}']
helm test my-release --timeout 5m --logs

2.2 helm-unittest

Local unit tests without a cluster:

# tests/deployment_test.yaml
suite: test deployment
templates:
  - deployment.yaml
tests:
  - it: should create deployment with correct replicas
    set:
      replicaCount: 3
    asserts:
      - isKind:
          of: Deployment
      - equal:
          path: spec.replicas
          value: 3

  - it: should set correct image
    set:
      image:
        repository: nginx
        tag: '1.25'
    asserts:
      - equal:
          path: spec.template.spec.containers[0].image
          value: 'nginx:1.25'

  - it: should not create ingress when disabled
    template: ingress.yaml
    set:
      ingress:
        enabled: false
    asserts:
      - hasDocuments:
          count: 0

2.3 ct (chart-testing) Tool

Automated chart change detection and testing in CI/CD:

ct list-changed --target-branch main
ct lint --target-branch main
ct install --target-branch main
ct lint-and-install --target-branch main

3. Linting

helm lint ./my-chart --strict
helm lint ./my-chart -f production-values.yaml

# Kubernetes schema validation
helm template my-release ./my-chart | kubeconform -strict -kubernetes-version 1.29.0

4. Schema Validation

{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["replicaCount", "image"],
  "properties": {
    "replicaCount": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "image": {
      "type": "object",
      "required": ["repository"],
      "properties": {
        "repository": { "type": "string" },
        "tag": { "type": "string", "default": "latest" },
        "pullPolicy": { "type": "string", "enum": ["Always", "IfNotPresent", "Never"] }
      }
    },
    "service": {
      "type": "object",
      "properties": {
        "type": { "type": "string", "enum": ["ClusterIP", "NodePort", "LoadBalancer"] },
        "port": { "type": "integer", "minimum": 1, "maximum": 65535 }
      }
    }
  }
}

Schema is automatically validated during helm install, helm upgrade, helm lint, and helm template.


5. OCI Registry Advanced Usage

helm package ./my-chart
helm push my-chart-1.0.0.tgz oci://ghcr.io/myorg/charts
helm install my-release oci://ghcr.io/myorg/charts/my-chart --version 1.0.0
helm pull oci://ghcr.io/myorg/charts/my-chart --version 1.0.0

6. Chart Signing and Verification

helm package --sign --key 'my-key' --keyring ~/.gnupg/secring.gpg ./my-chart
helm verify my-chart-1.0.0.tgz
helm install my-release my-chart-1.0.0.tgz --verify

7. Summary

Helm extensibility and quality assurance:

  1. Plugin system: Extend functionality with helm-diff, helm-secrets, helm-unittest
  2. Multi-layer testing: Combine helm test (integration), unittest (unit), ct (CI/CD)
  3. Linting: Multi-angle validation with helm lint, yamllint, kubeconform
  4. Schema validation: Ensure input validity with values.schema.json
  5. OCI registry: Deploy charts using the same workflow as container images
  6. Signing/verification: Prove chart integrity and provenance