Delivering modern cloud-native applications with open source technologies on Azure Kubernetes Service
This lab creates an AKS Cluster with Azure AD Integration for RBAC.
Need Global Admin Permissions to an Existing Azure AD
There are two options here. If you have global admin privileges to an existing Azure AD and you are ok with creating new Application Registrations then you can proceed to step 3. If you do not have access to an existing Azure AD, or you want to segregate the users for testing purposes, you need to create a new Azure AD via the Azure Portal.
Create new Azure AD Tenant
Create Application Registrations for Server and Client
# Set Azure AD Server Application ID and Secret
SERVER_APP_ID=""
SERVER_APP_SECRET=""
# Set Azure AD Client Application ID
CLIENT_APP_ID=""
AZUREAD_TENANT_ID=""
az account list
# Set Azure AD Tenant ID
AZUREAD_TENANT_ID=""
Create AKS Cluster with Azure AD RBAC
# Create Resource Group
USERINITIALS="<REPLACE-WITH-USER-INITIALS-LOWERCASE>"
RG="${USERINITIALS}aksrbac-rg"
LOC="eastus"
NAME="${USERINITIALS}aksrbac"
az group create --name $RG --location $LOC
PATH_TO_SSH_PUBLICKEY="~/.ssh/id_rsa.pub"
# Create AKS with RBAC Cluster
az aks create -g $RG -n $NAME --enable-rbac \
-k 1.12.8 --node-count 1 --ssh-key-value $PATH_TO_SSH_PUBLICKEY \
--aad-server-app-id $SERVER_APP_ID \
--aad-server-app-secret $SERVER_APP_SECRET \
--aad-client-app-id $CLIENT_APP_ID \
--aad-tenant-id $AZUREAD_TENANT_ID --no-wait
Create Two User Accounts in Azure AD
Create RBAC Binding to the two users created
az aks get-credentials -g $RG -n $NAME --admin
kubectl apply -f aksrbac-clusteradmin.yaml
kubectl apply -f aksrbac-viewdefault.yaml
Get New AKS Cluster Credentials for use with Azure AD
az aks get-credentials -g $RG -n $NAME
# If you login with the aksadmin account you will be able to see the nodes.
# If you login with the aksuser account the request will be denied.
kubectl get nodes