Skip to content

Commit

Permalink
ci: Add first letter of the K8S_TEST_HOST_TYPE to resource group name
Browse files Browse the repository at this point in the history
Ideally we'd add the instance_type or the full K8S_TEST_HOST_TYPE but
that exceeds the maximum amount of characteres allowed for the cluster
name.  With this in mind, let's use the first letter of
K8S_TEST_HOST_TYPE instead.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
(cherry picked from commit d9ef135)
  • Loading branch information
sprt authored and fidencio committed Sep 21, 2023
1 parent 882d7d7 commit 7892e04
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/gha-run-k8s-common.sh
Expand Up @@ -13,11 +13,25 @@ source "${tests_dir}/common.bash"

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() {
Expand Down Expand Up @@ -52,21 +66,11 @@ function create_cluster() {
-l eastus2 \
-n "${rg}"

local instance_type=""
case ${K8S_TEST_HOST_TYPE} in
small)
instance_type="Standard_D2s_v5"
;;
normal)
instance_type="Standard_D4s_v5"
;;
esac

az aks create \
-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")
Expand Down

0 comments on commit 7892e04

Please sign in to comment.