简体   繁体   English

Pulumi 在运行时获取 kubernetes 上下文

[英]Pulumi get kubernetes context at runtime

Is there a way to get the current kubernetes context at runtime to prevent calling pulumi up with the incorrect context?有没有办法在运行时获取当前的 kubernetes 上下文以防止使用不正确的上下文调用pulumi up I'd specifically like to make sure my local kubernetes deployment logic doesn't end up in anything other than a local cluster.我特别想确保我的本地 kubernetes 部署逻辑不会以本地集群以外的任何方式结束。

I've gone through the examples and don't see anything that does this: https://github.com/pulumi/examples/search?l=TypeScript&p=2&q=context&type= (maybe I'm thinking about my problem the wrong way).我已经浏览了示例,但没有看到任何这样做的内容: https : //github.com/pulumi/examples/search? l =TypeScript&p=2&q=context&type= (也许我在考虑我的问题是错误的道路)。

As explained here , first you have to create a context for your cluster that will be used, for example:正如解释在这里,首先你要创建群集将被使用,例如上下文:

kubectl config \
    set-context <my-context> \
    --cluster=<my-cluster> \
    --user=<my-user>

Then run pulumi stack init new-kube-stack where you will be asked to enter your access token and finally run pulumi config set kubernetes:context my-context to work in a cluster defined in previously created context.然后运行pulumi stack init new-kube-stack ,您将被要求输入访问令牌,最后运行pulumi config set kubernetes:context my-context以在先前创建的上下文中定义的集群中工作。

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

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