Propagate a deployment by Karmada

This guide will cover:

  • Install karmada control plane components in a Kubernetes cluster which is known as host cluster.
  • Join a member cluster to karmada control plane.
  • Propagate an application by using karmada.

Prerequisites

Install the Karmada control plane

1. Clone this repo to your machine:

  1. git clone https://github.com/karmada-io/karmada

2. Change to the karmada directory:

  1. cd karmada

3. Deploy and run Karmada control plane:

run the following script:

  1. # hack/local-up-karmada.sh

This script will do the following tasks for you:

  • Start a Kubernetes cluster to run the Karmada control plane, aka. the host cluster.
  • Build Karmada control plane components based on a current codebase.
  • Deploy Karmada control plane components on the host cluster.
  • Create member clusters and join Karmada.

If everything goes well, at the end of the script output, you will see similar messages as follows:

  1. Local Karmada is running.
  2. To start using your Karmada environment, run:
  3. export KUBECONFIG="$HOME/.kube/karmada.config"
  4. Please use 'kubectl config use-context karmada-host/karmada-apiserver' to switch the host and control plane cluster.
  5. To manage your member clusters, run:
  6. export KUBECONFIG="$HOME/.kube/members.config"
  7. Please use 'kubectl config use-context member1/member2/member3' to switch to the different member cluster.

There are two contexts in Karmada:

  • karmada-apiserver kubectl config use-context karmada-apiserver
  • karmada-host kubectl config use-context karmada-host

The karmada-apiserver is the main kubeconfig to be used when interacting with the Karmada control plane, while karmada-host is only used for debugging Karmada installation with the host cluster. You can check all clusters at any time by running: kubectl config view. To switch cluster contexts, run kubectl config use-context [CONTEXT_NAME]

Demo

Demo

Propagate application

In the following steps, we are going to propagate a deployment by Karmada.

1. Create nginx deployment in Karmada.

First, create a deployment named nginx:

  1. kubectl create -f samples/nginx/deployment.yaml

2. Create PropagationPolicy that will propagate nginx to member cluster

Then, we need to create a policy to propagate the deployment to our member cluster.

  1. kubectl create -f samples/nginx/propagationpolicy.yaml

3. Check the deployment status from Karmada

You can check deployment status from Karmada, don’t need to access member cluster:

  1. $ kubectl get deployment
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. nginx 2/2 2 2 20s