-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Microservices: add hands on script (#623)
- Loading branch information
Showing
6 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
NAME_SPACE="demo-app" | ||
|
||
kubectl delete namespace $NAME_SPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|