github.com/cilium/cilium@v1.16.2/test/controlplane/services/graceful-termination/generate.sh (about) 1 #!/usr/bin/env bash 2 # 3 # Generate the golden test files for the graceful termination test 4 # 5 # This generates the following files: 6 # init.yaml: The initial state of the cluster 7 # state1.yaml: Initial creation of the services and endpoints 8 # state2.yaml: Endpoint is set to terminating state 9 # state3.yaml: Endpoint has been removed 10 11 set -eux 12 13 dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 14 15 . "${dir}/../../k8s_versions.sh" 16 17 export KUBECONFIG="${dir}/kubeconfig" 18 19 function get_state() { 20 kubectl get -n test services,endpointslices -o yaml 21 } 22 23 : Start a kind cluster with the EndpointSliceTerminatingCondition gate 24 kind create cluster --config "${dir}/manifests/kind-config-1.26.yaml" --name graceful-term 25 26 : Wait for service account to be created 27 until kubectl get serviceaccount/default; do 28 sleep 5 29 done 30 31 : Preloading images 32 kind load --name graceful-term docker-image "${cilium_container_repo}/${cilium_container_image}:${cilium_version}" || true 33 kind load --name graceful-term docker-image "${cilium_container_repo}/${cilium_operator_container_image}:${cilium_version}" || true || true 34 35 : Install cilium 36 cilium install --wait 37 38 : Dump the initial state 39 kubectl get nodes,ciliumnodes,services,endpointslices -o yaml > "${dir}/init.yaml" 40 41 : Apply the graceful-termination.yaml and dump the initial state 42 kubectl create namespace test 43 kubectl apply -f "${dir}/manifests/graceful-termination.yaml" 44 kubectl wait -n test --for=condition=ready --timeout=60s --all pods 45 get_state > "${dir}/state1.yaml" 46 47 : Stop the server 48 kubectl -n test delete pod -l app=graceful-term-server & 49 PID_DELETE=$! 50 51 : Wait for endpoint to become terminating and then dump it 52 kubectl wait -n test --timeout=60s \ 53 -l kubernetes.io/service-name=graceful-term-svc \ 54 endpointslices \ 55 --for=jsonpath='{..endpoints..conditions.terminating}=true' 56 get_state > "${dir}/state2.yaml" 57 58 : Finish deletion and dump the final state 59 wait $PID_DELETE 60 get_state > "${dir}/state3.yaml" 61 62 : Tear down the cluster 63 kind delete clusters graceful-term 64 rm -f "${KUBECONFIG}"