繁体   English   中英

我无法为 Pulumi 创建集群,因为代码正在标记,请协助

[英]I cannot create cluster for Pulumi because the code is flagging, please assist

我正在通过 VScode 平台上的 Pulumi 在 Google 云上创建一个集群,它是用 Typescript 编写的,但“集群”标记为红色。

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const cluster = new gcp.container.Cluster("cluster", {
    zone: "us-central1-a"
    initialNodeCount: 3,
});

export const clusterId = cluster.id;

请协助使用 Pulumi 和 IAC for google cloud 来帮助成功创建集群。 谢谢。

显示 Typescript 代码和相应的错误

看起来 Pulumi 无法找到要部署到的 GCP 项目。

您需要按照以下方式在工作站上登录谷歌云: https://www.pulumi.com/docs/get-started/gcp/begin/#configure-gcp

或者,您可以设置相关的环境变量: https://www.pulumi.com/docs/intro/cloud-providers/gcp/setup/#optional-settings

假设您已经安装了Google Cloud SDK ,然后 初始化了 Cloud SDK

运行gcloud auth application-default login

这将导致以下结果;

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=000000000000-abcdefghijklmnopqrstuvwxyz.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud......

Credentials saved to file: [/Users/$HOME/.config/gcloud/application_default_credentials.json]

These credentials will be used by any library that requests Application Default Credentials (ADC).
/Users/$HOME/.bin/google-cloud-sdk/lib/third_party/google/auth/_default.py:69: UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. We recommend you rerun `gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see https://cloud.google.com/docs/authentication/
  warnings.warn(_CLOUD_SDK_CREDENTIALS_WARNING)

Quota project "<PROJECT_NAME>" was added to ADC which can be used by Google client libraries for billing and quota. Note that some services may still bill the project owning the resource.

然后,运行pulumi preview

看起来zone:现在已弃用,以下配置对我有用:

const cluster = new gcp.container.Cluster("cluster", {
    initialNodeCount: 1,

    loggingService: "logging.googleapis.com/kubernetes",
    monitoringService: "monitoring.googleapis.com/kubernetes",

    removeDefaultNodePool: true,

    enableLegacyAbac: false,
    enableBinaryAuthorization: true,

    addonsConfig: {
        horizontalPodAutoscaling: {
            disabled: false,
        },
        istioConfig: {
            disabled: false,
            auth: "AUTH_MUTUAL_TLS",
        },
        cloudrunConfig: {
            disabled: true
        }
    },
},  {
    customTimeouts: {
        create: "30m",
        update: "30m",
        delete: "30m"
    }
});

暂无
暂无

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

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