Kubernetes on Genesis Cloud with Claudie!
By Jakub Hlavacka
22 July 2024
Intro
Claudie is a platform for managing multi-cloud and hybrid-cloud Kubernetes clusters. These Kubernetes clusters can mix and match nodepools from various cloud providers, e.g. a single cluster can have a nodepool in AWS, another in GCP and another one on-premises. In one of the recent releases 0.7.0, Claudie brings support for Genesis Cloud and its EU-hosted GPU instances. This article explains the process of setting up a Kubernetes cluster on Genesis.
Step 1 - Install Claudie
Claudie needs to be installed on an existing Kubernetes cluster, referred to as the Management Cluster, which is used to manage the clusters it provisions. For this tutorial, an ephemeral cluster like kind can be used for simplicity. This step assumes that you have kind installed locally.
For testing, you can use ephemeral clusters like Minikube or kind. However, for production environments, it is recommended to use a more resilient solution since Claudie maintains the state of the infrastructure it creates.
Create a kind cluster and export the kubeconfig
user@<your_host>:~# kind create cluster --name claudie-mgmt Creating cluster "claudie-mgmt" ... ✓ Ensuring node image (kindest/node:v1.27.3) 🖼 ✓ Preparing nodes 📦 ✓ Writing configuration 📜 ✓ Starting control-plane 🕹️ ✓ Installing CNI 🔌 ✓ Installing StorageClass 💾 Set kubectl context to "kind-claudie-mgmt" You can now use your cluster with: kubectl cluster-info --context kind-claudie-mgmt
user@<your_host>:~# kind get kubeconfig -n claudie-mgmt > ~/.kube/claudie user@<your_host>:~# export KUBECONFIG=~/.kube/claudie user@<your_host>:~# kubectl get nodes NAME STATUS ROLES AGE VERSION claudie-mgmt-control-plane Ready control-plane 3m8s v1.27.3
Install cert-manager as it is a requirement for the Claudie Management cluster.
user@<your_host>:~# kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.0/cert-manager.yaml
Deploy Claudie
user@<your_host>:~# kubectl apply -f https://github.com/berops/claudie/releases/download/v0.8.1/claudie.yaml
Wait for all Pods to get into Ready state
user@<your_host>:~# kubectl -n claudie get pods NAME READY STATUS RESTARTS AGE ansibler-858667d9d7-2r9z7 1/1 Running 0 2m17s builder-bd8d5f97b-89zpl 1/1 Running 0 2m17s claudie-operator-6bdcb4ddbf-ljhtd 1/1 Running 0 2m17s context-box-65484fbc88-w7xwk 1/1 Running 0 2m17s create-table-job-md8pm 0/1 Completed 1 2m17s dynamodb-6d65df988-98nkh 1/1 Running 0 2m17s kube-eleven-76b95985cb-rqtmj 1/1 Running 0 2m17s kuber-5dd64cd759-rqlkc 1/1 Running 0 2m17s make-bucket-job-jb6wg 0/1 Completed 0 2m17s minio-0 1/1 Running 0 2m17s minio-1 1/1 Running 0 2m17s minio-2 1/1 Running 0 2m17s minio-3 1/1 Running 0 2m17s mongodb-5574c9b7-hq8jh 1/1 Running 0 2m17s scheduler-8468dc885f-stqxn 1/1 Running 0 2m17s terraformer-7d75cf49fd-d4x4f 1/1 Running 0 2m17s
Step 2 - Create Genesis API Token
Login to your Genesis Cloud Console to generate a new API token. For more information, you can follow this guide on creating an API Token.
Create a Kubernetes Secret that will contain the genesis API Token.
user@<your_host>:~# kubectl create secret generic genesiscloud-secret --namespace=claudie --from-literal=apitoken='YOUR_API_TOKEN'
Step 3 - Create a Claudie manifest file
Now, let's create a Claudie manifest file that describes the Kubernetes cluster you want to create on Genesis. You can use the example manifest below as a starting point. Note that the example provided in this article will use CPU Instances. For a GPU example with Nvidia Operator installation, refer to this guide. You can use the example manifest below as a starting point.
Create the file:
user@<your_host>:~# nano inputmanifest.yml
Add your content:
apiVersion: claudie.io/v1beta1 kind: InputManifest metadata: name: kubernetes-genesis spec: providers: - name: genesiscloud providerType: genesiscloud secretRef: name: genesiscloud-secret namespace: claudie nodePools: dynamic: - name: control-gen providerSpec: name: genesiscloud region: ARC-IS-HAF-1 count: 1 serverType: vcpu-2_memory-4g_disk-80g image: "Ubuntu 22.04" - name: compute-gen providerSpec: name: genesiscloud region: ARC-IS-HAF-1 count: 3 serverType: vcpu-2_memory-4g_disk-80g image: "Ubuntu 22.04" storageDiskSize: 50 kubernetes: clusters: - name: gen-cluster version: v1.27.1 network: 172.16.2.0/24 pools: control: - control-gen compute: - compute-gen
The above manifest file is used for defining a Kubernetes cluster. Let's break down some of the key fields in it:
spec.providers
» Contains configurations for supported cloud providers. It is referencing access credentials that were previously created in a Secret object.spec.nodePools.dynamic
» Defines dynamic node pools. Those are the cloud provider's VMs that Claudie is expected to create.spec.kubernetes.clusters
» Describes the Kubernetes cluster that will be created.
The Provided example is relatively simple and deploys a Kubernetes cluster with one master node and three worker nodes. However, Claudie can be used for more advanced cluster scenarios, including deploying clusters across different cloud providers and on-premise in multi-cloud/hybrid architecture. Additionally, it's worth noting that the nodes will be connected using a WireGuard network, eliminating the need for a virtual network resource. For a more in-depth understanding of Claudie's inputmanifest
definition, visit the documentation site. To see what are the instance types available for Genesis Cloud API, visit the developers site.
Step 4 - Deploy the cluster
Save the example above to an inputmanifest.yml
file, and apply it to the kind cluster with the following command:
user@<your_host>:~# kubectl apply -f inputmanifest.yml
inputmanifest.claudie.io/kubernetes-genesis created
Now you can follow the cluster deployment status. When the cluster is deployed, the status will state DONE.
user@<your_host>:~# kubectl get inputmanifest
NAME STATUS
kubernetes-genesis IN_PROGRESS
user@<your_host>:~# kubectl get inputmanifest
NAME STATUS
kubernetes-genesis DONE
Step 5 - Access the cluster
The kubeconfig will be saved to a Secret object in the claudie
namespace.
user@<your_host>:~# kubectl get secrets -A
NAMESPACE NAME TYPE DATA AGE
cert-manager cert-manager-webhook-ca Opaque 3 103m
claudie claudie-webhook-certificate kubernetes.io/tls 3 100m
claudie dynamo-secret-td2bt2f272 Opaque 2 101m
claudie gene-cluster-<hash>-kubeconfig Opaque 1 12m
claudie gen-cluster-<hash>-metadata Opaque 1 12m
claudie minio-secret-5hd7htgm7m Opaque 2 101m
claudie mongo-secret-gfc6d84tcf Opaque 2 101m
claudie genesiscloud-secret Opaque 1 82m
user@<your_host>:~# kubectl get secrets -n claudie -l claudie.io/output=kubeconfig,claudie.io/cluster=gen-cluster -ojsonpath={.items[0].data.kubeconfig} | base64 -d
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <your_data>
server: https://<KUBE_API_ADDRESS>:6443
name: genesiscloud-cluster
contexts:
- context:
cluster: genesiscloud-cluster
user: kubernetes-admin
name: kubernetes-admin@genesiscloud-cluster
current-context: kubernetes-admin@genesiscloud-cluster
kind: Config
preferences: {}
users:
- name: kubernetes-admin
user:
client-certificate-data: <your_data>
client-key-data: <your_data>
Confirm that the cluster is up and running:
user@<your_host>:~# kubectl get secrets -n claudie -l claudie.io/output=kubeconfig,claudie.io/cluster=gen-cluster -ojsonpath={.items[0].data.kubeconfig} | base64 -d > ~/.kube/genesis
user@<your_host>:~# export KUBECONFIG=~/.kube/genesis
user@<your_host>:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
compute-genesiscloud-rtx1uhe-1 Ready <none> 19m v1.24.0
compute-genesiscloud-rtx1uhe-2 Ready <none> 19m v1.24.0
compute-genesiscloud-rtx1uhe-3 Ready <none> 19m v1.24.0
control-genesiscloud-ccdwax4-1 Ready <none> 20m v1.24.0
Conclusion
In this tutorial, we walked through the process of deploying a Kubernetes cluster on Genesis Cloud using Claudie. We began by setting up Claudie in a local kind cluster, created a Genesis API Token for authentication, and defined a Claudie manifest file. After applying the manifest, we successfully created a Kubernetes cluster on Genesis Cloud.