docker - Ballerina:构建镜像并通过 k8s 插件推送到 gcr.io
问题描述
我正在使用一个简单的ballerina
代码来构建我的带有ballerinax/kubernetes
注释的程序(简单的 hello world)。该服务正在成功编译,并可通过本地主机的特定绑定端口访问。
在配置 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 注册表凭据的信息?
解决方案
Ballerina 还不支持 gcloud docker registry,但它支持 dockerhub。有关更多信息,请参阅示例 6 。
基本上,您可以将 docker 注册表用户名和密码导出为环境变量。
请在https://github.com/ballerinax/kubernetes/issues创建一个问题以跟踪此问题。
推荐阅读
- azure - 检查记录是否存在于 azure 逻辑应用程序内的 azure 表中
- nearprotocol - 使用未声明的类型或模块 near_blockchain
- python - Seaborn 不按顺序显示线图数据
- javascript - 复制粘贴文本区域行限制jquery
- python - 如何在树莓派操作系统上运行 python 程序
- reactjs - 在 GitHub 页面上部署的 Gatsby 站点中使用环境变量
- qml - 如何在 QML 2.0 TableView 中固定第一行?
- flutter - Flutter 中的响应式 MultiChildRenderObjectWidget
- android - 为 Recyclerview 自定义 GridLayoutManager 中的数据顺序
- forms - 如何在 Modal 中包含要呈现的自定义表单