Skip to content

thangchung/coffeeshop-on-dapr

Repository files navigation

coffeeshop-on-dapr

The .NET coffeeshop application runs on Dapr

Services

No. Service Name URI
1 product-service http://localhost:5001
2 counter-service http://localhost:5002
3 barista-service http://localhost:5003
4 kitchen-service http://localhost:5004
5 reverse-proxy http://localhost:8080

Featured technologies

Architecture

Pre-requisites

Get starting locally

> dapr init
> docker compose up 

Finally, you can play around using client.http to explore the application!

Make sure no redis, zipkin instances running

Get starting on Azure

  1. Ensure you have access to an Azure subscription and the Azure CLI installed

    az login
    az account set --subscription "My Subscription"
  2. Clone this repository

    git clone https://github.com/thangchung/coffeeshop-on-dapr.git
    cd coffeeshop-on-dapr
  3. Install KEDA extension

    Enable KEDA extension here

    az feature register --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview"
  4. Deploy the infrastructure

    az deployment sub create --location eastus --template-file ./iac/bicep/main.bicep
  5. Install Dapr extension

    Enable Dapr extension here

    az k8s-extension create --cluster-type managedClusters --cluster-name coffeeshop --resource-group azure_oss_rg --name dapr --extension-type Microsoft.Dapr
  6. Log into Azure Container Registry You can get your registry name from your resource group in the Azure Portal

    # enable admin login on Azure Portal
    docker login <registry_server_uri> -u <admin username> -p <password>

    For example: <registry_server_uri> looks like coffeeshopf2syic6ephtxk.azurecr.io

  7. Build and push containers

    Create an .env file at root project folder with content

    DOCKER_REGISTRY=<registry_server_uri>

    Then run docker-compose CLI as

    docker compose build
    docker push <registry_server_uri>/product-service:latest
    docker push <registry_server_uri>/counter-service:latest
    docker push <registry_server_uri>/barista-service:latest
    docker push <registry_server_uri>/kitchen-service:latest
    docker push <registry_server_uri>/reverse-proxy:latest
  8. Get AKS credentials

    az aks get-credentials --resource-group az_oss_rg --name coffeeshop

    Make sure when you go to Azure Portal, you should see keda and dapr components as the picture below

  9. Create dapr component on AKS

    kubectl apply -f iac/dapr/azure/orderup_pubsub.yaml
    kubectl apply -f iac/dapr/azure/barista_pubsub.yaml
    kubectl apply -f iac/dapr/azure/kitchen_pubsub.yaml
  10. Deploy the application

    az deployment group create --resource-group az_oss_rg --template-file ./iac/bicep/app.bicep
  11. Get your frontend URL

    kubectl get ingress

    For example,

    NAME CLASS HOSTS ADDRESS PORTS AGE
    reverseproxy app.5cde744b1d1242ffbc32.eastus.aksapp.io 20.241.232.155 80 13m
  12. Navigate to client.http, and change @host to what you can see on previous command, for example: app.5cde744b1d1242ffbc32.eastus.aksapp.io, then play with REST APIs there. Enjoy!

Clean up

az group delete -n az_oss_rg

Credits