|
| 1 | +version: '3' |
| 2 | + |
| 3 | +vars: |
| 4 | + TMP_DIR: |
| 5 | + sh: echo "${TMPDIR:-/tmp}" |
| 6 | + |
| 7 | +tasks: |
| 8 | + bootstrap: |
| 9 | + desc: "Bootstrap the multi-cluster dev environment (nso-standard and nso-infra) for local testing" |
| 10 | + cmds: |
| 11 | + - echo "🚀 Bootstrapping dev environment..." |
| 12 | + - task: create-clusters |
| 13 | + - task: prep-upstream |
| 14 | + - task: prep-downstream |
| 15 | + - task: link-clusters |
| 16 | + - echo "🎉 Dev environment bootstrapped successfully! Context is now kind-nso-standard." |
| 17 | + |
| 18 | + create-clusters: |
| 19 | + desc: "Create Kind upstream (standard) and downstream (infra) clusters" |
| 20 | + cmds: |
| 21 | + - echo "🧹 Cleaning up any existing clusters..." |
| 22 | + - kind delete cluster --name nso-standard || true |
| 23 | + - kind delete cluster --name nso-infra || true |
| 24 | + - echo "🏗️ Creating upstream (nso-standard) cluster..." |
| 25 | + - make kind-standard-cluster |
| 26 | + - echo "🏗️ Creating downstream (nso-infra) cluster..." |
| 27 | + - make kind-infra-cluster |
| 28 | + |
| 29 | + prep-upstream: |
| 30 | + desc: "Prepare the upstream cluster with Operator and cert-manager" |
| 31 | + cmds: |
| 32 | + - echo "🔧 Preparing upstream (nso-standard)..." |
| 33 | + - kubectl config use-context kind-nso-standard |
| 34 | + - make prepare-e2e |
| 35 | + |
| 36 | + prep-downstream: |
| 37 | + desc: "Prepare the downstream cluster with cert-manager, envoy-gateway, and external-dns" |
| 38 | + cmds: |
| 39 | + - echo "🔧 Preparing downstream (nso-infra)..." |
| 40 | + - kubectl config use-context kind-nso-infra |
| 41 | + - make prepare-infra-cluster |
| 42 | + |
| 43 | + link-clusters: |
| 44 | + desc: "Link upstream and downstream clusters using kubeconfig secret" |
| 45 | + cmds: |
| 46 | + - echo "🔗 Linking clusters..." |
| 47 | + - kind get kubeconfig --name nso-infra --internal > {{.TMP_DIR}}/.kind-nso-infra-internal.yaml |
| 48 | + - kubectl config use-context kind-nso-standard |
| 49 | + - | |
| 50 | + kubectl create namespace network-services-operator-system --dry-run=client -o yaml | kubectl apply -f - |
| 51 | + kubectl create secret -n network-services-operator-system \ |
| 52 | + generic downstream-cluster-kubeconfig \ |
| 53 | + --save-config \ |
| 54 | + --dry-run=client -o yaml \ |
| 55 | + --from-file=kubeconfig={{.TMP_DIR}}/.kind-nso-infra-internal.yaml | kubectl apply -f - |
| 56 | + - echo "⏳ Waiting for operator controller manager deployment to be ready..." |
| 57 | + - | |
| 58 | + kubectl -n network-services-operator-system \ |
| 59 | + wait deploy network-services-operator-controller-manager \ |
| 60 | + --for=condition=Available \ |
| 61 | + --timeout=180s |
| 62 | +
|
| 63 | + redeploy-operator: |
| 64 | + desc: "Rebuild the operator image, load it into nso-standard, and roll out the deployed controller" |
| 65 | + cmds: |
| 66 | + - echo "🔨 Building operator image and loading it into nso-standard..." |
| 67 | + # docker-build + kind load docker-image $(IMG) -n nso-standard |
| 68 | + - make load-image-operator |
| 69 | + - echo "♻️ Restarting the controller-manager to pick up the new image..." |
| 70 | + - kubectl config use-context kind-nso-standard |
| 71 | + - | |
| 72 | + kubectl -n network-services-operator-system \ |
| 73 | + rollout restart deploy network-services-operator-controller-manager |
| 74 | + - echo "⏳ Waiting for the new controller-manager rollout to complete..." |
| 75 | + - | |
| 76 | + kubectl -n network-services-operator-system \ |
| 77 | + rollout status deploy network-services-operator-controller-manager \ |
| 78 | + --timeout=180s |
| 79 | + - echo "✅ Operator redeployed with the freshly built image." |
| 80 | + |
| 81 | + destroy: |
| 82 | + desc: "Tear down the multi-cluster dev environment" |
| 83 | + cmds: |
| 84 | + - echo "💥 Destroying clusters..." |
| 85 | + - kind delete cluster --name nso-standard || true |
| 86 | + - kind delete cluster --name nso-infra || true |
| 87 | + - rm -f {{.TMP_DIR}}/.kind-nso-infra-internal.yaml |
| 88 | + - echo "✨ Cleanup finished." |
| 89 | + |
| 90 | + test: |
| 91 | + desc: "Run E2E tests using chainsaw on the local multi-cluster setup" |
| 92 | + cmds: |
| 93 | + - echo "🧪 Running E2E tests..." |
| 94 | + - | |
| 95 | + if [ -n "{{.CLI_ARGS}}" ]; then |
| 96 | + if [[ "{{.CLI_ARGS}}" == test/e2e/* || "{{.CLI_ARGS}}" == ./test/e2e/* ]]; then |
| 97 | + make test-e2e TEST_DIR="{{.CLI_ARGS}}" |
| 98 | + else |
| 99 | + make test-e2e TEST_DIR="./test/e2e/{{.CLI_ARGS}}" |
| 100 | + fi |
| 101 | + else |
| 102 | + make test-e2e |
| 103 | + fi |
0 commit comments