<p>I have a <code>k8s_object</code> rule to apply a deployment to my Google Kubernetes Cluster. Here is my setup:</p>

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

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

<pre><code>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
</code></pre>

<p><strong>error: no objects passed to apply</strong>
It doesn't push the new image to the Google Container Registry.</p>

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

<p>Here is the full code if you need to take a closer look: <a href="https://github.com/flolude/cents-ideas/blob/069c773ade88dfa8aff492f024a1ade1f8ed282e/services/gateway/BUILD" rel="nofollow noreferrer">https://github.com/flolude/cents-ideas/blob/069c773ade88dfa8aff492f024a1ade1f8ed282e/services/gateway/BUILD</a></p>

<h1>Update</h1>

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

<pre><code>gcloud auth configure-docker
</code></pre>

<p>I get some warnings:</p>

<pre><code>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.
</code></pre>

<p>I had <code>google-cloud-sdk</code> installed via <code>snap install</code>. What I did to make it work is to remove <code>google-cloud-sdk</code> via</p>

<pre><code>snap remove google-cloud-sdk
</code></pre>

<p>and then followed <a href="https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu#before-you-begin" rel="nofollow noreferrer">those instructions</a> to install it via</p>

<pre><code>sudo apt install google-cloud-sdk
</code></pre>

<p>Now it works fine</p>
