OT-CONTAINER-KIT / helm-charts

A repository which that will contain helm charts with best and security practices.
https://ot-container-kit.github.io/helm-charts
49 stars 84 forks source link

sidecar and initContainer can't be generated by HELM in Cluster / Replication / Sentinel #176

Open mrhovunping opened 10 months ago

mrhovunping commented 10 months ago

Does this issue reproduce with the latest release?

Yes.

redis-cluster: 0.15.11 redis-replication: 0.15.11 redis-sentinel: 0.15.12

What operating system and processor architecture are you using (kubectl version)?

kubectl version Output
$ kubectl version
Client Version: v1.28.2

Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3

Server Version: v1.21.9

WARNING: version difference between client (1.28) and server (1.21) exceeds the supported minor version skew of +/-1

What did you do?

Set SideCar `

sidecars:
  - name: "redis-labeler-sidecar"
    image: "registry.gitlab.com/smartadserver/infra/containers/k8s-redis-labeler-sidecar/k8s-redis-labeler-sidecar:0.0.3"
    imagePullPolicy: "IfNotPresent"
    resources: {}
    env: 
      - name: LABEL_SELECTOR
        value: "role=replication,redis_setup_type=replication"
      - name: NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: LOG_LEVEL
        value: "debug"
      - name: POD_NAME
        valueFrom:
          fieldRef:
            fieldPath: metadata.name

What did you expect to see? ` Expect to have a yml file generated with :

apiVersion: redis.redis.opstreelabs.in/v1beta2 kind: RedisReplication metadata: name: test labels: app.kubernetes.io/name: test helm.sh/chart: redis-replication-0.15.11 app.kubernetes.io/managed-by: Helm app.kubernetes.io/instance: test app.kubernetes.io/version: 0.15.1 app.kubernetes.io/component: middleware spec: clusterSize: 3
kubernetesConfig: image: "quay.io/opstree/redis:v7.0.12" imagePullPolicy: "IfNotPresent"

redisExporter: enabled: false image: "quay.io/opstree/redis-exporter:v1.44.0" imagePullPolicy: "IfNotPresent" storage: volumeClaimTemplate: spec: accessModes:

What did you see instead?

Error message:

Install.go:192: [debug] Original chart version: ""
install.go:209: [debug] CHART PATH: /home/sho/git/bug-165/charts/redis-replication

Error: template: redis-replication/templates/redis-replication.yaml:80:15: executing "redis-replication/templates/redis-replication.yaml" at <include>: wrong number of args for include: want 2 got 1
helm.go:84: [debug] template: redis-replication/templates/redis-replication.yaml:80:15: executing "redis-replication/templates/redis-replication.yaml" at <include>: wrong number of args for include: want 2 got 1
mrhovunping commented 10 months ago

The problem comes from the code :

  {{- if and .Values.sidecars (ne .Values.sidecars.name "") (ne .Values.sidecars.image "") }}
  sidecars: {{ include "sidecar.properties" | nindent 4 }}
  {{- end }}

Where it should be

  {{- if and .Values.sidecars (ne .Values.sidecars.name "") (ne .Values.sidecars.image "") }}
  sidecars: {{ include "sidecar.properties ." | nindent 4 }}
  {{- end }}

Same problem found in redis-replication / redis-sentinel and redis-cluster with sidecars and initContainer