DEV Community

Thang Chung
Thang Chung

Posted on

5 2 1 1 1

How to build and run SpinApp on Azure Kubernetes Services (AKS) with SpinKube in 3 steps

This tutorial guides you to run SpinApp on AKS with SpinKube in just 3 simple steps.


Let's get started.

Step 1: Create AKS cluster

az login --use-device-code
az account set --subscription <your subscription id>
az account show
Enter fullscreen mode Exit fullscreen mode

Now you are ready to create the AKS cluster as below:

az group create --name globalazure24 --location southeastasia

az aks create \
  --resource-group globalazure24 \
  --name spinkube-aks \
  --node-count 1
  --generate-ssh-keys

az aks get-credentials --resource-group globalazure24 --name spinkube-aks
Enter fullscreen mode Exit fullscreen mode

Step 2: Install Spinkube on AKS

# SpinKube needs cert-manager for provisioning and managing TLS certificates that are used by the admission webhook system of the Spin Operator
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.14.4/cert-manager.crds.yaml

# Add Helm repositories jetstack and KWasm
helm repo add jetstack https://charts.jetstack.io
helm repo add kwasm http://kwasm.sh/kwasm-operator

# Update Helm repositories
helm repo update

# Install cert-manager using Helm
helm install \
  cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --create-namespace \
  --version v1.14.4

# Install KWasm operator
helm install \
  kwasm-operator kwasm/kwasm-operator \
  --namespace kwasm \
  --create-namespace \
  --set kwasmOperator.installerImage=ghcr.io/spinkube/containerd-shim-spin/node-installer:v0.13.1

# For demo, making all nodes can run wasm workload, kwasm-operator will create containerd-shim-spin on these nodes 
kubectl annotate node --all kwasm.sh/kwasm-node=true

kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.runtime-class.yaml

kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.crds.yaml

kubectl apply -f https://github.com/spinkube/spin-operator/releases/download/v0.1.0/spin-operator.shim-executor.yaml
Enter fullscreen mode Exit fullscreen mode

Step 3: Build and run SpinApp on AKS

git clone https://github.com/thangchung/coffeeshop-on-spinkube

git checkout feat/global-azure-2024

cd coffeeshop-on-spinkube/product-api

export IMAGE_NAME=ttl.sh/coffeeshop-product-api-spin:24h

spin registry push --build $IMAGE_NAME

spin kube scaffold -f $IMAGE_NAME > app.yaml

kubectl apply -f app.yaml
Enter fullscreen mode Exit fullscreen mode

Now you're ready to curl:

curl http://localhost/v1-get-items-by-types/1,2,3 | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   280    0   280    0     0   2788      0 --:--:-- --:--:-- --:--:--  2800
[
  {
    "image": "img/COFFEE_BLACK.png",
    "item_type": "CoffeeBlack",
    "name": "COFFEE_BLACK",
    "price": 3
  },
  {
    "image": "img/COFFEE_WITH_ROOM.png",
    "item_type": "CoffeeWithRoom",
    "name": "COFFEE_WITH_ROOM",
    "price": 3
  },
  {
    "image": "img/ESPRESSO.png",
    "item_type": "Espresso",
    "name": "ESPRESSO",
    "price": 3.5
  }
]
Enter fullscreen mode Exit fullscreen mode

Happy hacking SpinKube on AKS!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (2)

Collapse
 
matei_radu profile image
Radu Matei

This is great, thanks for putting it together, @thangchung !

FYI I tried cloning the repo from github.com/thangchung/coffeeshop-o... and it's private.

Collapse
 
thangchung profile image
Thang Chung

Hi Radu. Thanks because you like it.

Sorry, I forgot to do it. It's public now and I also update the post.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay