简体   繁体   English

谷歌云构建和部署到 Kubernetes 环境变量

[英]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 配置文件的KustomizeKpt等部署程序。 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.

相关问题 开始使用 Google Cloud Kubernetes 集群后,Cloud Build 无法部署 Cloud Run - Cloud Build fails to deploy Cloud Run after started using Google Cloud Kubernetes Cluster 将 Kaniko 缓存与用于 Google Cloud 的 Google Cloud Build Kubernetes 部署一起使用 - Using Kaniko cache with Google Cloud Build for Google Cloud Kubernetes Deployments 如何在不使用谷歌云的情况下在 Kubernetes 上部署 wso2? - how deploy wso2 on Kubernetes without using google cloud? 根据另一个环境变量设置 Google Cloud Run 环境变量值 - Set Google Cloud Run environment variables value based on another environment variable 通过 Google Build 部署 Google Cloud Function 错误 - 无法准备上下文:无法评估 Dockerfile 路径中的符号链接 - Deploy Google Cloud Function through Google Build error - unable to prepare context: unable to evaluate symlinks in Dockerfile path 使用云构建部署云 function - Deploy cloud function using cloud build Cloud Build 和 Cloud Deploy 有什么区别? - What is the difference between Cloud Build and Cloud Deploy? 在 Google Cloud Run 中部署 NestJS - Deploy NestJS in Google Cloud Run 如何在 Google Cloud 上备份 Kubernetes 中的 Postgres 数据库? - How to backup a Postgres database in Kubernetes on Google Cloud? Google Cloud Build 不显示任何日志 - Google Cloud Build show no logs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM