---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: azure-keyvault-airflow
  namespace: default
  annotations:
    clusterconfig.azure.com/use-managed-source: "true"
spec:
  targetNamespace: airflow
  releaseName: keyvault-airflow
  chart:
    spec:
      chart: ./charts/keyvault-secrets
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
  interval: 5m0s
  install:
    remediation:
      retries: 3
  valuesFrom:
    - kind: ConfigMap
      name: config-map-values
      valuesKey: values.yaml
  values:
    secrets:
      - secretName: airflow-secrets 
        data:
          - key: fernet-key
            vaultSecret: airflow-fernet-key
          - key: webserver-key
            vaultSecret: airflow-webserver-key
          - key: password
            vaultSecret: airflow-admin-password
          - key: connection
            vaultSecret: airflow-db-connection
          - key: db-password
            vaultSecret: cpng-user-password
          - key: redis-password
            vaultSecret: redis-password
          - key: tenant-id
            vaultSecret: app-dev-sp-tenant-id
          - key: client-id
            vaultSecret: app-dev-sp-id
          - key: client-key
            vaultSecret: app-dev-sp-password
          - key: insights-key
            vaultSecret: insights-key
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
  name: azure-keyvault-airflow-variables
  namespace: default
  annotations:
    clusterconfig.azure.com/use-managed-source: "true"
spec:
  targetNamespace: airflow
  releaseName: keyvault-airflow-variables
  chart:
    spec:
      chart: ./charts/keyvault-secrets
      sourceRef:
        kind: GitRepository
        name: flux-system
        namespace: flux-system
  interval: 5m0s
  install:
    remediation:
      retries: 3
  valuesFrom:
    - kind: ConfigMap
      name: config-map-values
      valuesKey: values.yaml
  values:
    identity: false
    secrets:
      - secretName: airflow-variables 
        data:
          - key: AIRFLOW_VAR_AZURE_TENANT_ID
            vaultSecret: app-dev-sp-tenant-id
          - key: AIRFLOW_VAR_AZURE_CLIENT_ID
            vaultSecret: app-dev-sp-id
          - key: AIRFLOW_VAR_AZURE_CLIENT_SECRET
            vaultSecret: app-dev-sp-password
          - key: AIRFLOW_VAR_AAD_CLIENT_ID
            vaultSecret: app-dev-sp-id
          - key: AIRFLOW_VAR_APPINSIGHTS_KEY
            vaultSecret: insights-key
          - key: AIRFLOW_VAR_KEYVAULT_URI
            vaultSecret: keyvault-uri