Created
March 15, 2023 07:44
-
-
Save ruzickap/9e1d3253e638e8c0ec393e28fc8c44ed to your computer and use it in GitHub Desktop.
Deploy Azure AKS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export AZURE_LOCATION=westeurope | |
export CLUSTER_FQDN="ruzickap2aks.k8s.mylabs.dev" | |
# CLUSTER_NAME must have max 12 character due to "--nodepool-name" parameter | |
export CLUSTER_NAME="${CLUSTER_FQDN%%.*}" | |
export KUBECONFIG="/tmp/kubeconfig-${CLUSTER_NAME}.conf" | |
set -euxo pipefail | |
# az aks get-versions --location=westeurope | jq | |
if ! az aks list --query '[].name' | grep -q "${CLUSTER_NAME}" ; then | |
az group create -n "${CLUSTER_NAME}" -l "${AZURE_LOCATION}" | |
az aks create \ | |
--auto-upgrade-channel stable \ | |
--enable-cluster-autoscaler \ | |
--kubernetes-version 1.26.0 \ | |
--max-count 5 \ | |
--min-count 2 \ | |
--name "${CLUSTER_NAME}" \ | |
--node-count 2 \ | |
--node-osdisk-size 30 \ | |
--node-vm-size Standard_B2ms \ | |
--nodepool-name "${CLUSTER_NAME}" \ | |
--nodepool-tags "[email protected]" "Environment=dev" "Cluster_FQDN=${CLUSTER_FQDN}" \ | |
--resource-group "${CLUSTER_NAME}" \ | |
--tags "[email protected]" "Environment=dev" "Cluster_FQDN=${CLUSTER_FQDN}" | |
fi | |
az aks get-credentials --resource-group "${CLUSTER_NAME}" --name "${CLUSTER_NAME}" --admin --file "${KUBECONFIG}" --overwrite-existing | |
cat << EOF | |
*** Cluster DELETE | |
export CLUSTER_FQDN="ruzickap2aks.k8s.mylabs.dev" | |
az group delete --resource-group "${CLUSTER_FQDN%%.*}" --yes | |
EOF | |
echo -e "\n*****\n export KUBECONFIG=${KUBECONFIG} \n*****\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment