Skip to content
This repository has been archived by the owner on Feb 9, 2023. It is now read-only.

Latest commit

 

History

History
executable file
·
205 lines (154 loc) · 6.77 KB

initial-setup.md

File metadata and controls

executable file
·
205 lines (154 loc) · 6.77 KB

Demo Install & Setup

There are 2 ways to use this demo. You can deploy backing Azure services and run the Java microservices locally. This allows for local development and debugging.

Additionally, you can deploy everything to Azure and the microservices will be fully deployed to Azure Spring Apps or AKS.

Instructions for both are below.

Initial Setup Steps

In this step, you will provision the Azure resources needed to support Red Dog Java. This includes: Event-Hubs, Azure MySQL, Azure Redis, CosmosDB, Azure OpenAI Service, Azure Service Bus, Azure Key Vault, Storage Account, etc.

This script will also deploy ASA, AKS, ARO if needed.

  • Update/create the config.json file (in the ./scripts directory)

    • The deploytarget setting determines if you will run local or use one of the Azure options

    • Your file should look like this:

      {
          "location":"eastus",
          "username": "shortname",
          "adminpassword": "replaceSecurePassword",
          "_comment1": "for deploy target one of: local, asa, aks, aro",
          "deploytarget": "local"
      }
  • Run intial deployment script

    cd scripts
    ./start.sh
  • Jump to the section below that matches your deployment

Local Deployment/Debugging

This deployment will require a bash shell of your choice. It will not work on Azure Cloud Shell.

  • Pre-requisites

  • Setup local env variables

    • Script creates an output with the variables needed. Source the file in your ./outputs directory

      export DEPLOY_UNIQUE_SUFFIX=12345
      source ./outputs/var-reddog-spring-$DEPLOY_UNIQUE_SUFFIX.sh
  • Run microservices

    • Start with the order-service

      cd order-service
      mvn clean package
      java -jar ./target/*.jar
    • Repeat for each of the other services:

      • accounting-service
      • makeline-service
      • loyalty-service
      • receipt-generation-service
      • virtual-worker
      • virtual-customer
  • Start the UI web app

Azure Kubernetes Service (AKS) Deployment

If you selected AKS as the deployment target, your terminal should have access to cluster and the apps were deployed via GitOps.

Review the pods deployed in the cluster and validate the application UI is functional.

Note: The manual steps for deploying the application in AKS are noted here: AKS Deployment Notes

Azure Spring Apps Deployment

Follow the steps below to deploy Red Dog to your Azure Spring Apps instance deployed in the previous step.

Note: These manual steps will be replaced with the Bicep script going forward.

  • Setup local env variables

    • From the root directory of the repo

    • Script creates an output with the variables needed. Source the file in your ./outputs directory

      export DEPLOY_UNIQUE_SUFFIX=12345
      source ./outputs/var-reddog-spring-$DEPLOY_UNIQUE_SUFFIX.sh
  • Deploy order-service:

    # Set variables as needed
    export RG=''
    export SPRING_CLUSTER=''
    export SERVICE_NAME='order-service'
    
    az spring app create \
        -n $SERVICE_NAME \
        -s $SPRING_CLUSTER \
        -g $RG \
        --runtime-version Java_17 \
        --assign-endpoint true \
        --cpu 2 \
        --memory 1Gi \
        --instance-count 1 \
        --env AZURECOSMOSDBURI=$AZURECOSMOSDBURI AZURECOSMOSDBKEY=$AZURECOSMOSDBKEY AZURECOSMOSDBDATABASENAME='reddog' KAFKASASLJAASCONFIG=$KAFKASASLJAASCONFIG KAFKABOOTSTRAPSERVERS=$KAFKABOOTSTRAPSERVERS KAFKASECURITYPROTOCOL='SASL_SSL' KAFKASASLMECHANISM='PLAIN' KAFKATOPICNAME='reddog' MYSQLURL=$MYSQLURL MYSQLUSER='reddog' MYSQLPASSWORD=$MYSQLPASSWORD AZUREREDISHOST=$AZUREREDISHOST AZUREREDISPORT='6380' AZUREREDISACCESSKEY=$AZUREREDISACCESSKEY AZURESTORAGEACCOUNTNAME=$AZURESTORAGEACCOUNTNAME AZURESTORAGEACCOUNTKEY=$AZURESTORAGEACCOUNTKEY AZURESTORAGEENDPOINT=$AZURESTORAGEENDPOINT KAFKATOPICGROUP=$SERVICE_NAME KAFKA_CONSUMER_GROUP_ID=$SERVICE_NAME KAFKA_COMPLETED_ORDERS_TOPIC='make-line-completed'
    
    az spring app deploy \
        -s $SPRING_CLUSTER \
        -g $RG \
        --name $SERVICE_NAME \
        --source-path ./$SERVICE_NAME
    
    # Check apps and logs
    az spring app list -s $SPRING_CLUSTER -g $RG
    az spring app logs -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG --lines 1000
    az spring app logs -s $SPRING_CLUSTER -g $RG --lines 1000 -n order-service
    az spring app logs -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG -f # tail logs live
    
    # Delete if needed
    az spring app delete -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG
  • Deploy remaining microservices using the commands above. For each service, set the variable below and run the create/deploy commands.

    export SERVICE_NAME='loyalty-service'
    export SERVICE_NAME='makeline-service'
    export SERVICE_NAME='accounting-service'
    export SERVICE_NAME='virtual-worker'
    export SERVICE_NAME='virtual-customers'
    
    # for virtual customers, add this ENV VAR
    ORDER_SVC_URL=''
    
    # for virtual worker, add this ENV VAR 
    MAKELINE_SVC_URL=''
  • Deploy Dashboard UI (Custom Container) https://github.com/appdevgbb/reddog-ui-nextjs

    export SERVICE_NAME='dashboard'
    
    # set variables to URL for each service before running command
    az spring app create \
        -n $SERVICE_NAME \
        -s $SPRING_CLUSTER \
        -g $RG \
        --assign-endpoint true \
        --cpu 2 \
        --memory 1Gi \
        --instance-count 1 \
        --env PORT='1025' VIRTUAL_CUSTOMERS_URL='' ORDERS_URL='' ACCOUNTING_URL='' OPENAI_URL='' WORKER_URL=''
    
    az spring app deploy \
        -s $SPRING_CLUSTER \
        -g $RG \
        -n $SERVICE_NAME \
    --container-image chzbrgr71/reddog-dashboard:v1
  • Deploy OpenAI Neural Network service

    OpenAI Docs: https://learn.microsoft.com/en-us/azure/cognitive-services/create-account-bicep?tabs=CLI

    export SERVICE_NAME='openai-svc'
    
    az spring app create \
        -n $SERVICE_NAME \
        -s $SPRING_CLUSTER \
        -g $RG \
        --assign-endpoint true \
        --cpu 2 \
        --memory 1Gi \
        --instance-count 1 \
        --env OPENAI_API_BASE='' OPENAI_API_KEY=''
    
    az spring app deploy \
        -s $SPRING_CLUSTER \
        -g $RG \
        -n $SERVICE_NAME \
    --container-image chzbrgr71/reddog-openai-svc:v1