Creating VPC DNS Link in Microsoft Azure ​
WARNING
This is a beta feature available only per request for SAP-internal teams.
This tutorial explains how to link the SAP, BTP Kuma runtime network to a remote private DNS zone in Microsoft Azure. Learn how to create a new resource group, private DNS zone, and record-set, and assign required roles to the provided Kyma service principal in your Microsoft Azure subscription.
Prerequisites ​
- You have the Cloud Manager module added. See Add and Delete a Kyma Module.
- Azure CLI
Steps ​
Authorize Cloud Manager in the Remote Subscription ​
Log in to your Microsoft Azure account and set the active subscription:
shellexport SUBSCRIPTION={SUBSCRIPTION} az login az account set --subscription $SUBSCRIPTIONVerify if the Cloud Manager service principal exists in your tenant.
shellexport APPLICATION_ID={APPLICATION_ID} az ad sp show --id $APPLICATION_IDOptional: If the service principal doesn't exist, create one for the Cloud Manager application in your tenant.
shellaz ad sp create --id $APPLICATION_IDAssign the required
Classic Network ContributorandNetwork ContributorIdentity and Access Management (IAM) roles to the Cloud Manager service principal. See Authorizing Cloud Manager in the Remote Cloud Provider to identify the Cloud Manager principal.shellexport SUBSCRIPTION_ID=$(az account show --query id -o tsv) export OBJECT_ID=$(az ad sp show --id $APPLICATION_ID --query "id" -o tsv) az role assignment create --assignee $OBJECT_ID \ --role "Network Contributor" \ --scope "/subscriptions/$SUBSCRIPTION_ID" az role assignment create --assignee $OBJECT_ID \ --role "Classic Network Contributor" \ --scope "/subscriptions/$SUBSCRIPTION_ID"
Set Up a Test Environment in the Remote Subscription ​
Set the region that is closest to your Kyma cluster. Use
az account list-locationsto list available locations.shellexport REGION={REGION}Create a resource group as a container for related resources:
shellexport RESOURCE_GROUP_NAME="MyResourceGroup" az group create --name $RESOURCE_GROUP_NAME --location $REGIONCreate a private DNS zone:
shellexport ZONE_NAME="example.com" az network private-dns zone create --resource-group $RESOURCE_GROUP_NAME --name $ZONE_NAMECreate a private DNS A record:
shellexport RECORD_SET_NAME=test export IP_ADDRESS=10.0.0.1 az network private-dns record-set a add-record --resource-group $RESOURCE_GROUP_NAME --zone-name $ZONE_NAME --record-set-name $RECORD_SET_NAME --ipv4-address $IP_ADDRESS
Allow SAP BTP, Kyma Runtime to link with your Private DNS zone ​
Tag the private DNS zone with the Kyma shoot name:
export SHOOT_NAME=$(kubectl get cm -n kube-system shoot-info -o jsonpath='{.data.shootName}')
export ZONE_ID=$(az network private-dns show --name $ZONE_NAME --resource-group $RESOURCE_GROUP_NAME --query id --output tsv)
az tag update --resource-id $ZONE_ID --operation Merge --tags $SHOOT_NAMECreate VPC DNS Link ​
Create an AzureVpcDnsLink resource:
shellkubectl apply -f - <<EOF apiVersion: cloud-resources.kyma-project.io/v1beta1 kind: AzureVpcDnsLink metadata: name: kyma-vpc-dns-link spec: remoteLinkName: kyma-vpc-dns-link remotePrivateDnsZone: $ZONE_ID EOFWait for the AzureVpcDnsLink to be in the
Readystate.shellkubectl wait --for=condition=Ready azurevpcdnslink/kyma-vpc-dns-link --timeout=300sOnce the newly created AzureVpcDnsLink is provisioned, you should see the following message:
consoleazurevpcdnslink.cloud-resources.kyma-project.io/kyma-vpc-dns-link condition metCreate a namespace and export its value as an environment variable:
shellexport NAMESPACE={NAMESPACE_NAME} kubectl create ns $NAMESPACECreate a workload that queries previously created private DNS A record:
shellkubectl apply -n $NAMESPACE -f - <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: azurevpcdnslink-demo spec: selector: matchLabels: app: azurevpcdnslink-demo template: metadata: labels: app: azurevpcdnslink-demo spec: containers: - name: my-container resources: limits: memory: 512Mi cpu: "1" requests: memory: 256Mi cpu: "0.2" image: ubuntu command: - "/bin/bash" - "-c" - "--" args: - "apt update; apt install dnsutils -y; dig $RECORD_SET_NAME.$ZONE_NAME +noall +answer" EOFThis workload should print the resolved IP address of the private DNS A record to stdout.
To print the logs of one of the workloads, run:
shellkubectl logs -n $NAMESPACE `kubectl get pod -n $NAMESPACE -l app=azurevpcdnslink-demo -o=jsonpath='{.items[0].metadata.name}'`The command prints an output similar to the following:
console... test.example.com. 30 IN A 10.0.0.1
Next Steps ​
To clean up Kubernetes resources and your subscription resources, follow these steps:
Remove the created workloads:
shellkubectl delete -n $NAMESPACE deployment azurevpcdnslink-demoRemove the created AzureVpcDnsLink resource:
shellkubectl delete -n $NAMESPACE azurevpcdnslink kyma-vpc-dns-linkRemove the created namespace:
shellkubectl delete namespace $NAMESPACEIn your Microsoft Azure account, remove the created Azure resource group:
shellaz group delete --name $RESOURCE_GROUP_NAME --yes