This flow is used to setup a developer environment in Azure without Azure Arc and Flux. By default the three Azure Kubernetes clusters and networking layers are deployed, but the script can be edited to deploy only one layer with all functionality. Everything is executed from the local developer machine.
- PowerShell on Windows, or PowerShell Core on Linux/MacOS
- .NET 6.0
- .NET Core 3.1
- Azure CLI 2.40+
- Docker
- helm
- kubectl
- openssl
Clone this repo and open the project in VS Code. Open the Command Palette and choose Dev Containers: Reopen in Container
. With this choice you don't need to worry about your developer environment prerequisites and should be ready to go. When executing the deployment scripts, ensure you have a PowerShell terminal opened.
In a PowerShell environment, go to deployment
folder.
Ensure you are logged into Azure CLI, or run az login
first and set your default subscription.
./deploy-az-dev-bootstrapper.ps1 -ApplicationName <short-name>
By default this script provisions resources in Azure region West Europe
. To use another region, you can supply the argument -Location <shortname>
to the script above.
Note: review the arguments you can pass to the script
./deploy-az-dev-bootstrapper.ps1
so you can control deployment location, whether to deploy observability stack and more.
-
Deploy infrastructure with Bicep, the script deploys three AKS clusters when set using the default arguments.
- AKS
- VNET
- Log Analytics workspace
- App Insights component
- Envoy reverse proxy
- DNSMasq sample DNS server
-
Download AKS credentials.
-
Install core infrastructure on each AKS cluster: Envoy proxy and CoreDNS customization.
-
Install Dapr with Helm in AKS on two of the clusters (level 4 and level 2 of the network topology).
-
Install Mosquitto with Helm in each AKS cluster, including bridging from each lower broker to the level above.
-
Provision Azure application resources (ACR, Event Hubs, Storage).
-
Use
az acr build
to build and push images to the ACR. -
Install our sample components with Helm in AKS, splitting some of the application workloads to run on Level 2, and the cloud connected workload on Level 4.
- Level 4: Data gateway workload reading messages from the local MQTT broker and pushing them to Event Hubs through Dapr pubsub component.
- Level 2: Simulated Temperature Sensor, OPC PLC Simulator and OPC Publisher user Dapr to publish messages to the local MQTT broker.
To validate the deployment of the default resources and sample workloads you can validate a few things.
-
In Azure Portal:
- Review the new resource groups and their configuration. The resource groups will all be prefixed with the
ApplicationName
you supplied when running the script. - Go to the Azure Event Hub in the
<ApplicatioName>-App
resource group. Verify the Messages are being received by viewing the Metrics section of the Event Hub. Alternatively you can use a tool like ServiceBusExplorer to view messages being received and their contents.
- Review the new resource groups and their configuration. The resource groups will all be prefixed with the
-
In your terminal, use
kubectl
commands to review deployed workloads:- Connect to the desired AKS cluster by running
az aks get-credentials --resource-group <ApplicationName>L4 --name aks-<ApplicationName>L4
(L4
can be replaced byL3
orL2
). - Connect to L4 cluster and run the following command to see messages are being published to Event Hubs:
- Get the pods in
kubctl get pods -n edge-app1
- Get the logs for the Data Gateway module:
kubectl logs -l app=data-gateway-module -n edge-app1
. You should see some logs about messages published.
- Get the pods in
- You can also further view other workloads by reviewing deployments in the namespaces
edge-core
,edge-infra
andazure-arc
. - Connect to the L2 cluster and review the application (and their logs) deployed to
edge-app1
namespace.
- Connect to the desired AKS cluster by running
Subsequent deployments with new container images and Helm chart upgrades can be ran as follows:
Note
<resource-group-with-acr>
refers to the Resource Group with the<short-name>
appended with-App
.
In case you deployed the default developer environment with 3 layers (default):
./build-and-deploy-images.ps1 -AppResourceGroupName <resource-group-with-acr> -L4ResourceGroupName <resource-group-L4-cluster> -L2ResourceGroupName <resource-group-L2-cluster>
In case you deployed a developer environment with one single layer and cluster (you edited the deploy-az-dev-bootstrapper.ps1
script):
./build-and-deploy-images.ps1 -AppResourceGroupName <resource-group-with-acr> -L4ResourceGroupName <resource-group-with-acr> -L4ResourceGroupName <resource-group-L4-cluster>
To remove all Azure resources setup by the default script (AKS clusters, app resources and service principals), run the following from the deployment
folder:
./cleanup-az-resources.ps1 -ApplicationName <short-name>
The deployment script also has an option to deploy a single layer of AKS and networking infrastructure. To use the single deployment version, uncomment the second section in the deploy-az-dev-bootstrapper.ps1
. Instructions can be found in the comments of the script.
Follow a similar approach for removing resources in nested deployments. cleanup-az-resources.ps1
also has commented sections to delete the single layer resources.