flux how do you get value from secret and substitute that with your helm releases

In helm, it is very common to deploy helm with secret values. This secret are typically kubernetes secret. 

To see this in action, we will create a secret and then we will deploy our helm using HelmRelease from Flux (please do not mixed this up with Kustomization - we often used it together)

Here is our secret and this is what it looks like :-


apiVersion: v1
kind: Secret
metadata:
  name: external-dns-credentials
  namespace: kube-system
type: Opaque
stringData:
  tenantId: "tenantId"
  subscriptionId: "subscriptionId"
  resourceGroup: "my-resource-group"
  aadClientId: "myclientId"
  aadClientSecret: "mysecret"


And this is the template that get the value file from a secret and put it into the proper place 

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: external-dns-ext
spec:
  releaseName: external-dns-ext
  targetNamespace: kube-system
  interval: 5m
  chart:
    spec:
      chart: external-dns
      sourceRef:
        kind: HelmRepository
        name: external-dns
        namespace: flux-system
      version: "1.2.0"
  install:
    remediation:
      retries: -1
      remediateLastFailure: true
    crds: Create
  upgrade:
    crds: CreateReplace
    disableHooks: true
    cleanupOnFail: true
    remediation:
      retries: -1
      remediateLastFailure: true
  rollback:
    cleanupOnFail: true
  valuesFrom:
    - kind: Secret
      name: external-dns-credentials
      valuesKey: aadClientId
      targetPath: azure.aadClientId
    - kind:     Secret
      name: external-dns-credentials
      valuesKey: aadClientSecret
      targetPath: azure.aadClientSecret
  values:
    sources:
    - service

The key part is this text in red. Here we are getting the value from secret called external-dns. credentials. "aadClientId" - this is where we will be getting the value from - please look at the secret yaml above   

- kind: Secret
  name: external-dns-credentials
  valuesKey: aadClientId
targetPath: azure.aadClientId

Then targetPath: azure.aadClient. So this means we will render something like 

Final output of our value.yaml and that's what we will be deploying 



azure:
  aadClientId: <aadClient-Id-from-secret-called-external-dns-credentials>
  aadClientSecret:<aadClient-Secret-from-secret-called-external-dns-credentials>









Comments

Popular posts from this blog

vllm : Failed to infer device type

android studio kotlin source is null error

gemini cli getting file not defined error