【问题标题】:Ballerina: build image and push to gcr.io via k8s pluginBallerina:构建镜像并通过 k8s 插件推送到 gcr.io
【发布时间】:2018-07-22 11:01:54
【问题描述】:

我正在使用一个简单的ballerina 代码来构建我的程序(简单的hello world),并带有ballerinax/kubernetes 注释。该服务正在成功编译,并可通过本地主机的特定绑定端口访问。

在配置 kubernetes 部署时,我指定了映像构建和推送标志:

@kubernetes:Deployment {
    replicas: 2,
    name: "hello-deployment",
    image: "gcr.io/<gct-project-name>/hello-ballerina:0.0.2",
    imagePullPolicy: "always",
    buildImage: true,
    push: true
}

构建源代码时:

ballerina build hello.bal

这就是我得到的:

Compiling source
    hello.bal

Generating executable
    ./target/hello.balx
    @docker          - complete 3/3

    Run following command to start docker container:
    docker run -d -p 9090:9090 gcr.io/<gcr-project-name>/hello-ballerina:0.0.2

    @kubernetes:Service              - complete 1/1
    @kubernetes:Deployment           - complete 1/1
error [k8s plugin]: Unable to push docker image: unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication

请注意,当在我的本地机器上通过 docker 手动推送它时,它可以找到并且新图像正在被推送。

我错过了什么?有没有办法通过 kubernetes 包告诉芭蕾舞演员有关 docker 注册表凭据的信息?

【问题讨论】:

    标签: docker kubernetes ballerina


    【解决方案1】:

    Ballerina 还不支持 gcloud docker registry,但它支持 dockerhub。 请参考sample6 了解更多信息。

    基本上,你可以将 docker registry 用户名和密码导出为环境变量。

    请在https://github.com/ballerinax/kubernetes/issues 创建问题以跟踪此问题。

    【讨论】:

      【解决方案2】:

      似乎是 Container Registry 的问题,您无法进行身份验证。

      要对 Container Registry 进行身份验证,请使用 gcloud 作为 Docker 凭据助手。为此,请运行以下命令:

      gcloud auth configure-docker

      您需要运行一次此命令才能对 Container Registry 进行身份验证。 我们强烈建议您尽可能使用此方法。它提供对项目资源的安全、短期访问。

      您可以自行查看Container Registry Authentication Methods的步骤

      【讨论】:

        猜你喜欢
        • 2020-04-06
        • 2020-02-16
        • 2020-10-28
        • 2019-02-12
        • 2019-02-28
        • 2021-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多