Neste artigo, teremos foco nas configurações necessárias para rodar DAPR, KEDA on ARO (Azure RedHat OpenShift).
Desta forma, aproveitei para montar este repositório no GitHub chamado "App-Plant-Tree" que cobre conceitos sobre Arquitetura Cloud-Native combinando as seguintes tecnologias:
Login no Azure usando CLI:
az login
Defina os valores das variáveis conforme seu ambiente:
- $SubscriptionID = ''
- $Location = ''
- $ResourceGroupName = ''
- $ClusterName = ''
- $ContainerRegistryName = ''
- $ServiceBusNamespace = ''
Selecione sua assinatura azure:
az account set --subscription $SubscriptionID
Crie resource group:
az group create --name $ResourceGroupName --location $Location
Crie a virtual network
az network vnet create --address-prefixes 10.0.0.0/22 --name "$ClusterName-vnet" --resource-group $ResourceGroupName
Crie a subnet para control plane
az network vnet subnet create --resource-group $ResourceGroupName --vnet-name "$ClusterName-vnet" --name "$ClusterName-control-plane-subnet" --address-prefixes 10.0.0.0/23
Crie a subnet para workers
az network vnet subnet create --resource-group $ResourceGroupName --vnet-name "$ClusterName-vnet" --name "$ClusterName-worker-subnet" --address-prefixes 10.0.2.0/23
Desligando configurações de network policies para Private Link Service
az network vnet subnet update --name "$ClusterName-control-plane-subnet" --resource-group $ResourceGroupName --vnet-name "$ClusterName-vnet" --disable-private-link-service-network-policies true
Crie o cluster ARO:
az aro create --resource-group $ResourceGroupName --name $ClusterName --vnet "$ClusterName-vnet" --master-subnet "$ClusterName-control-plane-subnet" --worker-subnet "$ClusterName-worker-subnet"
Crie o Container Registry:
az acr create --name $ContainerRegistryName --resource-group $ResourceGroupName --sku basic
Conectando o Container Registry ao ARO:
az acr credential show -n $ContainerRegistryName
oc create secret docker-registry --docker-server=$ContainerRegistryName.azurecr.io --docker-username=<user name> --docker-password=<your password>--docker-email=unused acr-secret
oc secrets link default <pull_secret_name> --for=pull
Pegue a URL da console OpenShift
az aro show --name $ClusterName --resource-group $ResourceGroupName -o tsv --query consoleProfile
Pegue as credenciais OpenShift:
az aro list-credentials --name $ClusterName --resource-group $ResourceGroupName -o tsv
Valide a conexão com o cluster:
kubectl cluster-info
Adicione as referências:
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
helm upgrade --install dapr dapr/dapr --namespace dapr-system --create-namespace
helm upgrade --install dapr-dashboard dapr/dapr-dashboard --namespace dapr-system --create-namespace
Validar se os pods estão rodando:
kubectl get pods -n dapr-system
dapr dashboard -k
Resposta esperada:
DAPR dashboard found in namespace: dapr-system
DAPR dashboard available at http://localhost:8080
Adicione as referências:
helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm upgrade --install keda kedacore/keda -n keda-system --create-namespace
helm upgrade --install keda-add-ons-http kedacore/keda-add-ons-http -n keda-system --create-namespace
Verifique se os pods estão rodando:
kubectl get pods -n keda-system
Neste projeto, temos 3 diferentes opções exemplificadas (escolha uma):
az acr login --name $ContainerRegistryName
docker build -t "$ContainerRegistryName.azurecr.io/consumer-app:1.0.0" -f cmd/consumer/dockerfile .
docker build -t "$ContainerRegistryName.azurecr.io/producer-app:1.0.0" -f cmd/producer/dockerfile .
docker push "$ContainerRegistryName.azurecr.io/consumer-app:1.0.0"
docker push "$ContainerRegistryName.azurecr.io/producer-app:1.0.0"
helm upgrade --install app .helmcharts/app -n tree --create-namespace
Validar se os pods estão rodando:
kubectl get pods -n tree
# validar Logs
kubectl logs -f -l app=consumer1 --all-containers=true -n tree
# configurar a porta para acesso local
kubectl port-forward pod/producer1 8081 8081 -n tree
# enviar post para a aplicação producer
- POST -> http://localhost:8081/plant
- Json Body: {"numberOfTrees":100}
# Validar status dos pods
kubectl get pod -l app=consumer1 -n tree
Após finalizar seus testes, os próximos comandos te ajudarão a desinstalar todos os componentes de aplicação além de também excluir todos os componentes na azure.
helm uninstall app -n tree
helm uninstall keda-add-ons-http -n keda-system
helm uninstall keda -n keda-system
helm uninstall dapr -n dapr-system
Delete all Azure resources:
az aro delete --resource-group $ResourceGroupName --name $ClusterName
az acr delete --resource-group $ResourceGroupName --name $ContainerRegistryName
az group delete --name $ResourceGroupName
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.