Git Product home page Git Product logo

kubernetes-cluster-01's Introduction

Deploy microservice to GKE (Google Kubernetes Engine)

Key features of GCP - Google Kubernetes Engine (GKE)

- Orchestration

- Auto Scaling - Scale containers based on demand

- Service Discovery - Help microservices find one another

- Load Balancer - Distribute load among multiple instances of a microservice

- Self Healing - Do health checks and replace failing instances

- Zero Downtime Deployments - Release new versions without downtime

1. Start Docker Container:

  1. You can pull docker image to your OWN local machine

    -Exchange microservice 
    
    docker pull jamesfloatingmarket1508/mss-currency-exchange-k8s:0.0.11-SNAPSHOT
    
    - Conversion microservice
    docker pull jamesfloatingmarket1508/mss-currency-conversion-k8s:0.0.11-SNAPSHOT
    
  2. Run docker containers in your local manchine by Docker Deamon, for testing before doing any deployment.

    docker run -p 8000:8000 jamesfloatingmarket1508/mss-currency-exchange-k8s:0.0.11-SNAPSHOT
    
    docker run -p 8100:8100 jamesfloatingmarket1508/mss-currency-conversion-k8s:0.0.11-SNAPSHOT
    
  3. Test command on local:

     curl http://localhost:8000/currency-exchange/from/USD/to/GBP
    
     curl  http://localhost:8100/feign/currency-conversion/from/USD/to/GBP/quanlity/70
    

2. Deploy manual or automatic Google Kubernetes Engine

Create trial Google Kubernetes Cluster

Screenshot 2023-06-28 at 14 52 06

Step 1: Make sure you have GCloud be installed in your PC.

https://cloud.google.com/sdk/docs/install

Step 2: Authentication with Google Account that has Kubernetes Cluster.

gcloud container clusters get-credentials {your cluster name} --zone us-central1-c --project {project id}

a) Manual:

a1) Exchange service

kubectl create deployment currency-exchange --image=jamesfloatingmarket1508/mss-currency-exchange-k8s:0.0.11-SNAPSHOT

kubectl expose deployment currency-exchange --type=LoadBalancer --port=8000
Screenshot 2023-06-28 at 15 00 40
Terminal run:  kubectl get service

Test again: curl http://EXTERNAL-IP:port/currency-exchange/from/USD/to/GBP

Public IP: curl http://34.31.250.64:8000/currency-exchange/from/USD/to/GBP

a2) Conversion service

kubectl create deployment currency-conversion --image=jamesfloatingmarket1508/mss-currency-conversion-k8s:0.0.11-SNAPSHOT

kubectl expose deployment currency-conversion --type=LoadBalancer --port=8100

curl http://35.202.191.27:8100/feign/currency-conversion/from/USD/to/GBP/quanlity/123

b) How about deploy automatic by yaml file to Google Kubernetes Engine Open Terminal

Step 1)

 cd to exchange-currency-k8s directory
 kubectl apply -f deployment.yaml
Screenshot 2023-06-28 at 15 16 44

Step 2)

cd to conversion-currency-k8s directory
kubectl apply -f deployment.yaml
Screenshot 2023-06-28 at 16 19 50

You need to run metric server to make below commands working with correct data:

kubectl get hpa

kubectl top node

kubectl top pods

kubectl get pods --all-namespaces

Make GKN scale to 10 pods

  • Stress test ping API every 0.01 second to make the CPU usage hits 20%

    watch -n 0.01  curl http://35.202.191.27:8100/feign/currency-conversion/from/USD/to/GBP/quanlity/123
    
    watch -n 0.01  curl http://35.202.191.27:8100/feign/currency-conversion/from/USD/to/GBP/quanlity/456
    
    watch -n 0.01  curl http://35.202.191.27:8100/feign/currency-conversion/from/USD/to/GBP/quanlity/789
    
Screenshot 2023-06-28 at 16 28 02

How to trace log at CLuster Engine

Screenshot 2023-06-28 at 16 45 25 Screenshot 2023-06-28 at 16 58 39

Auto Scaling down to default replica set 1. Screenshot 2023-06-28 at 16 59 16

kubernetes-cluster-01's People

Contributors

lebronjamesuit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.