-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Followup to #242 This adds a new integration test that verifies that pods don't get scheduled until all the networking has been setup, making sure having linkerd-cni run run first doesn't trigger scheduling. Note that for now we just consider the linkerd-cni+calico combo. Worklow: 1. Install calico and linkerd-cni. 2. Label node and then add node selectors to calico and linkerd-cni to run only on the current node. 3. Create a new node. Calico nor linkerd-cni will be triggered in it. 4. Persist an nginx pod in that node. Verify it doesn't get scheduled. 5. Add label to linkerd-cni to have it trigger in the new node. 6. Verify the nginx pod still isn't scheduled. 7. Add label to calico to have it trigger in the new node. 8. Verify the nginx pod is finally scheduled. Note that currently the test fails at step 6, but will pass as soon #242 gets merged. **Update**: now that #242 has been merged, the tests are green 👍
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
cd "${BASH_SOURCE[0]%/*}" | ||
|
||
NODE_NAME=l5d-server-extra | ||
|
||
kubectl config use-context "k3d-$K3D_CLUSTER_NAME" | ||
|
||
printf '\n# Install calico and linkerd-cni...\n' | ||
kubectl apply -f manifests/calico/calico-install.yaml | ||
kubectl apply -f manifests/calico/linkerd-cni.yaml | ||
|
||
printf '\n# Label node and then add node selectors to calico and linkerd-cni to run only on the current node...\n' | ||
kubectl label node "k3d-$K3D_CLUSTER_NAME-server-0" allow-calico=true | ||
kubectl label node "k3d-$K3D_CLUSTER_NAME-server-0" allow-linkerd-cni=true | ||
kubectl -n kube-system patch daemonsets calico-node --type=json \ | ||
-p='[{"op": "add", "path": "/spec/template/spec/nodeSelector", "value": {"allow-calico": "true"}}]' | ||
kubectl -n linkerd-cni patch daemonsets linkerd-cni --type=json \ | ||
-p='[{"op": "add", "path": "/spec/template/spec/nodeSelector", "value": {"allow-linkerd-cni": "true"}}]' | ||
kubectl rollout status daemonset -n kube-system | ||
kubectl rollout status daemonset -n linkerd-cni | ||
|
||
printf '\n# Create new node...\n' | ||
k3d node create "$NODE_NAME" -c "$K3D_CLUSTER_NAME" | ||
k3d image import test.l5d.io/linkerd/cni-plugin:test -c "$K3D_CLUSTER_NAME" | ||
|
||
printf '\n# Start pod; k8s should not schedule it just yet...\n' | ||
selector="{ | ||
\"spec\": { | ||
\"nodeSelector\": { | ||
\"kubernetes.io/hostname\": \"k3d-$NODE_NAME-0\" | ||
} | ||
} | ||
}" | ||
kubectl run nginx --image nginx --restart Never --overrides="$selector" | ||
sleep 10s | ||
status=$(kubectl get po nginx -ojson | jq -r .status.containerStatuses[0]) | ||
if [[ "$status" == "null" ]]; then | ||
echo "Pod not scheduled as expected" | ||
else | ||
echo "Unexpected pod container status: $status" | ||
exit 1 | ||
fi | ||
|
||
printf '\n# Trigger linkerd-cni; k8s should still not schedule the pod...\n' | ||
kubectl label node "k3d-$NODE_NAME-0" allow-linkerd-cni=true | ||
kubectl rollout status daemonset -n linkerd-cni | ||
sleep 10s | ||
status=$(kubectl get po nginx -ojson | jq -r .status.containerStatuses[0]) | ||
if [[ "$status" == "null" ]]; then | ||
echo "Pod not scheduled as expected" | ||
else | ||
echo "Unexpected pod container status: $status" | ||
exit 1 | ||
fi | ||
|
||
printf '\n# Trigger calico; k8s should now schedule the pod...\n' | ||
kubectl label node "k3d-$NODE_NAME-0" allow-calico=true | ||
kubectl rollout status daemonset -n kube-system | ||
sleep 10s | ||
status=$(kubectl get po nginx -ojson | jq -c .status.containerStatuses[0]) | ||
if [[ "$status" == "null" ]]; then | ||
echo "Pod not scheduled unexpectedly" | ||
exit1 | ||
elif [[ $(echo "$status" | jq .state.running) == "null" ]]; then | ||
echo "Unexpected pod container status: $status" | ||
exit 1 | ||
fi | ||
echo 'Pod scheduled as expected.' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters