How do I add sidecar containers on the prometheus stable Helm Charts values.yaml file?

7/15/2020

I'm currently using the prometheus (NOT prometheus-operator, due to historical reasons) Helm charts in our on-premise Kubernetes cluster, and I'd like to deploy the Thanos sidecar.

How do I add the sidecar containers in the values.yaml file? Are there any examples on this that I can refer to? Seems like there are no documentation whatsoever regarding this, as pointed out by this https://github.com/helm/charts/issues/12815

-- jrlonan
kubernetes
kubernetes-helm
prometheus

2 Answers

7/15/2020

Like the comment said, the template is pretty simple.

  {{- if .Values.server.sidecarContainers }}
  {{- toYaml .Values.server.sidecarContainers | nindent 8 }}
  {{- end }}

You can put a values.yaml with your sidecar snippet like below:

server:
  sidecarContainers:
  - name: testSideCar
    image: alpine

And deploy with helm install prom stable/prometheus -f values.yaml. Then you can find your sidecar section in server deployment yaml:

apiVersion: apps/v1
kind: Deployment
spec:
  template:
    spec:
      serviceAccountName: test-prometheus-server
      containers:
        - name: prometheus-server-configmap-reload
          image: "jimmidyson/configmap-reload:v0.3.0"

          <<... omitted ...>>

        - name: testSideCar
          image: alpine
-- Ken Chen
Source: StackOverflow

7/15/2020

According to configuration section of stable/prometheus chart, you can add server.sidecarContainers

server.sidecarContainers - array of snippets with your sidecar containers for prometheus server

-- edbighead
Source: StackOverflow