From f4d14086a01ad918885708fe3b45bfba4f830ecf Mon Sep 17 00:00:00 2001 From: Shivansh Bhatnagar Date: Sat, 25 May 2024 14:47:02 +0530 Subject: [PATCH 1/2] Modified the Resource Migration Documentaion Signed-off-by: Shivansh Bhatnagar --- docs/tutorials/resource-migration.md | 82 +++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/resource-migration.md b/docs/tutorials/resource-migration.md index 2a7a5cbd..52f5e251 100644 --- a/docs/tutorials/resource-migration.md +++ b/docs/tutorials/resource-migration.md @@ -232,4 +232,84 @@ nginx-svc NodePort 10.13.161.255 80:30000/TCP 54s app= ``` As you see, you shall find `nginx` application related resource are all propagated to `member2` cluster, -which means the higher priority `PropagationPolicy` does work. \ No newline at end of file +which means the higher priority `PropagationPolicy` does work. + +--- + +### Apply Higher Priority PropagationPolicy + +#### Step 5: Write the code + +Create a new file `/tmp/pp-for-nginx-app.yaml` and copy the text below into it: + +```yaml +apiVersion: policy.karmada.io/v1alpha1 +kind: PropagationPolicy +metadata: + name: nginx-pp +spec: + conflictResolution: Overwrite + placement: + clusterAffinity: + clusterNames: + - member1 + - member2 ## propagate to more clusters other than member1 + priority: 10 ## priority greater than above PropagationPolicy (10 > 0) + preemption: Always ## preemption should equal to Always + resourceSelectors: + - apiVersion: apps/v1 + kind: Deployment + name: nginx-deploy + - apiVersion: v1 + kind: Service + name: nginx-svc + schedulerName: default-scheduler +``` + +#### Step 6: Run the command + +Apply this higher priority `PropagationPolicy` to the Karmada control plane: + +```shell +kubectl --context karmada-apiserver apply -f /tmp/pp-for-nginx-app.yaml +propagationpolicy.policy.karmada.io/nginx-pp created +``` + +#### Step 7: Verification + +```shell +kubectl --context member1 get deploy -o wide +kubectl --context member1 get svc -o wide +kubectl --context member2 get deploy -o wide +kubectl --context member2 get svc -o wide +``` + +You should see the `nginx` application related resources originally in `member1` also propagated to `member2`, completing the migration of resources : + +- **member1**: + + ```shell + kubectl --context member1 get deploy -o wide + NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR + nginx-deploy 2/2 2 2 5m24s nginx nginx:latest app=nginx + + kubectl --context member1 get svc -o wide + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR + nginx-svc NodePort 10.13.161.255 80:30000/TCP 54s app=nginx + ``` + +- **member2**: + + ```shell + kubectl --context member2 get deploy -o wide + NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR + nginx-deploy 2/2 2 2 5m24s nginx nginx:latest app=nginx + + kubectl --context member2 get svc -o wide + NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR + nginx-svc NodePort 10.13.161.255 80:30000/TCP 54s app=nginx + ``` + +This confirms that the higher priority `PropagationPolicy` has effectively propagated the `nginx` application resources to both `member1` and `member2` clusters, meeting the desired propagation requirements. + +--- From c0e2471185d9667b1f7e8b5a62eb2e5efa2cb512 Mon Sep 17 00:00:00 2001 From: Shivansh Bhatnagar Date: Sat, 25 May 2024 14:49:11 +0530 Subject: [PATCH 2/2] Some minor changes Signed-off-by: Shivansh Bhatnagar --- docs/tutorials/resource-migration.md | 54 ---------------------------- 1 file changed, 54 deletions(-) diff --git a/docs/tutorials/resource-migration.md b/docs/tutorials/resource-migration.md index 52f5e251..fd87c38d 100644 --- a/docs/tutorials/resource-migration.md +++ b/docs/tutorials/resource-migration.md @@ -180,61 +180,7 @@ which means the existing resources in `member1` cluster has been taken over by K So far, you have finished the migration, isn't it so easy? -### Apply higher priority PropagationPolicy -#### Step 5: Write the code - -Create new file `/tmp/pp-for-nginx-app.yaml` and copy text below to it: - -```yaml -apiVersion: policy.karmada.io/v1alpha1 -kind: PropagationPolicy -metadata: - name: nginx-pp -spec: - conflictResolution: Overwrite - placement: - clusterAffinity: - clusterNames: - - member1 - - member2 ## propagate to more clusters other than member1 - priority: 10 ## priority greater than above PropagationPolicy (10 > 0) - preemption: Always ## preemption should equal to Always - resourceSelectors: - - apiVersion: apps/v1 - kind: Deployment - name: nginx-deploy - - apiVersion: v1 - kind: Service - name: nginx-svc - schedulerName: default-scheduler -``` - -#### Step 6: Run the command - -Apply this higher priority PropagationPolicy to Karmada control plane. - -```shell -$ kubectl --context karmada-apiserver apply -f /tmp/pp-for-nginx-app.yaml -propagationpolicy.policy.karmada.io/nginx-pp created -``` - -#### Step 7: Verification - -```shell -$ kubectl --context member2 get deploy -o wide -NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR -nginx-deploy 2/2 2 2 5m24s nginx nginx:latest app=nginx -$ kubectl --context member2 get svc -o wide -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR -nginx-svc NodePort 10.13.161.255 80:30000/TCP 54s app=nginx -... -``` - -As you see, you shall find `nginx` application related resource are all propagated to `member2` cluster, -which means the higher priority `PropagationPolicy` does work. - ---- ### Apply Higher Priority PropagationPolicy