This repository is part of the presentation "TFTEC AO VIVO EM SÃO PAULO 2024". For more information about the event, please visit here.
- Azure Cloud Subscription
- Azure Devops
- Course Github Repositories
- Basic infrastructure created in the previous lab: Azure Kubernetes Service with Azure DevOps and Terraform
- Azure CLI
- Kubernetes kubectl tool
Create a new repository in the training project with the suggested name: tftec-app
.
Go to Pipeline > Library and add Variable group:
Variable group name: tftec-app-vars
Variable | Value |
---|---|
dockerfilePath | docker/Dockerfile |
HelmRepoName | helm-chart/ao-vivo-sp-24 |
imageRepository | image/ao-vivo-sp-24/tftec-app |
tag | $(Build.BuildId) |
Click Project settings > Pipelines > Service connections > New service connection.
Create the Kubernetes service connection:
Select Kubernetes > next > select the subscription.
For Service connection name: tftec-kubernetes
Check Grant access permission to all pipelines and save.
Crie a service connection do Azure Container Registry:
Selecione Docker Registry > next > Azure Container Registry.
Authentication Type: Service Principal
> selecione a assinatura.
Service connection name: tftec-registry
Check Grant access permission to all pipelines and save.
Build pipeline:
Access the yaml file and make changes according to your environment in the settings marked with MODIFICAR
.
Build pipeline:
Access the yaml file and make changes according to your environment in the settings marked with MODIFICAR
.
Build pipeline:
Pipelines > New pipeline > Azure Repos Git > <repo_name> > Existing Azure Pipelines YAML file > Branch main > path /cicd/stages/stages-build.yml > continue > rename to tftec-app-build
> save.
Deploy pipeline:
Pipelines > New pipeline > Azure Repos Git > <repo_name> > Existing Azure Pipelines YAML file > Branch main > path /cicd/stages/stages-deploy.yml > continue > rename to tftec-app-deploy
> save.
Run the tftec-app-build
build pipeline after success, collect build release information from Azure Container Registry, image
and chart
.
With the information in hand, edit the build information in the stages-deploy.yml
pipeline, save it, and monitor the pipeline execution. If the pipeline is not triggered automatically, go to pipelines and manually run the pipeline tftec-app-deploy
.
Example:
- imageTag: 'latest'
- chartVersion: '657'
Access the AKS cluster via the Azure portal, click connect, select Azure CLI and follow the commands to log in, set up the subscription and download the credentials.
Test connectivity and list the nodes in your cluster:
kubectl get nodes
Confirm that the microservice objects have been created and are running perfectly.
kubectl get deployments
kubectl get services
kubectl get secrets
kubectl get pods
NOTE: If you do not have Azure CLO and kubectl installed on your machine, follow these steps:
Linux Way
1 - Download and install azcli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
2 - Download and install Kubectl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
Install kubectl:
sudo apt-get update
sudo apt-get install -y kubectl
Verify the installation:
kubectl version --client
Windows Way
1 - Download and install azcli
https://learn.microsoft.com/pt-br/cli/azure/install-azure-cli
2 - Download and install Kubectl (chocolatey)
https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/
Install Chocolatey (if it is not already installed). Open PowerShell as Administrator and run the command:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Install kubectl with Chocolatey:
choco install kubernetes-cli -y
Verify the installation:
kubectl version --client
Mac Way
Install Brew (if it is not already installed). Open terminal as Administrator and run the command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
1 - Install Azure CLI
brew update && brew install azure-cli
2 - Install kubectl with Brew
brew install kubectl
Verify the installation:
kubectl version --client
- Important Note: Please access this repository and FORK it and use them during the course.
This project is under MIT License.