Skip to content

Instantly share code, notes, and snippets.

@darkn3rd
darkn3rd / steps_end_to_end.sh
Last active Sep 26, 2021
F/AKS with ExternalDNS/AzureDNS - steps_end_to_end.sh
View steps_end_to_end.sh
#!/usr/bin/env bash
###########
# STEP 0: Create File Structure
##########################
PROJECT_ROOT=~/aks_dns
mkdir -p $PROJECT_ROOT/{templates,demos/hello-kubernetes}
cd $PROJECT_ROOT
touch \
{azure_dns,external_dns,main,versions}.tf terraform.tfvars \
@darkn3rd
darkn3rd / external_dns_values.yaml
Created Sep 18, 2021
AKS/Helmfile + ExternalDNS/AzureDNS (kubletidentity) - external_dns_values.yaml.tmpl
View external_dns_values.yaml
provider: azure
azure:
resourceGroup: ${resource_group}
tenantId: ${tenant_id}
subscriptionId: ${subscription_id}
useManagedIdentityExtension: true
logLevel: ${log_level}
domainFilters:
- ${domain}
txtOwnerId: external-dns
@darkn3rd
darkn3rd / destroy_hello_kubernetes.sh
Created Sep 18, 2021
TF/AKS with ExternalDNS/AzureDNS - destroy_hello_kubernetes.sh
View destroy_hello_kubernetes.sh
pushd demos/hello-kubernetes
terraform destroy
popd
@darkn3rd
darkn3rd / verify_hello_kubernetes_deploy.sh
Last active Sep 19, 2021
TF/AKS with ExternalDNS/AzureDNS - verify_hello_kubernetes_deploy.sh
View verify_hello_kubernetes_deploy.sh
export AZ_AKS_CLUSTER_NAME="$(terraform output -raw kubernetes_cluster_name)"
export KUBECONFIG=~/.kube/${AZ_AKS_CLUSTER_NAME}.yaml
kubectl get all --namespace hello
@darkn3rd
darkn3rd / verify_external_dns_deploy.sh
Last active Sep 18, 2021
TF/AKS with ExternalDNS/AzureDNS - verify_external_dns_deploy.sh
View verify_external_dns_deploy.sh
export AZ_CLUSTER_NAME="$(terraform output -raw kubernetes_cluster_name)"
export KUBECONFIG=~/.kube/${AZ_CLUSTER_NAME}.yaml
kubectl get all --namespace kube-addons
@darkn3rd
darkn3rd / verify_externaldns_config.sh
Last active Sep 19, 2021
TF/AKS with ExternalDNS/AzureDNS - verify_externaldns_config.sh
View verify_externaldns_config.sh
export AZ_AKS_CLUSTER_NAME="$(terraform output -raw kubernetes_cluster_name)"
export KUBECONFIG=~/.kube/${AZ_AKS_CLUSTER_NAME}.yaml
kubectl get secret external-dns \
--namespace kube-addons \
--output jsonpath="{.data.azure\.json}" | base64 --decode
@darkn3rd
darkn3rd / verify_role_binding.sh
Last active Sep 19, 2021
TF/AKS with ExternalDNS/AzureDNS - verify_role_binding.sh
View verify_role_binding.sh
export AZ_PRINCIPAL_ID="$(terraform output -raw kubelet_identity_id)"
############
# show role bindings on kubelet id (managed id assigned to VMSS node pool)
############################################
az role assignment list --assignee $AZ_PRINCIPAL_ID --all \
--query '[].{roleDefinitionName:roleDefinitionName, provider:scope}' \
--output table | sed 's|/subscriptions.*providers/||' | cut -c -80
@darkn3rd
darkn3rd / verify_dns_records.sh
Last active Sep 19, 2021
TF/AKS with ExternalDNS/AzureDNS - verify_dns_records.sh
View verify_dns_records.sh
# set environment variables based on terraform.tfvars settings
export AZ_DNS_DOMAIN=$(terraform output -raw dns_zone_name)
export AZ_DNS_RESOURCE_GROUP=$(terraform output -raw dns_zone_resource_group_name)
# fetch list of reocords from the zoen
az network dns record-set list \
--resource-group $AZ_DNS_RESOURCE_GROUP \
--zone-name $AZ_DNS_DOMAIN \
--output table
@darkn3rd
darkn3rd / deploy_external_dns.sh
Created Sep 18, 2021
TF/AKS with ExternalDNS/AzureDNS - deploy_external_dns.sh
View deploy_external_dns.sh
# download helm provider
terraform init
# deploy external_dns helm chart
terraform apply --target helm_release.external_dns
@darkn3rd
darkn3rd / deploy_hello_kubernetes.sh
Created Sep 18, 2021
TF/AKS with ExternalDNS/AzureDNS - deploy_hello_kubernetes
View deploy_hello_kubernetes.sh
pushd demos/hello-kubernetes
terraform init
terraform apply
popd