Skip to content

the-gophers/cloud-native-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cloud Native Go

1. Cloud Native Go with Azure Kubernetes Service (AKS), KEDA + KEDA HTTP Addon

Walkthrough (vimeo.com)

In this lab you will deploy an Azure Kubernetes Service (AKS) cluster and other Azure services (Container Registry, Managed Identity, Storage Account, Service Bus, Key Vault), the open source KEDA (Kubernetes Event-driven Autoscaling) project, the KEDA HTTP Addon (kedacore/http-add-on) with Azure CLI and Bicep. You will then deploy a sample Go application, go-hello, to your cluster using kubectl and kustomization.

Requirements

Instructions

  1. Use the Azure CLI and Bicep templates to deploy the infrastructure for your application.

    # login to the azure cli
    az login
    
    # if you need kubectl, install it
    az aks install-cli
    
    # 01-aks/
    cd 01-aks
    bash deploy-main.sh

    You can optionally deploy an Azure Key Vault. This template is deployed in incremental mode.

    # 01-keyvault/
    cd 01-keyvault
    bash deploy-group.sh
  2. Use another Bicep template to run a Deployment Script that runs inside a container and installs the following on your AKS cluster.

    # 01-deploy-script/
    cd 01-deploy-script
    bash deploy-group.sh
  3. (Optional) Step 2 uses the bash scripts in 02-keda-http to install the dependencies. If you prefer, you can run these manually at any time via up.sh or down.sh.

    # 02-keda-http/
    cd keda-http
    
    # install
    bash up.sh
    
    # uninstall
    bash down.sh
    
    # authenticate
    bash auth.sh
  4. Use the kubectl CLI tool and kubectl apply -k (via kustomize) to deploy a pre-built container hello container image of our go-hello sample application.

    # 03-app/
    cd 03-app
    
    # (optional) run "az aks get-credentials" using the script mentioned in step 3.
    # bash ../02-keda-http/auth.sh
    
    # base
    kubectl apply -k ./base
    
    # keda-http
    # edit: my-image/kustomization.yaml
    # replace "host: 52.151.224.146" with the ip of your ingress controller
    kubectl apply -k ./keda-http
    
    # my-image
    # edit: my-image/kustomization.yaml
    # replace "newName: acrjxasx2.azurecr.io/asw101/test" with the name of your image, and "newTag" with the tag of your image, as applicable
    kubectl apply -k ./my-image

    You may now test and/or load test your application using curl or hey, and monitor it using kubectl or k9s. See 03-app/README.md for sample snippets.

  5. Build the go-hello sample app, using a distroless container image, and deploy it from your own container registry.

    # go-hello/
    cd go-hello
    
    # build locally
    bash do/docker-build.sh
    
    # build locally using buildx (e.g. Apple Silicon/M1)
    bash do/docker-buildx.sh
    
    # login to github container registry
    bash do/ghcr-login.sh
    
    # push to github container registry, replace 'asw101' with your GH user
    export OWNER='asw101'
    export IMAGE='test'
    export TAG='latest'
    
    bash do/ghcr-push.sh
    
    # build with azure container registry
    bash do/acr-build.sh

What's next?

Try our Cloud Native labs in Azure Open Source Labs (aka.ms/oss-labs) for Serverless Containers, KEDA, Dapr and more.