Local development environment
If you plan to contribute to Camel K, you will end up needing to run and troubleshoot your operator code locally. Here a guideline that will help you configure your local operator running.
Running operator locally
As soon as you build your operator locally you will ask yourself how to test it. The idea is that you execute it locally and instruct it to watch a namespace on a Kubernetes cluster (it may be remote or any local environment). Let’s use a namespace called operator-test
.
-
We start by setting the environment variable
WATCH_NAMESPACE
with the namespace you’d like your operator to watch.
export WATCH_NAMESPACE=operator-test
-
The next step is to install an
IntegrationPlatform
on the cluster namespace. You probably need to tweak the registry parameters in order to be able to authenticate against an image repository (see below paragraph for local repository instructions).
./kamel install --skip-operator-setup -n operator-test --registry my-registry:5000
-
Finally, assuming you’ve builded your application correctly we can run the operator:
./kamel operator
-
Test the local operator by creating a test
Integration
.
./kamel run xyz.abc -n operator-test
make sure no other Camel K Operators are watching that namespace, neither you have a global Camel K Operator installed on your cluster. |
Local operator and local cluster
If you want to run a local operator togheter with Minikube
you will need an additional step in order to let the local operator being able to push images in the local registry. We need to expose the local registry as described in this procedure:
-
Enable the addon registry (this should be already in place):
minikube addons enable registry
-
Get the
Pod
name that is in charge to run the registry and proxy the registry 5000 port to be used locally.
kubectl get pods -n kube-system NAME READY STATUS RESTARTS AGE ... registry-fttbv 1/1 Running 40 89d ... kubectl port-forward --namespace kube-system registry-fttbv 5000:5000
-
Update the
IntegrationPlatform
to instruct it to use thelocalhost
registry:
./kamel install --skip-operator-setup -n operator-test --registry localhost:5000 --force
A similar procedure may work if you use other local environments. The idea is to expose the docker registry and be able to use it from your local operator.
Local Camel K runtime
Camel K integrations are based on Camel K runtime, generally paired with the operator release. If you need to specify a different runtime, or you have a local Camel K runtime that you want to test, then you will need to specify it in the Integration Platform
:
./kamel install --skip-operator-setup -n operator-test --registry localhost:5000 --force --runtime-version 1.7.0-SNAPSHOT
With the above instructions, the operator will pick up and use the snapshot version you have released locally.