Manage Workload on Multiple OKE Clusters Using Karmada
Introduction
Karmada (short for Kubernetes Armada) is a management platform that allows you to run cloud-native applications seamlessly across multiple Kubernetes clusters and cloud environments without requiring any changes to your applications. By leveraging Kubernetes-native APIs and advanced scheduling features, Karmada delivers an open and truly multi-cloud Kubernetes experience.
Designed for multi-cloud and hybrid cloud use cases, Karmada provides turnkey automation for managing applications across clusters. Its core capabilities include centralized management, high availability, automated failure recovery, and intelligent traffic scheduling.
Objectives
-
Install
karmadacomponents on a host OKE cluster. -
Join 2 OKE member clusters to karmada.
-
Create deployment with pods spread accross 2 OKE clusters.
Prerequisites
-
Active tenancy on OCI
-
A user with sufficient privileges to create the resources
Note: You can only use workload identity for enhanced clusters.
-
A compartment already created in which to deploy resources
-
Dynamic group for all VMs in the compartment:
All {instance.compartment.id = 'ocid1.compartment.oc1...'} -
Policy to run OCI CLI commands using instance principal:
allow dynamic-group <dynamic-group-name> to manage cluster-family in compartment <compartment-name>
Task 1: Create Necessary Resources for the Demo
Note: The following steps show how to deploy 3 OKE clusters and 1 VM that will be used during the demo.
-
Download the release zip that contains the terraform files from github: karmada-on-oke.
-
Use Oracle Resource Manager to create and apply the stack.
- Using the hamburger menu, go to Oracle Resource Manager.
- Choose
Stacks. - Select
Create stack. - Select
My configuration. - In the
My configurationsection, make sureZip fileis selected. Choose the zip file that you previously downloaded. SelectUpload. - Give the stack a meaningful name.
- Select
Next. - Choose the ssh public key that will be used to connect to VM.
- Choose the compartment where the resources will be created.
- Select
Next. - On the next screen select
Run apply. - Select
Create.
-
Get the public IP of the VM.
Upon a successful run of the job from the previous step, the last line in the log should include the public IP of the VM. Record it for later use.
Task 2: Install Karmada on Host Cluster
- Using the IP previously obtained, use ssh to connect to the VM:
ssh -i <private-ssh-key> opc@<public-IP> -
Switch to root user:
sudo su - -
Install karmada components on host cluster:
karmadactl init
Task 3: Join OKE Cluster Members
-
Join cluster
member1:karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config join member1 --cluster-kubeconfig=$HOME/.kube/config-k1 -
Join cluster
member2:karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config join member2 --cluster-kubeconfig=$HOME/.kube/config-k2 -
Display member clusters:
karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config get clusters
Task 4: Deploy Workload on Karmada
-
Set
KUBECONFIGto point to the karmada-api server:export KUBECONFIG=/etc/karmada/karmada-apiserver.config -
Create the deployment and the corresponding propagation policy:
kubectl apply -f https://raw.githubusercontent.com/oracle-devrel/oci-automation-hub/refs/heads/main/karmada-on-oke-sample/deployment.yaml kubectl apply -f https://raw.githubusercontent.com/oracle-devrel/oci-automation-hub/refs/heads/main/karmada-on-oke-sample/propagationpolicy.yaml -
Verify the deployment:
karmadactl get deployment --operation-scope allOutput should be similar to:
# karmadactl get deployment --operation-scope all NAME CLUSTER READY UP-TO-DATE AVAILABLE AGE ADOPTION nginx Karmada 3/3 3 3 22m - nginx member2 2/2 2 2 22m Y nginx member1 1/1 1 1 22m YNotice that out of the three pods, two are running on
member2and one onmember1.
Task 5: Clean-Up
- Un-install karmada components from the host cluster:
karmadactl --kubeconfig /root/.kube/config deinit
- Destroy the resources created using the terraform stack:
- Navigate back to Oracle Resource Manager.
- Select the stack you created.
- Select
Destroy.
Acknowledgments
- Author - Daniel Dinu (Principal Cloud Engineer)
More Learning Resources
Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.
For product documentation, visit Oracle Help Center.
Manage Workload on Multiple OKE Clusters Using Karmada
G43223-01