简体   繁体   中英

Google Cloud Build and Deploy to Kubernetes environment variables

I'm currently migrating my rest API to Google Cloud. I'm trying to setup a CI/CD pipeline on Kubernetes. So far I managed to build my Docker image with Cloud Build via a Github trigger. I created a pipeline with Cloud Deploy that builds and launch Kubernetes pods on staging and production.

Now I'm trying to inject environment variables to each Kubernetes clusters based on the stage of the pipeline (staging, production, ...).

I managed to create a secret with all my env variables for each environment. But now I don't know how to inject the right secret in the right cluster. Is there a way to get the env for skaffold to render the correct pod config? Something like that:

envFrom:
      - secretRef:
          name: ${env}-api

Or any other better practice.

Thank you

Typically people use a deployer like Kustomize or Kpt with Skaffold profiles. These deployers take an opinionated stance that configuration should be in data files so that they can be reviewed and committed just like source code. It's just too easy to get environment variables mixed up.

The Skaffold getting-started-kustomize example is a good starting point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM