How to deploy CrateDB clusters with Kubernetes on Azure AKS

In this tutorial, we will illustrate step-by-step how to run CrateDB clusters with Kubernetes on Azure AKS using the CrateDB Kubernetes operator. The operator has been recently licensed under the Apache 2.0 license.

Installation

To get started, you will need the Azure CLI tools and an Azure subscription. Please check the Azure official documentation for the installation instructions. Then, log in to your account and switch to the subscription you want to use:

az login --use-device-code
az account set --name subscription_name

To monitor and analyze data from multiple resources, check that these providers are registered:

az provider show -n Microsoft.OperationsManagement -o table
az provider show -n Microsoft.OperationalInsights -o table

For deploying the Kubernetes cluster you will need two additional tools: Kubernetes command line tool, kubectl, and Kubernetes package manager helm. Please check kubectl and helm documentation for the installation instructions.

Finally, you will need the jq processor and the base64 decoder.

Deploying new Kubernetes cluster

As a first step, configure some details about your cluster:

export AKS_RESOURCE_GROUP_NAME="my-cratedb-group"
export AKS_REGION="WestEurope"
export K8S_CLUSTER_NAME="my-cratedb-k8s-cluster"

Next, create a new resource group:

az group create --name $AKS_RESOURCE_GROUP_NAME --location $AKS_REGION

To deploy a Kubernetes cluster with Azure Kubernetes Services (AKS) run the following:

az aks create -g $AKS_RESOURCE_GROUP_NAME -n $K8S_CLUSTER_NAME --enable-managed-identity --node-count 3 --generate-ssh-keys

This command created a new managed Kubernetes cluster consisting of three nodes.

Now, let’s configure your kubectl to connect to this cluster:

az aks get-credentials --resource-group $AKS_RESOURCE_GROUP_NAME --name $K8S_CLUSTER_NAME

To check the status of the nodes in the cluster run:

kubectl get nodes

If everything is running fine you can expect the output similar to the following:

NAME                                STATUS   ROLES   AGE   VERSION
aks-nodepool1-25785877-vmss000000   Ready    agent   91s   v1.23.12
aks-nodepool1-25785877-vmss000001   Ready    agent   90s   v1.23.12
aks-nodepool1-25785877-vmss000002   Ready    agent   91s   v1.23.12

Deploy a CrateDB cluster

Now it is time to deploy the CrateDB cluster. Create namespaces to keep things tidy by grouping resources:

kubectl create namespace crate-operator
kubectl create namespace crate

To install the CrateDB operator with Helm Chart, first, add crate-operator to the helm repository:

helm repo add crate-operator https://crate.github.io/crate-operator
helm repo update

Use the helm install command:

helm install crate-operator crate-operator/crate-operator --namespace crate-operator

The output should look like

NAME: crate-operator
LAST DEPLOYED: Thu Nov  3 13:31:14 2022
NAMESPACE: crate-operator
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing crate-operator.

Use an example similar to the one from the article Run CrateDB with Kubernetes Operator — CrateDB: Tutorials to create a dev-cluster.yaml file for a CrateDB resource specification:

kubectl --namespace crate create -f dev-cluster.yaml

To check if the resource has been created we can use this command:

kubectl get cratedbs -n crate

As an output of the above command, you should see the cluster name and CrateDB version installed.

NAME         CLUSTERNAME   VERSION   NODES   AGE   HEALTH
my-cluster   crate-dev     5.0.3             9s    

The pods will take a few moments to get initialized, you can check their status by running the following command:

kubectl get pods --namespace crate

Or from the Azure UI:

Access deployed cluster

Congratulations! Now that you have the running CrateDB cluster on Azure AKS, let’s get the IP address of the cluster:

kubectl get service crate-my-cluster -o json -n crate | jq -r '.status.loadBalancer.ingress[0].ip'

The operator creates a user named system for you to access the cluster. To get the password run:

kubectl get secret user-system-my-cluster -n crate -o json | jq -r '.data.password' | base64 -d

You can access the CrateDB Admin UI by using the IP address and port 4200:

From this point, you are ready to import and query data! If you like this tutorial and would like to learn more about CrateDB in general visit our docs and join our community.

1 Like