diff --git a/README.md b/README.md index 669645f..31b270c 100755 --- a/README.md +++ b/README.md @@ -198,20 +198,20 @@ We cover a wide range of DevOps topics in our content library, explore them unde Architecture architecture 📖 architecture/README.md - ⏩ coming-soon - - - - Packer - coming-soon - 📖 www.packer.io - ⏩ coming-soon + ✔️ Architecture Microservices microservices 📖 aws/microservices + ✔️ basic demo + + + + Packer + coming-soon + 📖 www.packer.io ⏩ coming-soon diff --git a/topics/microservices/README.md b/topics/microservices/README.md index 1191034..bf7ba08 100644 --- a/topics/microservices/README.md +++ b/topics/microservices/README.md @@ -9,3 +9,7 @@ - Microservices architecture design: https://learn.microsoft.com/en-us/azure/architecture/microservices/ - aks-microservices: [aks-microservices](https://learn.microsoft.com/en-us/azure/architecture/reference-architectures/containers/aks-microservices/aks-microservices) - https://dotnet.microsoft.com/en-us/learn/aspnet/microservices-architecture + +## Hands-on +### Basics +- Checkout [basic](./basic/) content \ No newline at end of file diff --git a/topics/microservices/assets/first-demo-microservices-result.png b/topics/microservices/assets/first-demo-microservices-result.png new file mode 100755 index 0000000..48b42c1 Binary files /dev/null and b/topics/microservices/assets/first-demo-microservices-result.png differ diff --git a/topics/microservices/basic/README.md b/topics/microservices/basic/README.md new file mode 100644 index 0000000..43bc09a --- /dev/null +++ b/topics/microservices/basic/README.md @@ -0,0 +1,36 @@ +# Demo microservices + +- Using GCP demo: https://github.com/GoogleCloudPlatform/microservices-demo +- Manifest: https://github.com/GoogleCloudPlatform/microservices-demo/blob/main/release/kubernetes-manifests.yaml + +## 1. Provision K8s cluster + +- Find the installation via [k8s](../../k8s/) content + +## 2. Run hello microservices script + +Prerequisite: + +- A k8s cluster up and running (step 1) + +Run: + +```bash +./hello-microservices.sh +``` + +This will deploy the application then forward the service to port `8080` (or you could adjust to another port works with you machine) + +## 3. Check the result + +Visit localhost:8080, you should get the similar result like this: + +![first-demo-microservices-result](../assets/first-demo-microservices-result.png) + +## 4. Cleanup + +Run: + +```bash +./cleanup-hello-microservices.sh +``` diff --git a/topics/microservices/basic/cleanup-hello-microservices.sh b/topics/microservices/basic/cleanup-hello-microservices.sh new file mode 100755 index 0000000..fe56110 --- /dev/null +++ b/topics/microservices/basic/cleanup-hello-microservices.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +NAME_SPACE="demo-app" + +kubectl delete namespace $NAME_SPACE diff --git a/topics/microservices/basic/hello-microservices.sh b/topics/microservices/basic/hello-microservices.sh new file mode 100755 index 0000000..0d8a7eb --- /dev/null +++ b/topics/microservices/basic/hello-microservices.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +console_log() { + echo ">>> [Microservices] $1" +} + +# Variables +NAME_SPACE="demo-app" + +# Deploy +console_log "Deploying the services" +console_log "NAME_SPACE: $NAME_SPACE" + +if kubectl get namespace "$NAME_SPACE" &>/dev/null; then + console_log "Namespace $NAME_SPACE already exists." +else + console_log "Namespace $NAME_SPACE does not exist. Creating..." + kubectl create namespace "$NAME_SPACE" +fi + +kubectl apply -n $NAME_SPACE -f https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/main/release/kubernetes-manifests.yaml +kubectl get pods -n $NAME_SPACE + +# Wait for services up +console_log "Waiting for all services are up. Sleeping 120s..." +# sleep 120 + +console_log "Checking all resouces in namespace '$NAME_SPACE'" +kubectl get all -n $NAME_SPACE + +console_log "Checking pods" +kubectl get pods -n $NAME_SPACE + +# Port forward +console_log "Forward the 'service/frontend' service" +## NOTE: You can change the '8080' port to whatever works on your machine +kubectl port-forward service/frontend -n $NAME_SPACE 8080:80 + +# Access the application +## Visit http://localhost:8080 to check your application +