[英]Google Cloud Build and Deploy to Kubernetes environment variables
I'm currently migrating my rest API to Google Cloud.我目前正在将我的 rest API 迁移到 Google Cloud。 I'm trying to setup a CI/CD pipeline on Kubernetes.
我正在尝试在 Kubernetes 上设置 CI/CD 管道。 So far I managed to build my Docker image with Cloud Build via a Github trigger.
到目前为止,我设法通过 Github 触发器使用 Cloud Build 构建了我的 Docker 映像。 I created a pipeline with Cloud Deploy that builds and launch Kubernetes pods on staging and production.
我使用 Cloud Deploy 创建了一个管道,该管道在暂存和生产环境中构建和启动 Kubernetes pod。
Now I'm trying to inject environment variables to each Kubernetes clusters based on the stage of the pipeline (staging, production, ...).现在我正在尝试根据管道的阶段(暂存、生产......)将环境变量注入每个 Kubernetes 集群。
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?
有没有办法让 skaffold 的环境呈现正确的 pod 配置? 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.通常,人们使用带有 Skaffold 配置文件的Kustomize或Kpt等部署程序。 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. Skaffold
getting-started-kustomize
示例是一个很好的起点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.