1

I have a k8s_object rule to apply a deployment to my Google Kubernetes Cluster. Here is my setup:

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"
  },
)

But when I run bazel run //services/gateway:k8s_deployment.apply, I get the following error

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

error: no objects passed to apply It doesn't push the new image to the Google Container Registry.

Strangely, this worked a few days ago. But I didn't change anything.

Here is the full code if you need to take a closer look: https://github.com/flolude/cents-ideas/blob/069c773ade88dfa8aff492f024a1ade1f8ed282e/services/gateway/BUILD

Update

I don't know if this has something to do with this issue but when I run

gcloud auth configure-docker

I get some warnings:

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.
Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137
  • Have you tried deploying it under different name? or moving it from `cents-ideas`? I know it's weird ... but maybe it will work. – Crou Feb 12 '20 at 16:08
  • still the same error – Florian Ludewig Feb 12 '20 at 16:12
  • I've updated my question.... is this causing the issues? – Florian Ludewig Feb 12 '20 at 16:15
  • Try checking this [`docker-credential-gcloud` not in system PATH](https://stackoverflow.com/questions/49780218/docker-credential-gcloud-not-in-system-path) – Crou Feb 12 '20 at 16:17
  • Yeah, I've tried this. But when I run `gcloud components install docker-credential-gcr` I get this error: `ERROR: (gcloud.components.install) You cannot perform this action because this Cloud SDK installation is managed by an external package manager. Please consider using a separate installation of the Cloud SDK created through the default mechanism described at: https://cloud.google.com/sdk/ ` – Florian Ludewig Feb 12 '20 at 16:18
  • 1
    Consider updating the SDK, latest is 280.0.0 [docs](https://cloud.google.com/sdk/docs) – Crou Feb 12 '20 at 16:24
  • Nice it worked (not exactly as described in the docs, but thank you!) – Florian Ludewig Feb 12 '20 at 16:33

1 Answers1

1

I had google-cloud-sdk installed via snap install. What I did to make it work is to remove google-cloud-sdk via

snap remove google-cloud-sdk

and then followed those instructions to install it via

sudo apt install google-cloud-sdk

Now it works fine

Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137