-
Notifications
You must be signed in to change notification settings - Fork 30
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
Integration test for cni-repair-controller #316
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on the nitpicky side, the CNI plugin runs alpine, can we re-use the same image so we don't pull busybox in tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thinking 👍 |
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this change accidental? Or do we need the target dir in the context when building an image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. This was a leftover from an iteration where the binary wasn't build inside the same Dockerfile.