github.com/cilium/cilium@v1.16.2/test/controlplane/pod/hostport/generate.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  # Generate the golden test files for the HostPort test.
     4  #
     5  
     6  set -eux
     7  
     8  dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
     9  
    10  . "${dir}/../../k8s_versions.sh"
    11  
    12  export KUBECONFIG="${dir}/kubeconfig"
    13  
    14  : Start a kind cluster
    15  kind create cluster --config "${dir}/manifests/kind-config-1.26.yaml" --name hostport
    16  
    17  : Wait for service account to be created
    18  until kubectl get serviceaccount/default; do
    19      sleep 5
    20  done
    21  
    22  : Preloading images
    23  kind load --name hostport docker-image "${cilium_container_repo}/${cilium_container_image}:${cilium_version}" || true
    24  kind load --name hostport docker-image "${cilium_container_repo}/${cilium_operator_container_image}:${cilium_version}" || true || true
    25  
    26  : Install cilium
    27  cilium install --wait
    28  
    29  : Dump the initial state
    30  kubectl get nodes,pods -o yaml > "${dir}/init.yaml"
    31  
    32  : Apply manifest for hostport-1 pod
    33  kubectl create namespace test
    34  kubectl apply -f "${dir}/manifests/hostport-1.yaml"
    35  
    36  : Wait for all pods
    37  kubectl wait -n test --for=condition=ready --timeout=60s pod hostport-1
    38  
    39  : Dump the pods
    40  kubectl get -n test pods -o yaml > "${dir}/state1.yaml"
    41  
    42  : Put hostport-1 pod in "completed" by terminating nginx container.
    43  kubectl -n test exec -it hostport-1 -c nginx -- /bin/sh -c "kill 1"
    44  
    45  : Apply manifest for hostport-2 pod and wait for all pods
    46  kubectl apply -f "${dir}/manifests/hostport-2.yaml"
    47  kubectl wait -n test --for=condition=ready --timeout=60s pod hostport-2
    48  
    49  : Dump the pods
    50  kubectl get -n test pods -o yaml > "${dir}/state2.yaml"
    51  
    52  : Deleted the completed hostport-1 pod.
    53  kubectl -n test delete pod hostport-1
    54  
    55  : Dump the final state
    56  kubectl get -n test pods -o yaml > "${dir}/state3.yaml"
    57  
    58  : Tear down the cluster
    59  kind delete clusters hostport
    60  rm -f "${KUBECONFIG}"