Bazel Kubernetes Object Error: no objects passed to apply (Google Container Registry)

Bazel Kubernetes Object Error: no objects passed to apply (Google Container Registry)

我有一个 k8s_object 规则来将部署应用到我的 Google Kubernetes 集群。这是我的设置:

load("@io_bazel_rules_docker//nodejs:image.bzl", "nodejs_image")
nodejs_image(
    name = "image",
    data = [":lib", "//:package.json"],
    entry_point = ":index.ts",
)

load("@io_bazel_rules_k8s//k8s:object.bzl", "k8s_object")
k8s_object(
  name = "k8s_deployment",
  template = ":gateway.deployment.yaml",
  kind = "deployment",
  cluster = "gke_cents-ideas_europe-west3-b_cents-ideas",
  images = {
    "gcr.io/cents-ideas/gateway:latest": ":image"
  },
)

但是当我运行bazel run //services/gateway:k8s_deployment.apply时,我得到以下错误

INFO: Analyzed target //services/gateway:k8s_deployment.apply (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //services/gateway:k8s_deployment.apply up-to-date:
  bazel-bin/services/gateway/k8s_deployment.apply
INFO: Elapsed time: 0.113s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
$ /snap/bin/kubectl --kubeconfig= --cluster=gke_cents-ideas_europe-west3-b_cents-ideas --context= --user= apply -f -
2020/02/12 14:52:44 Unable to publish images: unable to publish image gcr.io/cents-ideas/gateway:latest
error: no objects passed to apply

错误:没有传递给应用的对象 它不会将新图像推送到 Google Container Registry。

奇怪的是,这在几天前就奏效了。但是我什么都没改。

如果您需要仔细查看,这里是完整代码:https://github.com/flolude/cents-ideas/blob/069c773ade88dfa8aff492f024a1ade1f8ed282e/services/gateway/BUILD

更新

我不知道这是否与此问题有关,但是当我 运行

gcloud auth configure-docker

我收到一些警告:

WARNING: `docker-credential-gcloud` not in system PATH.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
WARNING: Your config file at [/home/flolu/.docker/config.json] contains these credential helper entries:

{
  "credHelpers": {
    "asia.gcr.io": "gcloud", 
    "staging-k8s.gcr.io": "gcloud", 
    "us.gcr.io": "gcloud", 
    "gcr.io": "gcloud", 
    "marketplace.gcr.io": "gcloud", 
    "eu.gcr.io": "gcloud"
  }
}
Adding credentials for all GCR repositories.
WARNING: A long list of credential helpers may cause delays running 'docker build'. We recommend passing the registry name to configure only the registry you are using.
gcloud credential helpers already registered correctly.

我通过 snap install 安装了 google-cloud-sdk。我所做的就是通过

删除 google-cloud-sdk
snap remove google-cloud-sdk

然后按照those instructions通过

安装它
sudo apt install google-cloud-sdk

现在可以正常使用了