...
We assume you have an existing parent domain i.e. example.com hosted on the same account as the cluster that we are going to create in the coming section and you wish to access the cluster environment through the hostname. Terraform will create a subdomain in format
<cluster_name>.<domain>
.cluster name: uepe-aks
domain: example.com
final domain: uepe-aks.example.com
In addition, we also assume terraform is allowed to add a NS (NameServer) record to the parent domain. This is to allow DNS delegation from the parent domain to subdomain.
Terraform needs to persist the state of your provisioned infrastructure, by default the state file is stored locally on the computer that terraform is executed from. However if you have multiple person working on the infrastructure then it is recommended to store the state file on remote persistent such as Azure Storage, see https://learn.microsoft.com/en-us/azure/developer/terraform/store-state-in-azure-storage?tabs=terraform for more information.
We use the Azure Files (SMB/NFS) as the default persistent storage for data needs to be persisted.
We use the Azure Database for PostgreSQL - Flexible Server service for Usage Engine Private Edition database.
We assume that you have the privileges to create user managed identity and grant role to the identity created by terraform within the same resource group. See https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp for more details.
To use the terraform template, preview feature has to be enabled in your Azure subscription. Refer to https://learn.microsoft.com/en-us/azure/aks/api-server-vnet-integration#install-the-aks-preview-azure-cli-extension for the commands to run. You only need to execute these sections:
Install the aks-preview Azure CLI extension
Register the 'EnableAPIServerVnetIntegrationPreview' feature flag
Create Basic Cluster and
...
Additional Infrastructure
Follow these steps to create a basic Kubernetes cluster with public and private VPC:
Extract the downloaded
azure.tar.gz
file.Go to
<your local path>/azure/terraform
folder and copy theterraform.tfvars.example
toterraform.tfvars
.Edit the
terraform.tfvars
file.Specify the desired
cluster_name
, Azurelocation
andkubernetes_version
(see Compatibility Matrix (4.23) to find out which Kubernetes versions that are compatible with this release of Usage Engine Private Edition). Also specify your Azureresource_group_name
,domain
as well as the desired number of nodes per cluster (user_node_count
).If you will be running with a database other than Derby also specify
db_password
anddb_version
.
terraform.tfvars | Where to get the value from? |
---|---|
| Name of the resource group. The resource group must exist in the Azure subscription. |
| Location of the cluster |
| Name of the cluster, it must be unique within the resource group. |
| Your existing domain name. In the Azure management console, this is the DNS zones that is listed on page The service created by Usage Engine Private Edition in the coming section will be accessible in format |
| Kubernetes version. |
| Number of nodes in the user node pool. |
| Choose a secure password for the system database administrator. Minimum 10 characters. |
| PostgreSQL database version. Supported versions are 11, 12, 13, 14, 15 and 16. |
| Boolean flag to enable PostgreSQL database resource creation. |
| Boolean flag to enable subdomain NS record auto creation in parent domain. In case your parent domain is not under the same resource group or your parent domain is hosted in another cloud provider, then you must set it to false. |
| Boolean flag to enable file storage resource creation. |
Example:
Code Block |
---|
# ____ _____ _____ _____ _ _ _____ ____ _____ # / ___|| ____|_ _| |_ _| | | | ____/ ___|| ____|_ # \___ \| _| | | | | | |_| | _| \___ \| _| (_) # ___) | |___ | | | | | _ | |___ ___) | |___ _ # |____/|_____| |_| |_| |_| |_|_____|____/|_____(_) # The below values must be set explicitly in order for the setup to work correctly. # Name of the resource group # The resource group must be existed in the Azure subscription. resource_group_name = "PT_Stratus" # Location of the cluster # Use command `az account list-locations --query "[].displayName" -o tsv` to get all available locations. # Or see https://azure.microsoft.com/en-us/explore/global-infrastructure/products-by-region/?products=kubernetes-service®ions=all location = "Southeast Asia" # Name of the cluster, it must be unique within the resource group. cluster_name = "uepe-aks" # Domain DNS name # The DNS zone must already exist in Azure DNS or in other cloud provider DNS zone. # We'll create a subdomain zone from parent domain, the final domain will be in format "<cluster_name>.<domain>". # Please note that if this domain is hosted on another resource group or other cloud provider, then you must # set auto_create_ns_record = false and manually add the subdomain NS record to the parent domain. domain = "stratus.az.digitalroute.net" # Admin user password to the database db_password = "super_SeCrEt_db_pAsSwOrD_457!" # _______ _______ _ _ __ _ ____ _ _____ # |_ _\ \ / / ____| / \ | |/ / / \ | __ )| | | ____|_ # | | \ \ /\ / /| _| / _ \ | ' / / _ \ | _ \| | | _| (_) # | | \ V V / | |___ / ___ \| . \ / ___ \| |_) | |___| |___ _ # |_| \_/\_/ |_____/_/ \_\_|\_\/_/ \_\____/|_____|_____(_) # The below sections are the default values, tweak them to your needs. # _ _ ______ # / \ | |/ / ___| # / _ \ | ' /\___ \ # / ___ \| . \ ___) | # /_/ \_\_|\_\____/ # The size of the Virtual Machine # Use command `az vm list-sizes --location "West Europe" --output table` to get available VM sizes. vm_size = "Standard_DS2_v2" # Kubernetes version kubernetes_version = "1.29" # Number of nodes in the system node pool, must be at least 1 node. system_node_count = 2 # Number of nodes in the user node pool. If zero, the user node pool will not be created. user_node_count = 1 # DNS prefix specified when creating the managed cluster. # It must begin and end with a letter or number, contain only letters, numbers, and hyphens and be between 1 and 54 characters in length. dns_prefix = "aks" # Operating system disk size in GB os_disk_size_gb = 30 # The priority for Virtual Machines within the Virtual Machine Scale Set that powers the node pool. # Valid values are Regular and Spot. priority = "Regular" # The eviction policy for Virtual Machines within the Virtual Machine Scale Set that powers the node pool. eviction_policy = "Delete" # The maximum price you are willing to pay for Spot VMs. The value must be -1 or a positive value with up to five decimal places. # See https://docs.microsoft.com/en-us/azure/virtual-machines/spot-vms for more information. spot_max_price = -1 .......... # ____ _ _ ____ # | _ \| \ | / ___| # | | | | \| \___ \ # | |_| | |\ |___) | # |____/|_| \_|____/ # Specify if nameservers of the subdomain should automatically inserted as a NS record to the parent domain's zone to allow DNS delegation. # By default we assume your parent domain zone is hosted on the same resource group, if this is not the case then you MUST set it to false. auto_create_ns_record = true # ____ _____ ___ ____ _ ____ _____ # / ___|_ _/ _ \| _ \ / \ / ___| ____| # \___ \ | || | | | |_) | / _ \| | _| _| # ___) || || |_| | _ < / ___ \ |_| | |___ # |____/ |_| \___/|_| \_\/_/ \_\____|_____| # Persistent storage storage_enabled = true # Kind of account to create. Valid options are Storage, StorageV2, BlobStorage, BlockBlobStorage or FileStorage. account_kind = "FileStorage" # Tier to use for the storage account. Either Standard or Premium. # For BlockBlobStorage and FileStorage accounts only Premium is valid. account_tier = "Premium" # Storage redundancy type # See https://learn.microsoft.com/en-us/azure/storage/files/files-redundancy for available options. account_replication_type = "LRS" # Protocol used for the share, either SMB or NFS. # See https://learn.microsoft.com/en-us/azure/storage/files/storage-files-planning#available-protocols for the comparison. enabled_protocol = "SMB" # Storage capacity in GB storage_capacity = 100 # ____ _ _____ _ ____ _ ____ _____ # | _ \ / \|_ _|/ \ | __ ) / \ / ___|| ____| # | | | |/ _ \ | | / _ \ | _ \ / _ \ \___ \| _| # | |_| / ___ \| |/ ___ \| |_) / ___ \ ___) | |___ # |____/_/ \_\_/_/ \_\____/_/ \_\____/|_____| # PostgreSQL database db_enabled = true # SKU Name for PostgreSQL, it follows the tier + name pattern. # Available tiers are Basic (B), GeneralPurpose (GP), MemoryOptimized (MO). # Use command `az postgres flexible-server list-skus --location "West Europe" --output table` to find out available SKU names. # For example, tier "GeneralPurpose" and name "Standard_D2s_v3", the SKU name is "GP_Standard_D2s_v3". sku_name = "GP_Standard_D2s_v3" # Storage performance tier for IOPS. See https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server#storage_tier-defaults-based-on-storage_mb for more information db_tier = "P10" # DB version. Supported versions are 11, 12, 13, 14, 15 and 16. db_version = "16" # DB storage in MB. See https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/postgresql_flexible_server#storage_tier-defaults-based-on-storage_mb for available storage sizes. db_allocated_storage = 131072 # Specify which availability zone the instance should be located in. zone = 1 |
...
A basic Kubernetes cluster has now been set up successfully.
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
...
Code Block |
---|
NAME STATUS ROLES AGE VERSION aks-default-41718565-vmss000000 Ready <none> 6d2h v1.29.5 aks-default-41718565-vmss000001 Ready <none> 6d1h v1.29.5 aks-internal-23883603-vmss000000 Ready <none> 6d2h v1.29.5 |
Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
...
This section is now complete and you can proceed to the Kubernetes Cluster Add-ons - Azure (4.23) section.