AKS Starter Kit Getting Started
1. Introduction
- Purpose of the Guide: This guide is designed to assist users in comprehending the necessary prerequisites and the steps involved to successfully execute the project.
- Definitions:
- Environment: The project utilized
terraform workspacefor switch between environments.
- Environment: The project utilized
- Project's folder structure:
- docs: Project's documentation
- env: Folder contains environment specific backend and modules configuration
- modules: Project's modules
- plans: Folder for storing generated plans
- scripts:
terraform init,terraform planandterraform apply, with workspace (environment) configuration applied, implemented in bothbashandpowershellscripts.
- Backend:
azurermbackend is configured by<ENV>.backend.tfvarsfile. - Customization:
- Modules can be customized by editing their respective
<ENV>.tfvarsfiles, where ENV is selected workspace. - Additional resources and configurations can be added as per project requirements.
- Modules can be customized by editing their respective
2. Getting Started
Please note that this project is designed to provision new Azure resources, including the setup of a new Azure Kubernetes Service (AKS) cluster, among other components. It has not been tested with existing AKS clusters or pre-configured Azure resources. Users planning to deploy this project should be aware that it assumes a fresh environment for optimal compatibility and performance. Existing Azure resource configurations may require adjustments or could lead to unpredictable outcomes if used in conjunction with this project.
Prerequisites:
- Azure account with
Contributorpermission for the Azure subscription. Terraforminstalled on your local machine.Azure Storage Accountfor storing Terraform State.- You will need a domain under your control with the ability to manage its DNS settings for
KialiandGrafanadashboards. After deployment,KialiandGrafanadashboards will be up and running. - Some knowledge of
Terraform,Kubernetes,HelmandIstio. - You must be logged in with Azure CLI
az loginand required subscription should be selectedaz account set
- Azure account with
Initial Setup:
Rename
default.backend.tfvarstodev.backend.tfvarsand define a proper backend configuration.Run
terraform initto initialize the backend:.\scripts\init.ps1 -ENV "dev"Create a new workspace
dev:terraform workspace new devEmpty
devworkspace will be created and selectedRename
default.tfvarstodev.tfvarsand configure project's modules.Adjust parameters as per your infrastructure needs
Make sure that optional modules are disabled on this stage:
project_modules = { kiali = false prometheus = false grafana = false letsencrypt = false }Create an empty
azure.yamlfile in root folder
3. Deployment with Terraform
The deployment can be divided in 3 phases:
- Deploy azure resources
- Create an
A recordsfor your domains - Deploy services
There is couple of reasons for such dividing:
kubernetes_manifestterraform statements will try to connect cluster first to check if resource is already created on a plan stage, and will fail because cluster is not created yet.- Let's encrypt will perform ACME challenge for your domains as a part of certification issuing process, which requires your domain to point to AKS IP address. DNS record update is async and might take 5-60 minutes depending on provider.
Phase I - Build azure resources (~5 minute): Considering everything is set in Initial setup, you can start building the Azure infrastructure
Plan terraform changes:
.\scripts\plan.ps1Review the output
Apply the changes:
.\scripts\apply.ps1
Phase II - Create A records for domains (~ 5-60 minutes):
Obtain clusters public IP address via Portal/AKS/Services ann ingresses blade or by running:
kubectl get svc/istio-ingress -n istio-systemEXTERNAL-IPwill be the cluster's IP addressCreate A record for
kialiCreate A record for
grafanaWait couple of minutes and check that domain is resolved to cluster's IP
Phase III - Build the services (~5-10 minutes): Assuming that above is implemented
Turn optional modules on:
project_modules = { kiali = true prometheus = true grafana = true letsencrypt = true }Plan terraform changes:
.\scripts\plan.ps1Review the output
Apply the changes:
.\scripts\apply.ps1
Enjoy!
4. Usage
Connecting to AKS: With newly generated
kubeconfigfile:$env:KUBECONFIG = "azure.yaml"You can also connect cluster as described in the portal.