typescript - 如何在 Pulumi 中找到现有的 gitlab 项目集群?
问题描述
我已经在 Gitlab 中连接了一个 Kubernetes 集群作为项目集群 https://gitlab.com/steinKo/gitlabcicd/-/clusters/142291 我想在 Pulumi 中访问这个集群 Folow thw dcumentaion 我可以使用查找现有的 ProjectCluster 资源吗我使用 API 调用
public static get(name: string, id: Input<ID>, state?: ProjectClusterState, opts?: CustomResourceOptions): ProjectCluster
我写
import * as gitlab from "@pulumi/gitlab";
const cluster = gitlab.get("gitlabcicd", ???)
然后我收到一条错误消息:Property get dose not exit 如何使用 get API?我在哪里可以找到身份证?
解决方案
您可以使用以下代码访问集群:
import * as gitlab from "@pulumi/gitlab";
const projectCluster = gitlab.ProjectCluster.get("mycluster", "clusterid");
mycluster
你在 Pulumi 程序中给它的名字是哪里,clusterid
是集群的 GitLab 中的 ID。
您可以使用 GitLab API 获取集群的 ID:https ://docs.gitlab.com/ee/api/project_clusters.html
请注意,这将不允许您对集群进行更改(因为您没有将其导入 Pulumi 程序),但它会为您提供有关集群本身的信息。
如果你想开始在你的 Pulumi 程序中管理集群,那么你可以使用 CLI 通过运行这个命令来导入它:pulumi import gitlab:index/projectCluster:ProjectCluster bar projectid:clusterid
这会给你正确的代码来复制和粘贴到你的 Pulumi 程序中,然后你就可以开始管理它了。
推荐阅读
- jquery - 使用 Fastselect 更改下拉值
- java - 如何在没有额外信息的情况下有效地从一堆网页中提取文本
- json - 如何用里面的函数解析这个复杂的 JSON 对象
- jenkins-pipeline - 如何从 Jenkins 作业 DSL groovy 代码创建和编辑管道定义文件
- sql - sqlite eval INNER JOIN 自我重复 v(*) 条目
- php - 如果发现子项值为空,则删除包含子项的父数组
- java - VS 代码 launch.json 外部终端
- azure - 使我的应用服务受 Azure API 信任
- amazon-web-services - 重命名 Amazon RDS 选项组
- html - 在 Internet Explorer 中运行时,页脚未出现在 Chrome 中