This solution was developed/tested using the following:
- Terraform (v1.0.6)
- Docker (v20.10.8)
- Azure CLI (v2.28.0)
- kubectl (v1.20.2)
- envsubst (v0.19.8.1)
- jq (v1.6)
The following commands should get your infrastructure set up.
Good luck! 🤞
-
Perform an interactive login to Azure using the CLI:
az login
This should open your preferred browser with a prompt to log in to your account.
-
Now you have authenticated to Azure you can get cracking with the Terraform:
terraform init
-
Now let's ask Terraform to provision the various resources.
terraform apply
Sanity check the output and respond appropriately (most likely with a
yes
, 'cause you want your Superset resources, right?) -
Go make yourself a brew ☕.
The provisioning might take a while (the Redis instance seems to be the culprit responsible for the significant wait time at a whopping 17 minutes last time I tried. Bonkers).
-
Get the
acr_login_server
value from Terraform and assign it to an environment variable:export ACR_LOGIN_SERVER=$(terraform output -raw acr_login_server)
-
Have a quick sanity check of the variable value:
echo $ACR_LOGIN_SERVER
-
Log in to the Azure Container Registry (ACR):
az acr login --name $ACR_LOGIN_SERVER
-
Build the Superset Docker container:
docker build --tag $ACR_LOGIN_SERVER/superset_base .
-
Push the container to the ACR:
docker push $ACR_LOGIN_SERVER/superset_base
Before we begin it is important to remind you, dear reader, that this whole thing is a demonstration on how to deploy Superset to Azure. It is not illustrating best practices, and a prime example of this is shown in step 1 below where we will be grabbing a secret from a secure KeyVault, and assigning it to an environment variable. Hmmm...
-
Set up the environment variables:
export RESOURCE_GROUP_NAME=$(terraform output -raw resource_group_name) export AKS_CLUSTER_NAME=$(terraform output -raw aks_cluster_name) export ACR_LOGIN_SERVER=$(terraform output -raw acr_login_server) export SUPERSET_WEB_IP=$(terraform output -raw superset_web_ip) export DATABASE_HOST=$(terraform output -raw databse_host) export DATABASE_ADMIN_USERNAME=$(terraform output -raw database_admin_username) export DATABASE_ADMIN_PASSWORD_SECRET_ID=$(terraform output -raw database_admin_password_secret_id) export DATABASE_ADMIN_PASSWORD=$(az keyvault secret show --id $DATABASE_ADMIN_PASSWORD_SECRET_ID | jq -r .value) export REDIS_HOST=$(terraform output -raw redis_host) export REDIS_PORT=$(terraform output -raw redis_port)
-
Connect to the AKS cluster:
az aks get-credentials --resource-group $RESOURCE_GROUP_NAME --name $AKS_CLUSTER_NAME
-
Create the namespace:
kubectl apply --filename kubernetes/namespace.yaml
-
Set up the services:
cat kubernetes/services.yaml | envsubst | kubectl apply --filename -
Note: this uses
envsubst
to perform token replacement within the*.yaml
files before piping them in tokubectl
viastdin
. -
Set up the secrets:
cat kubernetes/secrets.yaml | envsubst | kubectl apply --filename -
-
Set up the config map (environment variables):
cat kubernetes/config.yaml | envsubst | kubectl apply --filename -
-
Set up the initialisation job (this performs tasks like the initial database object creation):
cat kubernetes/job.yaml | envsubst | kubectl apply --filename -
-
Set up the superset application:
cat kubernetes/deployment.yaml | envsubst | kubectl apply --filename -
-
Get the URL for the Superset Application:
echo http://$SUPERSET_WEB_IP
-
Go have fun on with your new Superset instance! 🎉