ssh ckad00023
You need two outcomes in moose:
At most 10 Pods total (across both Deployments).
About 20% of chipmunk-service traffic goes to canary-chipmunk-deployment.
In Kubernetes Services, traffic distribution is (roughly) proportional to the number of ready endpoints behind the Service. So the standard canary trick is:
1) Inspect what exists
kubectl -n moose get deploy
kubectl -n moose get svc chipmunk-service -o wide
kubectl -n moose describe svc chipmunk-service
Get the Service selector (important):
kubectl -n moose get svc chipmunk-service -o jsonpath='{.spec.selector}{"\n"}'
Check current replicas:
kubectl -n moose get deploy current-chipmunk-deployment -o jsonpath='{.spec.replicas}{"\n"}'
kubectl -n moose get deploy canary-chipmunk-deployment -o jsonpath='{.spec.replicas}{"\n"}'
List pods + labels (to confirm both Deployments’ pods match the Service selector):
kubectl -n moose get pods --show-labels
2) Ensure both Deployments are behind the Service
This is the key: the pods from BOTH deployments must match the Service selector.
If the Service selector is something like app=chipmunk, then both Deployments’ pod templates must include app: chipmunk.
If one Deployment doesn’t match, patch its pod template labels to match the selector.
2A) Example: selector is app=chipmunk
(Only do this if you see the Service selector contains app=chipmunk and one of the deployments is missing it.)
kubectl -n moose patch deploy current-chipmunk-deployment \
-p '{"spec":{"template":{"metadata":{"labels":{"app":"chipmunk"}}}}}'
kubectl -n moose patch deploy canary-chipmunk-deployment \
-p '{"spec":{"template":{"metadata":{"labels":{"app":"chipmunk"}}}}}'
Wait for rollouts if patches triggered new ReplicaSets:
kubectl -n moose rollout status deploy current-chipmunk-deployment
kubectl -n moose rollout status deploy canary-chipmunk-deployment
Verify endpoints now include pods from both deployments:
kubectl -n moose get endpoints chipmunk-service -o wide
3) Set replicas to enforce “max 10 pods” and “20% canary”
Set:
current = 8
canary = 2Total = 10.
kubectl -n moose scale deploy current-chipmunk-deployment --replicas=8
kubectl -n moose scale deploy canary-chipmunk-deployment --replicas=2
Wait until ready:
kubectl -n moose rollout status deploy current-chipmunk-deployment
kubectl -n moose rollout status deploy canary-chipmunk-deployment
Confirm total pods is 10 (or less) and all are Running/Ready:
kubectl -n moose get pods
kubectl -n moose get pods | tail -n +2 | wc -l
Confirm endpoints count matches 10:
kubectl -n moose get endpoints chipmunk-service -o jsonpath='{.subsets[*].addresses[*].ip}' | wc -w
4) Test load balancing via NodePort 30000
Run several times:
for i in $(seq 1 30); do curl -s http://localhost:30000/; echo; done
You should see canary responses appear roughly ~20% of the time (not exact every run).
If you want a clearer signal, check which pods are endpoints and ensure 2 belong to canary and 8 to current:
kubectl -n moose get pods -l app=chipmunk -o wide
kubectl -n moose get endpoints chipmunk-service -o wide