mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-20 00:07:55 +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)"
|
tests_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
source "${tests_dir}/common.bash"
|
source "${tests_dir}/common.bash"
|
||||||
|
|
||||||
AZ_RG="${AZ_RG:-kataCI}"
|
|
||||||
K8S_TEST_HOST_TYPE="${K8S_TEST_HOST_TYPE:-small}"
|
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() {
|
function _print_cluster_name() {
|
||||||
test_type="${1:-k8s}"
|
test_type="${1:-k8s}"
|
||||||
|
|
||||||
short_sha="$(git rev-parse --short=12 HEAD)"
|
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() {
|
function install_azure_cli() {
|
||||||
@@ -38,23 +57,20 @@ function login_azure() {
|
|||||||
function create_cluster() {
|
function create_cluster() {
|
||||||
test_type="${1:-k8s}"
|
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
|
delete_cluster "${test_type}" || true
|
||||||
|
|
||||||
local instance_type=""
|
local rg="$(_print_rg_name ${test_type})"
|
||||||
case ${K8S_TEST_HOST_TYPE} in
|
|
||||||
small)
|
az group create \
|
||||||
instance_type="Standard_D2s_v5"
|
-l eastus2 \
|
||||||
;;
|
-n "${rg}"
|
||||||
normal)
|
|
||||||
instance_type="Standard_D4s_v5"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
az aks create \
|
az aks create \
|
||||||
-g "${AZ_RG}" \
|
-g "${rg}" \
|
||||||
|
--node-resource-group "node-${rg}" \
|
||||||
-n "$(_print_cluster_name ${test_type})" \
|
-n "$(_print_cluster_name ${test_type})" \
|
||||||
-s "${instance_type}" \
|
-s "$(_print_instance_type)" \
|
||||||
--node-count 1 \
|
--node-count 1 \
|
||||||
--generate-ssh-keys \
|
--generate-ssh-keys \
|
||||||
$([ "${KATA_HOST_OS}" = "cbl-mariner" ] && echo "--os-sku AzureLinux --workload-runtime KataMshvVmIsolation")
|
$([ "${KATA_HOST_OS}" = "cbl-mariner" ] && echo "--os-sku AzureLinux --workload-runtime KataMshvVmIsolation")
|
||||||
@@ -79,16 +95,15 @@ function get_cluster_credentials() {
|
|||||||
test_type="${1:-k8s}"
|
test_type="${1:-k8s}"
|
||||||
|
|
||||||
az aks get-credentials \
|
az aks get-credentials \
|
||||||
-g "${AZ_RG}" \
|
-g "$(_print_rg_name ${test_type})" \
|
||||||
-n "$(_print_cluster_name ${test_type})"
|
-n "$(_print_cluster_name ${test_type})"
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete_cluster() {
|
function delete_cluster() {
|
||||||
test_type="${1:-k8s}"
|
test_type="${1:-k8s}"
|
||||||
|
|
||||||
az aks delete \
|
az group delete \
|
||||||
-g "${AZ_RG}" \
|
-g "$(_print_rg_name ${test_type})" \
|
||||||
-n "$(_print_cluster_name ${test_type})" \
|
|
||||||
--yes
|
--yes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,10 +66,10 @@ else
|
|||||||
|
|
||||||
case ${K8S_TEST_HOST_TYPE} in
|
case ${K8S_TEST_HOST_TYPE} in
|
||||||
small)
|
small)
|
||||||
K8S_TEST_UNION=($K8S_TEST_SMALL_HOST_UNION)
|
K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]})
|
||||||
;;
|
;;
|
||||||
normal)
|
normal)
|
||||||
K8S_TEST_UNION=($K8S_TEST_NORMAL_HOST_UNION)
|
K8S_TEST_UNION=(${K8S_TEST_NORMAL_HOST_UNION[@]})
|
||||||
;;
|
;;
|
||||||
baremetal)
|
baremetal)
|
||||||
K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]} ${K8S_TEST_NORMAL_HOST_UNION[@]})
|
K8S_TEST_UNION=(${K8S_TEST_SMALL_HOST_UNION[@]} ${K8S_TEST_NORMAL_HOST_UNION[@]})
|
||||||
|
Reference in New Issue
Block a user