Skip to content

Commit

Permalink
docs: Improve tutorial (#947)
Browse files Browse the repository at this point in the history
Co-authored-by: Britania Rodriguez Reyes <[email protected]>
  • Loading branch information
jamyct and britaniar authored Nov 8, 2024
1 parent d75bd45 commit 3cb2de9
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 3 deletions.
18 changes: 15 additions & 3 deletions docs/tutorials/MigrationWithOverrideDR.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions docs/tutorials/testfiles/crp-availability.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions docs/tutorials/testfiles/nginx-deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions docs/tutorials/testfiles/nginx-service.yaml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions docs/tutorials/testfiles/ro-1.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3cb2de9

Please sign in to comment.