Categories
Camel Cloud Golang Java

Camel K, Kind and a Local Registry

I was going to propose including this in the Camel K official documentation, but I am keeping it here for now now because it requires some hacks to work.

Up until now I have been using k3s for most of my development work, since it runs well on my NUC, but recently I switched to Kind (aka Kubernetes in Docker) by default. It’s much easier and faster for development and testing.

By default Kind does not come with a local registry but it is possible to use it with one. However, the proposed script does not seem to work well for Camel K and requires at least 2 changes (which is the primary reason I am not proposing this as a documentation yet).

The first step is to use this modified script to create your Kind cluster along with a local registry. If you are crazy enough to carelessly run scripts you find on the internet, you can do so at your own risk with:

curl https://gist.githubusercontent.com/orpiske/2a66ffd8be02b8b67f65e8d37c0f357d/raw/05b5f6c1adabc6fce32095623a8f8c5be7ff49ba/kind-with-local-registry.sh | bash

After running it, the output of your docker ps should look more or less like this:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0d42a78b4120 kindest/node:v1.20.2 "/usr/local/bin/entr…" 40 minutes ago Up 40 minutes 127.0.0.1:43881->6443/tcp kind-control-plane
dfa73eb254e1 registry:2 "/entrypoint.sh /etc…" 40 minutes ago Up 40 minutes 127.0.0.1:5000->5000/tcp kind-registry

Then, you have to push the openjdk11 base image and the camel-k operator image to your local registry.

Use this to clone the opendjk11 container image:

docker pull adoptopenjdk/openjdk11:slim && docker tag adoptopenjdk/openjdk11:slim localhost:5000/adoptopenjdk/openjdk11:slim && docker push localhost:5000/adoptopenjdk/openjdk11:slim

And then this, to clone the Camel K container image:

docker pull apache/camel-k:1.4.0 && docker tag apache/camel-k:1.4.0 localhost:5000/apache/camel-k:1.4.0 && docker push localhost:5000/apache/camel-k:1.4.0

With these images cloned, you can go ahead and install Camel K on the cluster. It doesn’t support OLM, so it will be installed on the default namespace. It also requires a few extra flags to point to the correct registry and base images we cloned.

kamel install --olm=false -n default --registry kind-registry:5000 --registry-insecure true --operator-image kind-registry:5000/apache/camel-k:1.4.0 --base-image kind-registry:5000/adoptopenjdk/openjdk11:slim --build-strategy routine --build-publish-strategy Spectrum

I haven’t tried with other build and build publish strategies, but Spectrum should be fine for testing/development.

By Otavio Piske

Just another nerd

Leave a Reply

Your email address will not be published. Required fields are marked *