Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: locality loadbalance doc #101

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions content/en/docs/userguide/locality_loadbalance.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ kubectl label node ambient-worker3 topology.kubernetes.io/subzone=subzone3
```

2. start test servers
- create `sample` namespace
```
kubectl create namespace sample
```
- run a service
```
kubectl apply -n sample -f - <<EOF
Expand Down Expand Up @@ -262,7 +266,7 @@ EOF

- Test the access.
```
$ kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
kubectl exec -n sample "$(kubectl get pod -n sample -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
```
The output is from the helloworld-region.zone1.subzone1 that is currently co-located on the ambient-worker.
```
Expand All @@ -272,13 +276,11 @@ $ Hello version: region.zone1.subzone1, instance: helloworld-region.zone1.subzon

- Remove the service on the ambient-worker and test Failover.
```
kubectl get deployment
# list of name
kubectl delete deployment <name> # name of the pod on the ambient-worker
kubectl delete deployment -n sample helloworld-region.zone1.subzone1
```

```
kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
kubectl exec -n sample "$(kubectl get pod -n sample -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
```

The output is helloworld-region.zone1.subzone2, and a failover of the traffic has occurred.
Expand All @@ -288,12 +290,13 @@ $ Hello version: region.zone1.subzone2, instance: helloworld-region.zone1.subzon

- Relabel the locality of the ambient-worker3 same as the worker2 and test.
```
kubectl label node ambient-worker3 topology.kubernetes.io/region=region
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you remove this region label

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the region label has already been added in the beginning:

kubectl label node ambient-worker3 topology.kubernetes.io/region=region
kubectl label node ambient-worker3 topology.kubernetes.io/zone=zone2
kubectl label node ambient-worker3 topology.kubernetes.io/subzone=subzone3

Here we want to change the locality of ambient-worker3, so we only need to adjust the zone and subzone labels.

kubectl label node ambient-worker3 topology.kubernetes.io/zone=zone1
kubectl label node ambient-worker3 topology.kubernetes.io/subzone=subzone2
kubectl label node ambient-worker3 topology.kubernetes.io/zone=zone1 --overwrite
kubectl label node ambient-worker3 topology.kubernetes.io/subzone=subzone2 --overwrite
```
delete helloworld-region.zone2.subzone3 and re-apply the development pod as follows, then run test:
```
kubectl delete deployment -n sample helloworld-region.zone2.subzone3

kubectl apply -n sample -f - <<EOF
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -333,7 +336,7 @@ EOF

test multi times:
```
kubectl exec "$(kubectl get pod -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
kubectl exec -n sample "$(kubectl get pod -n sample -l app=sleep -o jsonpath='{.items[0].metadata.name}')" -c sleep -- curl -sSL "http://helloworld:5000/hello"
```

The output randomly shows helloworld-region.zone1.subzone2 and helloworld-region.zone1.subzone2-worker3.
Expand Down
Loading