我有一个服务帐户,可以在Google Container Builder上触发构建.这工作正常,但现在我想使用该服务帐户检索构建日志.
这是获取日志的代码(使用google-auto-auth包获取令牌,这部分在其他地方运行良好,所以我真的不认为这是问题):
var url = logsBucket + '/log-' + buildId + '.txt';
debug('Requesting log at %s', url);
request
.get(url)
.set('Authorization', 'Bearer ' + token)
.end(function(err, res) {
if (err) return cb(err);
var log = res.body;
debug('Received build log : %o', log);
cb(null, log);
});
Run Code Online (Sandbox Code Playgroud)
目前,尽管服务帐户可以访问以下角色,但401 Unauthorized已失败:
这是错误:
{
"message": "Forbidden",
"stack": "Error: Forbidden\n at Request.callback (/app/node_modules/superagent/lib/node/index.js:696:15)\n [...]",
"status": 403,
"response": {
"req": {
"method": "GET",
"url": "https://storage.googleapis.com/{PROJECT_ID}.cloudbuild-logs.googleusercontent.com/log-42602b35-af02-4e75-8100-8a3bd0e720fb.txt",
"headers": …Run Code Online (Sandbox Code Playgroud) 我们正在将容器构建流程迁移到Google Container Builder.我们有使用Node或Scala的多个repo.
从实际的容器构建器功能来看,是否可以缓存两个构建之间的依赖关系(例如:node_modules,.ivy,...).每次下载所有内容真的是耗费时间(金钱).
我知道可以构建一个包含所有内容的自定义docker镜像,但我们更愿意避免使用此解决方案.
例如,我们是否可以为此目的安装持久卷,就像我们以前使用DroneIO一样?甚至更好地自动像Bitbucket Pipelines?
谢谢
我正在尝试指定一个构建请求,指定source为repoSource:
{
"source": {
"repoSource": {
"repoName": "myRepo",
"branchName": "master"
}
},
"steps": [
{
"name": "gcr.io/cloud-builders/docker",
"args": ["build", "-t", "gcr.io/$PROJECT_ID/zookeeper", "."]
}
],
"images": [
"gcr.io/$PROJECT_ID/zookeeper"
]
}
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用 gcloud 提交它时,出现错误:
$ gcloud container builds submit --no-source --config cloudbuild.json
ERROR: (gcloud.container.builds.submit) cloudbuild.json: config cannot specify source
Run Code Online (Sandbox Code Playgroud)
在“编写自定义构建请求”中,它说:
当您使用 gcloud 命令行工具提交构建请求时,如果您将源指定为命令行参数,则源字段可能不是必需的。您还可以在构建请求文件中指定源。有关更多信息,请参阅 gcloud 文档。
注意:构建资源文档中描述的 storageSource 和 repoSource 字段与 source 字段不同。storageSource 指示 Container Builder 在 Cloud Storage 存储桶中查找源文件,repoSource 指包含源文件的 Cloud Source Repository。
那么,如何使用 gcloud 指定 …
google-cloud-platform google-container-registry google-container-builder
语境
使用Container Builder构建并用于App Engine的Ruby on Rails应用程序。我们要求捆绑器能够使用SSH密钥从私有git存储库安装依赖项。
SSH密钥来自一个安全存储桶,它们通过KMS进行解密。这些步骤很好。但是,使用Docker构建容器的最后一步是无法访问SSH密钥。
我以前没有使用Docker的丰富经验,所以我认为这是一个简单的问题。
cloudbuild.yml
steps:
# Get and prepare Deploy Key
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'gs://[PROJECT-BUCKET]/git_id_rsa.enc', '/root/.ssh/git_id_rsa.enc']
volumes:
- name: 'ssh-setup'
path: /root/.ssh
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=/root/.ssh/git_id_rsa.enc
- --plaintext-file=/root/.ssh/git_id_rsa
- --location=global
- --keyring=[KEYRING]
- --key=[KEY]
volumes:
- name: 'ssh-setup'
path: /root/.ssh
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: /workspace/deploy/git-prepare.sh
volumes:
- name: 'ssh-setup'
path: /root/.ssh
# ... Omitted steps ...
# Docker build
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/[PROJECT-NAME]', '.'] …Run Code Online (Sandbox Code Playgroud) 我在 Google Cloud Container Builder 中设置了构建触发器,这些触发器设置为在特定分支上触发并使用 repo 中的 cloudbuild.yml 配置。在我将提交推送到这些分支中的任何一个的第一天,它触发了容器构建并成功完成。从那时起,触发器只是间歇性地工作。
有时 Google Cloud Container Builder 根本没有检测到提交(我已经检查过提交在 bitbucket 中并且提交在正确的分支上)。那时,我尝试通过谷歌控制台手动触发构建,但它使用上次构建的旧提交,而不是最新提交。那么我将尝试从 repo 中推送小的更改或进行空提交。
有时这会触发构建,有时不会。有趣的是,当构建在一段时间后最终在一个分支上触发时,如果其他分支最近有尚未构建的提交,它将触发构建。
我不知道如何解决这个问题。有没有人遇到过类似的问题?
更新:
我解决了我的问题。我最初将每个 bitbucket 存储库添加到 Google Cloud 中的源存储库。之后,我在 Container Registry 中为每个存储库添加了构建触发器。添加触发器时,我必须通过与添加源存储库相同的过程来连接到 Bitbucket 中的存储库。后来我意识到它在源存储库部分自动为每个存储库创建了一个单独的连接。所以我有两个连接到源存储库中列出的 bitbucket 中的每个存储库。一旦我删除了重复项,触发器就开始一致地工作。
总之,请确保源存储库中没有任何重复的连接。
我想通过 Java 客户端或 GCloud API 本身从其集群之一中获取当前的 GKE 项目 ID。
ClusterManagerClient用适当的初始化ClusterManagerSettings-> 是否可以使用此客户端获取此特定项目 ID?
(我希望每个 GKE 集群中都有一个全局上下文,我们可以在其中了解我们正在运行的当前项目)。
谢谢
google-api-java-client google-cloud-platform kubernetes google-kubernetes-engine google-container-builder
我在 GCE 上有一个 Kubernetes 部署,我希望根据在 Google Container Registry 中创建的新映像(最好通过构建触发器)自动更新。有没有办法做到这一点?
提前致谢。
-标记
kubernetes google-kubernetes-engine google-container-registry google-container-builder
我正在使用gcr.io/cloud-builders/bazel在 google 容器构建上构建我的图像。
从日志来看,似乎大部分时间都在为 bazel 设置工作区。这个工作区不会因构建而改变,所以我认为可以预先计算并存储在新图像中。
如何在 Google Cloud Platform 上加速这些 bazel 构建?
Already have image (with digest): gcr.io/cloud-builders/bazel
Extracting Bazel installation...
........................
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
Loading: 0 packages loaded
WARNING: /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/io_bazel_rules_go/go/def.bzl:137:3: DEPRECATED: com_github_golang_protobuf : new_go_repository is deprecated. Please migrate to go_repository soon.
WARNING: /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/io_bazel_rules_go/go/def.bzl:137:3: DEPRECATED: com_github_golang_glog : new_go_repository is deprecated. Please migrate to go_repository soon.
WARNING: /builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/io_bazel_rules_go/go/def.bzl:137:3: DEPRECATED: org_golang_google_grpc : new_go_repository is deprecated. …Run Code Online (Sandbox Code Playgroud) 我不明白此错误消息的含义。它发生在我的构建结束时,即构建完成并标记了图像时。这是日志的结尾:
Step 17/18 : WORKDIR /var/www
---> 0cb8de2acd8f
Removing intermediate container 7e7838eac6fb
Step 18/18 : CMD bundle exec puma -C config/puma.rb
---> Running in 9089eb79192b
---> 890a53af5964
Removing intermediate container 9089eb79192b
Successfully built 890a53af5964
Successfully tagged us.gcr.io/foo-staging/foobar:latest
ERROR
ERROR: failed to find one or more images after execution of build steps: ["us.gcr.io/foo-staging/foobar:a2122696c92f430529197dea8213c96b3eee8ee4"]
Run Code Online (Sandbox Code Playgroud)
这是我的cloudbuild.yaml:
steps:
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', 'us.gcr.io/$PROJECT_ID/foobar', '.' ]
images:
- 'us.gcr.io/$PROJECT_ID/foobar:$COMMIT_SHA'
- 'us.gcr.io/$PROJECT_ID/foobar:latest'
timeout: 3600s
Run Code Online (Sandbox Code Playgroud)
我以为这可能是暂时性故障,但我重试了构建,然后又发生了。
google-cloud-platform google-container-registry google-container-builder
我有一个deployment.yaml含有部署3个容器+ LB服务和cloudbuild.yaml含步骤建集装箱图像每一次有新的承诺一定的分支上到位桶混帐回购协议。
一切正常,除了每当有新映像版本(我在部署中使用 :latest 标记)时我的部署都不会更新这一事实,为了改变这一点,我明白我的部署映像应该使用一些独特的东西,而不是 :latest,例如作为 git commit SHA。
问题: 我不确定如何在 GCB CI 过程中执行图像声明更新以包含新的提交 SHA。
YAML 的:https : //paste.ee/p/CsETr
google-cloud-platform kubernetes google-kubernetes-engine google-container-registry google-container-builder