Search code examples
postgresqlkubernetesazure-pipelinesairflowchmod

/templates/postgres.yaml:35:27: executing "airflow/templates/postgres.yaml" at <.Values.chmod.image>: map has no entry for key "chmod"


[ERROR] templates/: template: airflow/templates/postgres.yaml:35:27: executing "airflow/templates/postgres.yaml" at <.Values.chmod.image>: map has no entry for key "chmod"

Here is my yaml file:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: {{ .Values.postgres.name }}
spec:
  selector:
    matchLabels:
      name: {{ .Values.postgres.label }}
  replicas: 1
  template:
    metadata:
      labels:
        name: {{ .Values.postgres.label }}
    spec:
      restartPolicy: {{ .Values.postgres.restartPolicy }}
      initContainers:
        - name: init-chmod-data
          image: {{ .Values.chmod.image }}
          imagePullPolicy: {{ .Values.airflow.image.pullPolicy }}
          command:
            - /bin/sh
            - -cx
            - |
              mkdir -p /var/lib/postgresql/data/pgdata
              chown -R 999:999 /var/lib/postgresql/data/pgdata
              ls -l /var/lib/postgresql/data
          volumeMounts:
            - name: vol
              mountPath: /var/lib/postgresql/data/pgdata
              subPath: postgresql/pgdata
      containers:
        - name: {{ .Values.postgres.containers.name }}
          image: {{ .Values.postgres.image.name }}
          imagePullPolicy: {{ .Values.postgres.image.imagePullPolicy }}
          ports:
            - containerPort: {{ .Values.postgres.ports.containerPort }}
              protocol: {{ .Values.postgres.ports.protocol }}
          volumeMounts:
            - name: vol
              mountPath: /var/lib/postgresql/data/pgdata
              subPath: postgresql/pgdata
          env:
            - name: POSTGRES_USER
              value: {{ .Values.postgres.env.user }}
            - name: POSTGRES_PASSWORD
              value: {{ .Values.postgres.env.password }}
            - name: POSTGRES_DB
              value: {{ .Values.postgres.env.database }}
            - name: PGDATA
              value: /var/lib/postgresql/data/pgdata
            - name: POD_IP
              valueFrom: { fieldRef: { fieldPath: status.podIP } }
          command: ["docker-entrypoint.sh"]
          args:
            - "postgres"
            - "-cshared_buffers=512MB"
            - "-cmax_connections=500"
          livenessProbe:
            initialDelaySeconds: {{ .Values.postgres.livenessProbe.initialDelaySeconds }}
            timeoutSeconds: {{ .Values.postgres.livenessProbe.timeoutSeconds }}
            failureThreshold: {{ .Values.postgres.livenessProbe.failureThreshold }}
            exec:
              command:
              - /bin/sh
              - -c
              - exec pg_isready --host $POD_IP ||  if [[ $(psql -qtAc --host $POD_IP 'SELECT pg_is_in_recovery') != "f" ]]; then  exit 0 else; exit 1; fi
          readinessProbe:
            initialDelaySeconds: {{ .Values.postgres.readinessProbe.initialDelaySeconds }}
            timeoutSeconds: {{ .Values.postgres.readinessProbe.timeoutSeconds }}
            periodSeconds: {{ .Values.postgres.readinessProbe.periodSeconds }}
            exec:
              command:
              - /bin/sh
              - -c
              - exec pg_isready --host $POD_IP
      volumes:
        - name: {{ .Values.postgres.volumes.name }}
          persistentVolumeClaim:
            claimName: {{ .Values.postgres.volumes.persistentVolumeClaim.claimName }}
      imagePullSecrets:
        - name: {{ .Values.postgres.image.pullSecrets }}
---
apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.postgres.service.name }}
spec:
  ports:
    - port: {{ .Values.postgres.service.ports.port }}
      targetPort: {{ .Values.postgres.service.ports.targetPort }}
  selector:
    name: {{ .Values.postgres.service.name }}

Solution

  • It seems you are using a very old version of airflow helm chart, so it's better to upgrade it to a newer version.

    For your problem, it says that chmod doesn't exist in your values file, and where it's a simple image used to execute some basic commands, I think you can use any linux image (alpine for example). So to solve the issue, you need to add this to your values.yml file:

    chmod:
      image: alpine