From 3cb2de98f6edb78ca5ec775df9d0be00a7735755 Mon Sep 17 00:00:00 2001 From: jamyct Date: Fri, 8 Nov 2024 14:17:39 +1100 Subject: [PATCH] docs: Improve tutorial (#947) Co-authored-by: Britania Rodriguez Reyes <145056127+britaniar@users.noreply.github.com> --- docs/tutorials/MigrationWithOverrideDR.md | 18 ++++++++++++--- .../tutorials/testfiles/crp-availability.yaml | 23 +++++++++++++++++++ .../tutorials/testfiles/nginx-deployment.yaml | 20 ++++++++++++++++ docs/tutorials/testfiles/nginx-service.yaml | 13 +++++++++++ docs/tutorials/testfiles/ro-1.yaml | 23 +++++++++++++++++++ 5 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 docs/tutorials/testfiles/crp-availability.yaml create mode 100644 docs/tutorials/testfiles/nginx-deployment.yaml create mode 100644 docs/tutorials/testfiles/nginx-service.yaml create mode 100644 docs/tutorials/testfiles/ro-1.yaml diff --git a/docs/tutorials/MigrationWithOverrideDR.md b/docs/tutorials/MigrationWithOverrideDR.md index e43fd9a5c..795351a87 100644 --- a/docs/tutorials/MigrationWithOverrideDR.md +++ b/docs/tutorials/MigrationWithOverrideDR.md @@ -15,6 +15,9 @@ Due to a sudden increase in traffic and resource demands in your WestUS clusters The following resources are currently deployed in the WestUS clusters: #### Service + +> Note: Service test file located [here](./testfiles/nginx-service.yaml). + ```yaml apiVersion: v1 kind: Service @@ -36,6 +39,9 @@ Summary: - It targets pods with the label app: nginx and forwards traffic to port 80 on the pods. #### Deployment + +> Note: Deployment test file located [here](./testfiles/nginx-deployment.yaml). + ```yaml apiVersion: apps/v1 kind: Deployment @@ -67,6 +73,9 @@ Summary: - The pods are labeled with `app: nginx` and expose port 80. #### ClusterResourcePlacement + +> Note: CRP Availability test file located [here](./testfiles/crp-availability.yaml) + ```yaml apiVersion: placement.kubernetes-fleet.io/v1 kind: ClusterResourcePlacement @@ -261,6 +270,9 @@ When the clusters in WestUS are nearing capacity limits and risk becoming overlo For this tutorial, we will move them to WestEurope. ## Create Resource Override + +> Note: Cluster resource override test file located [here](./testfiles/ro-1.yaml) + To scale up during migration, apply this override before updating crp: ```yaml apiVersion: placement.kubernetes-fleet.io/v1alpha1 @@ -318,13 +330,13 @@ spec: strategy: type: RollingUpdate ``` -Update the `crp.yaml` to reflect selecting clusters with higher node-count and apply it: +Update the [`crp-availability.yaml`](./testfiles/crp-availability.yaml) to reflect selecting clusters with higher node-count and apply it: ```bash -kubectl apply -f crp.yaml +kubectl apply -f crp-availability.yaml ``` ### Results -After applying the updated `crp.yaml`, the Fleet will schedule the application on the available clusters in WestEurope as they each have 3 nodes. +After applying the updated [`crp-availability.yaml`](./testfiles/crp-availability.yaml), the Fleet will schedule the application on the available clusters in WestEurope as they each have 3 nodes. You can check the status of the CRP to ensure that the application has been successfully migrated and is running in the new region: ```bash kubectl get crp crp-availability -o yaml diff --git a/docs/tutorials/testfiles/crp-availability.yaml b/docs/tutorials/testfiles/crp-availability.yaml new file mode 100644 index 000000000..a71815420 --- /dev/null +++ b/docs/tutorials/testfiles/crp-availability.yaml @@ -0,0 +1,23 @@ +apiVersion: placement.kubernetes-fleet.io/v1 +kind: ClusterResourcePlacement +metadata: + name: crp-availability +spec: + policy: + affinity: + clusterAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + clusterSelectorTerms: + - labelSelector: + matchLabels: + fleet.azure.com/location: westus + numberOfClusters: 2 + placementType: PickN + resourceSelectors: + - group: "" + kind: Namespace + name: test-app + version: v1 + revisionHistoryLimit: 10 + strategy: + type: RollingUpdate diff --git a/docs/tutorials/testfiles/nginx-deployment.yaml b/docs/tutorials/testfiles/nginx-deployment.yaml new file mode 100644 index 000000000..bf649c196 --- /dev/null +++ b/docs/tutorials/testfiles/nginx-deployment.yaml @@ -0,0 +1,20 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + namespace: test-app +spec: + selector: + matchLabels: + app: nginx + replicas: 2 + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.16.1 + ports: + - containerPort: 80 diff --git a/docs/tutorials/testfiles/nginx-service.yaml b/docs/tutorials/testfiles/nginx-service.yaml new file mode 100644 index 000000000..88503e2f8 --- /dev/null +++ b/docs/tutorials/testfiles/nginx-service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: nginx-service + namespace: test-app +spec: + selector: + app: nginx + ports: + - protocol: TCP + port: 80 + targetPort: 80 + type: LoadBalancer diff --git a/docs/tutorials/testfiles/ro-1.yaml b/docs/tutorials/testfiles/ro-1.yaml new file mode 100644 index 000000000..8cd4a2e2c --- /dev/null +++ b/docs/tutorials/testfiles/ro-1.yaml @@ -0,0 +1,23 @@ +apiVersion: placement.kubernetes-fleet.io/v1alpha1 +kind: ResourceOverride +metadata: + name: ro-1 + namespace: test-app +spec: + resourceSelectors: + - group: apps + kind: Deployment + version: v1 + name: nginx-deployment + policy: + overrideRules: + - clusterSelector: + clusterSelectorTerms: + - labelSelector: + matchLabels: + fleet.azure.com/location: westeurope + jsonPatchOverrides: + - op: replace + path: /spec/replicas + value: + 4