mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-27 15:57:09 +00:00
ci: Create clusters in individual resource groups
This makes it so that each AKS cluster is created in its own individual resource group, rather than using the "kataCI" resource group for all test clusters. This is to accommodate a tool that we recently introduced in our Azure subscription which automatically deletes resource groups after a set amount of time, in order to keep spending under control. The tool will automatically delete any resource group, unless it has a tag SkipAutoDeleteTill = YYYY-MM-DD. When this tag is present, the resource group will be retained until the specified date. Note that I tagged all current resource groups in our subscription with SkipAutoDeleteTill = 2043-01-01 so that we don't lose any existing resources. Fixes: #7982 Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
This commit is contained in:
parent
5f8e210d3b
commit
68267a3996
@ -11,7 +11,6 @@ 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_cluster_name() {
|
function _print_cluster_name() {
|
||||||
@ -21,6 +20,12 @@ function _print_cluster_name() {
|
|||||||
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
||||||
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
||||||
# The aks-preview extension is required while the Mariner Kata host is in preview.
|
# The aks-preview extension is required while the Mariner Kata host is in preview.
|
||||||
@ -38,9 +43,15 @@ 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 rg="$(_print_rg_name ${test_type})"
|
||||||
|
|
||||||
|
az group create \
|
||||||
|
-l eastus2 \
|
||||||
|
-n "${rg}"
|
||||||
|
|
||||||
local instance_type=""
|
local instance_type=""
|
||||||
case ${K8S_TEST_HOST_TYPE} in
|
case ${K8S_TEST_HOST_TYPE} in
|
||||||
small)
|
small)
|
||||||
@ -52,7 +63,8 @@ function create_cluster() {
|
|||||||
esac
|
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 "${instance_type}" \
|
||||||
--node-count 1 \
|
--node-count 1 \
|
||||||
@ -79,16 +91,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user