简体   繁体   English

我们如何在 pulumi 中只使用多个 kubernetes 配置中的 1 个配置

[英]How can we use only 1 config out of multiple kubernetes config in pulumi

We have 5 EKS clusters and configs are defined in same folder location.我们有 5 个 EKS 集群,并且在同一文件夹位置定义了配置。 When I try to create a resource, as the stack path is common for all clusters, my resource is getting deployed in all clusters.当我尝试创建资源时,由于堆栈路径对于所有集群都是通用的,因此我的资源会部署在所有集群中。 I have to provide a condition to deploy in a single cluster.我必须提供在单个集群中部署的条件。

在此处输入图片说明

We use github actions and in the workflows, the common stack path is declares.我们使用 github 操作,并且在工作流中,公共堆栈路径是声明。 I am new to pulumi and typescripting, trying to figure out where i can provide condition to deploy only in single cluster with the existing setup.我是 pulumi 和打字稿的新手,试图找出我可以在哪里提供条件以仅在具有现有设置的单个集群中进行部署。 Any help would be appreciated, thank you in advance.任何帮助将不胜感激,在此先感谢您。

With infrastructure automation tools like Pulumi or Terraform, you usually code the setup of how you want our infrastructure to be.使用诸如 Pulumi 或 Terraform 之类的基础设施自动化工具,您通常可以对您希望我们的基础设施的设置进行编码。

In Pulumi, you code your infrastructure in a project.在 Pulumi 中,您可以在一个项目中编码您的基础设施。 The documentation of what a Pulumi project is can be found here: Pulumi 项目的文档可以在这里找到:

https://www.pulumi.com/docs/intro/concepts/project/ https://www.pulumi.com/docs/intro/concepts/project/

When you want to set this up a number of times, you use different stacks for that.当您想要多次设置它时,您可以为此使用不同的堆栈。 Here are the docs on Stacks :以下是Stacks上的文档:

https://www.pulumi.com/docs/intro/concepts/stack/ https://www.pulumi.com/docs/intro/concepts/stack/

Off interest is this sentence in the opening paragraph: Off Interest 是开篇中的这句话:

Stacks are commonly used to denote different phases of development (such as development , staging , and production ) or feature branches (such as feature-x-dev ).堆栈通常用于表示不同的开发阶段(例如developmentstagingproduction )或功能分支(例如feature-x-dev )。

You can put environment specific configuration in the stack config file (YAML).您可以将特定于环境的配置放在堆栈配置文件 (YAML) 中。 When using stacks, you end up with this in your source structure:使用堆栈时,您最终会在源结构中得到以下内容:

Pulumi.yaml       // <- Pulumi project file
Pulumi.dev.yaml   // <- Config for stack `dev`
Pulumi.prod.yaml  // <- Config for stack `prod`

I limit stack configuration to aspects like resource names, sizing config like amount of nodes, etc but not to have flags which lead to creating more/less resources.我将堆栈配置限制在资源名称、节点数量等配置大小等方面,但没有导致创建更多/更少资源的标志。 I explicitely do not want drift between my environments.我明确不希望在我的环境之间漂移。

How I do it is exactly the opposite of what you want to achieve.我的做法与您想要实现的完全相反。 I never have Typescript files resembling an environment.我从来没有类似环境的 Typescript 文件。

Can you elaborate more on what the differences between your environments are?您能否详细说明您的环境之间的差异?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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