github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/e2e_conformance/setup.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright (c) 2020 Intel Corporation
     4  #
     5  # SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  # Entry point to start a K8S cluster for end-to-end testing
     9  # If cluster is already running with Kata RuntimeClass, skip this script and
    10  # use run.sh
    11  
    12  set -o errexit
    13  set -o nounset
    14  set -o pipefail
    15  
    16  SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
    17  source "${SCRIPT_PATH}/../../../lib/common.bash"
    18  source "${SCRIPT_PATH}/../../../.ci/lib.sh"
    19  CRI_RUNTIME="${CRI_RUNTIME:-containerd}"
    20  
    21  wait_init_retry="10s"
    22  
    23  info "Setup env for K8s e2e testing"
    24  cd "${GOPATH}/src/github.com/kata-containers/tests/integration/kubernetes"
    25  if ! bash ./init.sh; then
    26  	info "k8s init failed trying again"
    27  	bash ./cleanup_env.sh
    28  	sleep "${wait_init_retry}"
    29  	bash ./init.sh
    30  fi
    31  crictl --version
    32  if ! kubectl get -f "runtimeclass_workloads/kata-runtimeclass.yaml" \
    33  	&>/dev/null; then
    34  	info "Install the kata runtimeClass"
    35  	kubectl create -f "runtimeclass_workloads/kata-runtimeclass.yaml"
    36  fi
    37  kubectl get pods --all-namespaces