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

Prerequisites

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.

  1. Download the release zip that contains the terraform files from github: karmada-on-oke.

  2. Use Oracle Resource Manager to create and apply the stack.

    1. Using the hamburger menu, go to Oracle Resource Manager.
    2. Choose Stacks.
    3. Select Create stack.
    4. Select My configuration.
    5. In the My configuration section, make sure Zip file is selected. Choose the zip file that you previously downloaded. Select Upload.
    6. Give the stack a meaningful name.
    7. Select Next.
    8. Choose the ssh public key that will be used to connect to VM.
    9. Choose the compartment where the resources will be created.
    10. Select Next.
    11. On the next screen select Run apply.
    12. Select Create.
  3. 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

  1. Using the IP previously obtained, use ssh to connect to the VM:
    ssh -i <private-ssh-key> opc@<public-IP>
    
  2. Switch to root user:

    sudo su -
    
  3. Install karmada components on host cluster:

    karmadactl init
    

Task 3: Join OKE Cluster Members

  1. Join cluster member1:

       karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config  join member1 --cluster-kubeconfig=$HOME/.kube/config-k1
    
  2. Join cluster member2:

       karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config  join member2 --cluster-kubeconfig=$HOME/.kube/config-k2
    
  3. Display member clusters:

    karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config  get clusters
    

Task 4: Deploy Workload on Karmada

  1. Set KUBECONFIG to point to the karmada-api server:

    export KUBECONFIG=/etc/karmada/karmada-apiserver.config
    
  2. 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
    
  3. Verify the deployment:

    karmadactl  get deployment --operation-scope all
    

    Output 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   Y
    

    Notice that out of the three pods, two are running on member2 and one on member1.

Task 5: Clean-Up

  1. Un-install karmada components from the host cluster:
karmadactl --kubeconfig /root/.kube/config deinit
  1. Destroy the resources created using the terraform stack:

Acknowledgments

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.