Terraform Service Principal
You need a Service Principal to deploy your Terraform templates:
az ad sp create-for-rbac --name "terraform-sp" --role Contributor --scopes /subscriptions/<YOUR SUBSCRIPTION>
You’ll get a JSON output like this:
{
"appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"displayName": "terraform-sp",
"password": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
Key Values:
appId: This is the client_id.
password: This is the client_secret.
tenant: This is the tenant_id.
Installing Terraform
You can find the information on how you can install Terraform according to your operating system:
With “terraform plan” you can verify which resources will be created.
You can start deploying the resources with “terraform apply”
You can check the result on the Azure portal which will look like this:
You can delete your resources later with “terraform destroy”, when you finished using them.
Update your kubectl according to your cluster:
az aks get-credentials --resource-group aks-resource-group --name aks-cluster --overwrite-existing
You can deploy the Helm templates manually with the following command:
helm upgrade --install -f ./helm/helloworld/values.yaml helloworld ./helm/helloworld
After the deployment you can verify it in Azure:
If you check the LoadBalancer, you can verify if the application is runnnig correctly:
Deploying with Azure Pipeline
You can deploy the application with Azure DevOps pipeline as well:
The pipeline is using Snyk to scan the docker image. You can find the scan result on the Synk website or in the pipeline:
You can find the code on my github:
Comments