mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-19 07:49:17 +00:00
Merge pull request #7983 from sprt/resource-group-naming
ci: Create clusters in individual resource groups
This commit is contained in:
@@ -11,14 +11,33 @@ set -o pipefail
|
||||
tests_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${tests_dir}/common.bash"
|
||||
|
||||
AZ_RG="${AZ_RG:-kataCI}"
|
||||
K8S_TEST_HOST_TYPE="${K8S_TEST_HOST_TYPE:-small}"
|
||||
|
||||
function _print_instance_type() {
|
||||
case ${K8S_TEST_HOST_TYPE} in
|
||||
small)
|
||||
echo "Standard_D2s_v5"
|
||||
;;
|
||||
normal)
|
||||
echo "Standard_D4s_v5"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown instance type '${K8S_TEST_HOST_TYPE}'" >&2
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
function _print_cluster_name() {
|
||||
test_type="${1:-k8s}"
|
||||
|
||||
short_sha="$(git rev-parse --short=12 HEAD)"
|
||||
echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64"
|
||||
echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64-${K8S_TEST_HOST_TYPE:0:1}"
|
||||
}
|
||||
|
||||
function _print_rg_name() {
|
||||
test_type="${1:-k8s}"
|
||||
|
||||
echo "${AZ_RG:-"kataCI-$(_print_cluster_name ${test_type})"}"
|
||||
}
|
||||
|
||||
function install_azure_cli() {
|
||||
@@ -38,23 +57,20 @@ function login_azure() {
|
||||
function create_cluster() {
|
||||
test_type="${1:-k8s}"
|
||||
|
||||
# First, ensure that the cluster didn't fail to get cleaned up from a previous run.
|
||||
# First ensure it didn't fail to get cleaned up from a previous run.
|
||||
delete_cluster "${test_type}" || true
|
||||
|
||||
local instance_type=""
|
||||
case ${K8S_TEST_HOST_TYPE} in
|
||||
small)
|
||||
instance_type="Standard_D2s_v5"
|
||||
;;
|
||||
normal)
|
||||
instance_type="Standard_D4s_v5"
|
||||
;;
|
||||
esac
|
||||
local rg="$(_print_rg_name ${test_type})"
|
||||
|
||||
az group create \
|
||||
-l eastus2 \
|
||||
-n "${rg}"
|
||||
|
||||
az aks create \
|
||||
-g "${AZ_RG}" \
|
||||
-g "${rg}" \
|
||||
--node-resource-group "node-${rg}" \
|
||||
-n "$(_print_cluster_name ${test_type})" \
|
||||
-s "${instance_type}" \
|
||||
-s "$(_print_instance_type)" \
|
||||
--node-count 1 \
|
||||
--generate-ssh-keys \
|
||||
$([ "${KATA_HOST_OS}" = "cbl-mariner" ] && echo "--os-sku AzureLinux --workload-runtime KataMshvVmIsolation")
|
||||
@@ -79,16 +95,15 @@ function get_cluster_credentials() {
|
||||
test_type="${1:-k8s}"
|
||||
|
||||
az aks get-credentials \
|
||||
-g "${AZ_RG}" \
|
||||
-g "$(_print_rg_name ${test_type})" \
|
||||
-n "$(_print_cluster_name ${test_type})"
|
||||
}
|
||||
|
||||
function delete_cluster() {
|
||||
test_type="${1:-k8s}"
|
||||
|
||||
az aks delete \
|
||||
-g "${AZ_RG}" \
|
||||
-n "$(_print_cluster_name ${test_type})" \
|
||||
az group delete \
|
||||
-g "$(_print_rg_name ${test_type})" \
|
||||
--yes
|
||||
}
|
||||
|
||||
|
@@ -66,10 +66,10 @@ else
|
||||
|
||||
case ${K8S_TEST_HOST_TYPE} in
|
||||
small)
|
||||
K8S_TEST_UNION=($K8S_TEST_SMALL_HOST_UNION)
|
||||
K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]})
|
||||
;;
|
||||
normal)
|
||||
K8S_TEST_UNION=($K8S_TEST_NORMAL_HOST_UNION)
|
||||
K8S_TEST_UNION=(${K8S_TEST_NORMAL_HOST_UNION[@]})
|
||||
;;
|
||||
baremetal)
|
||||
K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]} ${K8S_TEST_NORMAL_HOST_UNION[@]})
|
||||
|
Reference in New Issue
Block a user