-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integration test for cni-repair-controller
(Note this will fail until linkerd/linkerd2#11699 lands) The `integration-cni-plugin.yml` workflow (formerly known as `cni-plugin-integration.yml`) has been expanded to run the new recipe `cni-repair-controller-integration`, which performs the following steps: - Rebuilds the `linkerd-cni-repair-controller` crate and `cni-plugin` - Creates a new cluster at version `v1.27.6-k3s1` (version required for Calico to work) - Triggers a new `./cni-repair-controller/integration/run.sh` script which: - Installs Calico - Installs the latest linkerd-edge CLI - Installs `linkerd-cni` and wait for it to become ready - Install the linkerd control plane in CNI mode - Install a `pause` DaemonSet The `linkerd-cni` instance has been configured to include an extra initContainer that will delay its start for 15s. Since we waited for it to become ready, this doesn't affect the initial install. But then a new node is added to the cluster, and this delay allows for the new `pause` DaemonSet replica to start before the full CNI config is ready, so we can observe its failure to come up. Once the new `linkerd-cni` replica becomes ready we observe how the `pause` failed replica is replaced by a new healthy one.
- Loading branch information
Showing
7 changed files
with
131 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
rust-toolchain | ||
target/ |
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,11 @@ | ||
{ | ||
"name": "docker.io/rancher/k3s", | ||
"channels": { | ||
"stable": "v1.27.6-k3s1", | ||
"latest": "v1.27.6-k3s1", | ||
"v1.27": "v1.27.6-k3s1" | ||
}, | ||
"digests": { | ||
"v1.27.6-k3s1": "sha256:9486bbb9ca9b81c098ecd07f1c45441e143dab12577e22cf062586edcfd9d952" | ||
} | ||
} |
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,7 @@ | ||
# This config adds an extra initContainer that will make linkerd-cni to delay | ||
# its start for 15s, so to allow time for the pause DaemonSet to start before | ||
# the full CNI config is ready and enter a failure mode | ||
extraInitContainers: | ||
- name: sleep | ||
image: busybox | ||
command: ["/bin/sh", "-c", "sleep 15"] |
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,19 @@ | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: pause | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: pause-app | ||
template: | ||
metadata: | ||
annotations: | ||
linkerd.io/inject: enabled | ||
labels: | ||
app: pause-app | ||
spec: | ||
priorityClassName: system-node-critical | ||
containers: | ||
- name: pause-container | ||
image: k8s.gcr.io/pause |
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,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# shellcheck disable=SC2086 | ||
function step() { | ||
repeat=$(seq 1 ${#1}) | ||
printf "%0.s#" $repeat | ||
printf "#####\n# %s...\n" "$1" | ||
printf "%0.s#" $repeat | ||
printf "#####\n" | ||
} | ||
|
||
if [[ ! "$1" =~ (.*):(.*) ]]; then | ||
echo 'Usage: run.sh name:tag' | ||
exit 1 | ||
fi | ||
cni_plugin_image=${BASH_REMATCH[1]} | ||
cni_image_version=${BASH_REMATCH[2]} | ||
|
||
cd "${BASH_SOURCE[0]%/*}" | ||
|
||
step 'Installing Calico' | ||
kubectl apply -f https://k3d.io/v5.1.0/usage/advanced/calico.yaml | ||
kubectl --namespace=kube-system wait --for=condition=available --timeout=120s \ | ||
deploy/calico-kube-controllers | ||
|
||
step 'Installing latest linkerd edge' | ||
scurl https://run.linkerd.io/install-edge | sh | ||
export PATH=$PATH:$HOME/.linkerd2/bin | ||
linkerd install --crds | kubectl apply -f - | ||
# The linkerd-cni-config.yml config adds an extra initContainer that will make | ||
# linkerd-cni to delay its start for 15s, so to allow time for the pause | ||
# DaemonSet to start before the full CNI config is ready and enter a failure | ||
# mode | ||
linkerd install-cni \ | ||
--use-wait-flag \ | ||
--cni-image "$cni_plugin_image" \ | ||
--cni-image-version "$cni_image_version" \ | ||
--set repairController.enabled=true \ | ||
-f linkerd-cni-config.yml \ | ||
| kubectl apply -f - | ||
linkerd check --pre --linkerd-cni-enabled | ||
linkerd install --linkerd-cni-enabled | kubectl apply -f - | ||
linkerd check | ||
|
||
step 'Installing pause DaemonSet' | ||
kubectl apply -f pause-ds.yml | ||
kubectl wait --for=condition=ready --timeout=120s -l app=pause-app po | ||
|
||
step 'Adding a node' | ||
cluster=$(just-k3d --evaluate K3D_CLUSTER_NAME) | ||
image=$(just --evaluate cni-plugin-image) | ||
k3d node create node2 --cluster "$cluster" | ||
k3d image import --cluster "$cluster" "$image" | ||
|
||
step 'Checking new DS replica fails with code 95' | ||
sleep 10 | ||
kubectl wait \ | ||
--for=jsonpath='{.status.initContainerStatuses[0].lastState.terminated.exitCode}'=95 \ | ||
--field-selector=spec.nodeName=k3d-node2-0 \ | ||
pod | ||
|
||
step 'Checking new DS replica gets replaced' | ||
for _ in {1..5}; do | ||
if kubectl wait --for=condition=ready --timeout=10s -l app=pause-app po; then | ||
break | ||
fi | ||
done | ||
kubectl wait --for=condition=ready --timeout=10s -l app=pause-app po; |
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