helm conditional block doesn't work when set to false

2/8/2020

I'm trying to create a conditional block to create a PVC or emptyDir. When I set the value to true it works as expected, however when when using false I get the following error: did not find expected '-' indicator

yaml file:

        volumeMounts:
        - name: rabbitmq-data
          mountPath: /etc/rabbitmq/config
          readOnly: false
        - name: mq-tls
          mountPath: /etc/rabbitmq/certfiles
        - name: data
          mountPath: /var/lib/rabbitmq/mnesia
      volumes:
        - name: data
        {{- if .Values.global.rabbitmq.persistence.enabled }}          
          persistentVolumeClaim:
            claimName: rabbitmq-pv-claim
        {{- else }}
        emptyDir: {}    
        {{- end }}           
        - name: mq-tls
          secret:
            secretName: rabbitmq-secrets
            defaultMode: 420
        - configMap:
            name: mq-config
            defaultMode: 420
            items:
            - key: rabbitmq.config
              path: rabbitmq.config
            - key: definitions.json
              path: definitions.json
          name: rabbitmq-data

values.yaml file:

  rabbitmq:
    persistence:
      enabled: false
-- Oren Ashkenazy
kubernetes-helm

0 Answers