vectordotdev / helm-charts

Helm charts for Vector.
https://vector.dev
Mozilla Public License 2.0
111 stars 90 forks source link

Add chart test to manifest #309

Open skygrammas opened 1 year ago

skygrammas commented 1 year ago

Helm supports chart tests, which can help validate that a chart works as expected when installed. Additionally, chart tests can help a chart consumer understand how a chart should behave. These tests are fairly simple jobs and could reduce the deployment of erroneous charts. For example, #306 highlights how chart version 0.22.0 is effectively broken by changes introduced in #291; I believe that a chart test that simply validates Vector's configuration could catch such issues and accelerate less-faulty releases.

I am recommending that a chart test be added to the chart manifest for Vector's Helm charts.

skygrammas commented 1 year ago

An example job specification that may be effective is the following:

apiVersion: batch/v1
kind: Job
metadata:
  name: vector-test-installation
spec:
  template:
    metadata:
      annotations:
        "helm.sh/hook": test
    spec:
      containers:
      - name: vector-validate
        image: timberio/vector:{{ .Values.image.tag }}
        command: ['vector']
        args: ['validate --config-yaml /etc/vector/vector.yaml; echo $?']
        {{- if hasKey .Values "env" }}
        env:
        {{- .Values.env | toYaml | nindent 8 }}
        {{- end }}
        volumeMounts:
        - name: config
          mountPath: /etc/vector/vector.yaml
          subPath: vector.yaml
      volumes:
      - name: config
        configMap:
          name: vector-test-configmap
      restartPolicy: Never
spencergilbert commented 1 year ago

I haven't checked recently, but I do remember chart tests causing problems with ArgoCD a couple years back - it would be good to make sure we don't cause unpleasant regressions if we add them.