Apache Camel K on AKS quick setup

_hs_

HS

Posted on January 5, 2020

Apache Camel K on AKS quick setup

Update

RC2 was out recently but it appears that it has a bug with Azure Container Registry; it wont work with that registry that is. If you log deployment for camel operator it would look something like this:

{"level":"error","ts":1585456685.5099766,"logger":"controller-runtime.controller","msg":"Reconciler error","controller":"integrationkit-controller","request":"default/kit-bq02c4nu9gqrpld3bo70","error":"error during trait customization: unsupported secret type for registry authentication","errorVerbose":"unsupported secret type for registry authentication\ngithub.com/apache/camel-k/pkg/trait.getRegistrySecretFor\n\tgithub.com/apache/camel-k@/pkg/trait/builder.go:404\ngithub.com/apache/camel-k/pkg/trait.(*builderTrait)
Enter fullscreen mode Exit fullscreen mode

Use RC1 at least for Windows if you need to work with ACR.

Intro

Recently I wanted to develop microservice/API/whatever with nice and easy way of integrating other clients to the system (a system in development phase). I needed quick and easy way like writing JS functions in one file for each tiny task then somehow connecting them. It may sound like an ugly solution but it's actually way more effective than one might thing. Setting up scripts, networks, discoveries etc. by using Azure functions requires more time and maintenance than writing a simple script that can talk to its sibling components in Kubernetes cluster which is where Camel K kick in.

Setup AKS

I'm not going to focus much on AKS installation but rather configuring it for Camel K.

  1. First step, of course, would be having AKS running on Azure. I'm not going to post details on how to set it up but if you want to follow the tutorial just got to Azure portal and create one AKS by click the Add Resource and then choosing the icon like this one AKS marketplace icon
    Or have this link to the docs. Hope it stays the same so I don't have to edit.

  2. Next, make sure you connect kubectl to Azure Cloud Shell by running the cloud shell, like finding this icon Cloud shell in the top right corner and by clicking it, something like this Cloud Shell on Azure web portal pops up at the bottom of your screen.

  3. Input command

    az aks get-credentials --resource-group YOUR_RESOURCE_GROUP --name YOUR_AKS_NAME
    


    but remember to replace YOUR_RESOURCE_GROUP AND YOUR_AKS_NAME with the resource group name in which your new AKS is created , and AKS resource name respectively.

  4. Verify kubectl by running something like

    kubectl get nodes
    


    If it returns nodes (usually 3 if default setup) you're good to go.

  5. You must set up a registry. At the moment of writing Azure does not do this for you and probably wont ever as they have Azure Container Registry which you pay by the hour or day. For free ones I recommend doing a bit research but also this link should be helpful. One example is to create ACR (Azure container registry). For now I'll stick to Azure one, so after creating it you can use

    az aks update -n YOUR_AKS_NAME -g YOUR_AKS_RESOURCE_GROUP_NAME --attach-acr YOUR_ACR_NAME
    

This should update the existing AKS to use new Azure Container Registry. If you want you can build AKS from start to use ACR. Here's the link. I'm too lazy to research how can you do it via portal as I already had AKS and just wanted registry.

Adding Apache Camel K

This post focuses on having 'just enough' to get started. Therefor I put my Camel K client into server just to have it up and running.

  1. Go to: https://github.com/apache/camel-k/releases
  2. Go to section assets:
    Camel K packages example

  3. Copy link to latest Camel-K for Linux 64. At the time of writing AKS supports only Linux which is probably what most of you anyways want.

  4. wget should be installed already for your AKS as it runs Linux based OS and at the moment of writing contains wget by default, so

    wget https://github.com/apache/camel-k/releases/download/1.0.0-RC1/camel-k-client-1.0.0-RC1-linux-64bit.tar.gz
    


    should work. This should work for PS also so you don't have to switch to bash if you prefer PS.

  5. Extract the files. If you do ls you'll see the clouddrive directory there and I'm gonna use it for now. Use something like

    tar -C clouddrive/camelk -xzf camel-k-client-1.0.0-RC1-linux-64bit.tar.gz
    


    Now it might give you problem if you try

    cd clouddrive
    


    in PS. bash would work so don't be surprised by it. Just switch to the directory somehow (cd /usr/csuser/clouddrive should work in PS as it appears it's a symlink problem).
    NOTE: As these are just test cases remove Camel K files as soon as your done with this.

  6. Install Apache Camel K by following this link.
    If your lazy then just make sure you have image registry and fire up

    ./kamel install --registry YOUR_REGISTRY_DOMAIN.com --registry-auth-username YOUR_USERNAME --registry-auth-password SECRET_PASSWORD
    


    from the place where you extracted content of previous tar.
    If you had AKS with ACR or followed this tutorial you will have those credentials in Azure portal under Access keys in ACR resource.
    ACR image registry resource Access Key page

Verify

Hopefully this should work. Quick test would be running ./kamel get and get an empty list with headers NAME PHASE KIT. This means Camel K is connected to AKS.

Local Camel K

If you have Docker on your local machine or if you had minikube + kubectl installed you could configure it to use remote server. Usually you should go to home directory under .kube/config and have something like this

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: *
    server: https://kameldns-something-something.hcp.northeurope.azmk8s.io:443
  name: camel
contexts:
- context:
    cluster: camel
    user: clusterUser_Integrations_camel
  name: camel
current-context: camel
kind: Config
preferences: {}
users:
- name: clusterUser_Integrations_camel
  user:
    client-certificate-data: *
    client-key-data: *
    token: *

Enter fullscreen mode Exit fullscreen mode

Now don't forget to create a backup of your current config or merge this code with your local cluster. Basically

And now your kamel.exe or kamel.sh or whichever should be working with remote server. Another way is to install all the things in VS Code like extensions: Apache Camel K integrations, Azure Kubernetes Service, Kubernetes ... and Azure CLI (this one is not VS Code plugin) which provides login to Azure and makes VS Code extensions work directy with your account after you log in with az login.

I really hope this is useful to someone :D.

Have fun!

Links

  1. https://camel.apache.org/camel-k/latest/
  2. https://github.com/apache/camel-k/releases
  3. https://docs.microsoft.com/en-gb/azure/aks/kubernetes-walkthrough-portal
  4. https://johanbostrom.se/blog/list-of-free-private-docker-registry-and-repository
💖 💪 🙅 🚩
_hs_
HS

Posted on January 5, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Apache Camel K on AKS quick setup
camelk Apache Camel K on AKS quick setup

January 5, 2020