Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

How to resolve locally built images? #685

Open
nickdecooman opened this issue Feb 17, 2022 · 2 comments
Open

How to resolve locally built images? #685

nickdecooman opened this issue Feb 17, 2022 · 2 comments

Comments

@nickdecooman
Copy link

nickdecooman commented Feb 17, 2022

For local development, I am using Docker inside a Minikube cluster. I would like to build the image and then apply it to the cluster directly without the image being published to some remote registry.

Unfortunately, when not providing a registry in the image name, k8s_object seems to fall back to index.docker.io.

Example
Assume a Docker target (:image) that builds an image with the following name: bazel/services/api:image

BUILD.bazel:

rust_image(
      name ="image",
      ....
)

k8s_object(
    name = "k8s",
    template = ":k8s.yaml",
    context = "minikube",
    images = {
        "bazel/services/api:image": ":image"
    },
)

k8s.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api-deployment
  labels:
    app: api
spec:
  selector:
    matchLabels:
      app: api
  replicas: 1
  template:
    metadata:
      labels:
        app: api
    spec:
      containers:
        - name: api
          image: bazel/services/api:image
          imagePullPolicy: Never

Now, when running bazel run //services/api:k8s.resolve -- --no_push=true, the image is resolved to index.docker.io/bazel/services/api@sha256:3ebdf5964644a7aba0b4cde6baa5fd1c822ee61f784ca2c3b6cc5cf29bd72270

How can I disable the fallback to index.docker.io so that the image name resolves to bazel/services/api@sha256:3ebdf5964644a7aba0b4cde6baa5fd1c822ee61f784ca2c3b6cc5cf29bd72270?

Setting image_chroot with an empty string does not work.

Thanks!

@jmileson
Copy link

I got local images working by doing the following:

  • setup a local registry with this guide
  • port-forward to the registry with kubectl -n kube-system port-forward svc/registry 5000:80 &.
  • set image_chroot set to localhost:5000/<some path>

@loeffel-io
Copy link

🙈

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants