Git Product home page Git Product logo

kubernetes-starter-coffee-app's Introduction

Coffee Application

Creating Deployments and Services via YAML configuration files

$ kubectl apply -f coffee-app.yaml
$ kubectl apply -f order-api.yaml

Access Kubernetes Dashboard

$ kubectl proxy &
// port defaults to 8001
// add -p [port-number] to specify which port to run the proxy
// e.g. kubectl proxy -p 8080 &

Access the Kubernetes Dashboard on http://localhost:8001/ui

Exposing and Accessing Application

The application is exposed through the service configuration in the yaml files.
There are 2 ways to access the application.

  • Access via NodePort You will need your worker IP address and NodePort of the service

    Worker IP address:

    $ bx cs workers [cluster-name]
    OK
    ID                                                 Public IP      Private IP       Machine Type   State    Status   Version   
    kube-dal10-crbbdb1ff6a36846e9b2dfb522a07005af-w1   169.60.123.123   10.177.184.196   b1c.16x64      normal   Ready    1.7.4_1502*   
    

    NodePort:

    $ kubectl get svc
    NAME         CLUSTER-IP       EXTERNAL-IP     PORT(S)          AGE
    coffee-app   172.21.108.170   169.46.321.321   3000:30080/TCP   1h
    order-api    172.21.57.151    169.46.322.322   3001:30081/TCP   39m
    

    You will access the sample app through http://169.60.123.123:30080

  • Access via LoadBalancer

    You can get the external IP through:

    $ kubectl get svc
    NAME         CLUSTER-IP       EXTERNAL-IP     PORT(S)          AGE
    coffee-app   172.21.108.170   169.46.321.321   3000:30080/TCP   1h
    order-api    172.21.57.151    169.46.322.322   3001:30081/TCP   39m
    

    You will access the sample app through http://169.60.321.321:3000

Scaling the Deployment

Scaling the coffee-app frontend

$ kubectl scale deploy coffee-app --replicas=2
kubectl get deployment "coffee-app" scaled

Scaling the order-api backend

$ kubectl scale deploy order-api --replicas=2
kubectl get deployment "order-api" scaled

You can scale up or down by specifying the number of replicas.

Horizontal Pod Autoscaler

$ kubectl autoscale deployment coffee-app --cpu-percent=20 --min=1 --max=10
$ kubectl autoscale deployment order-api --cpu-percent=20 --min=1 --max=10

// Send load to the backend
//Ctrl + C to cancel
while true; do curl -X POST -H 'Content-Type: application/json' -d '{ "mocha": "1", "americano": "2", "espresso": "3", "latte": "4", "machhiato": "5" }' http://169.46.322.322:3001/process_order; done

// Send load to the frontend
//Ctrl + C to cancel
while true; do curl -s http://169.46.74.114:3000 > /dev/null; done

// Send load to frontend then ordering
//Ctrl + C to cancel
while true; do curl -X POST -H 'Content-Type: application/json' -d '{ "mocha": "1", "americano": "2", "espresso": "3", "latte": "4", "machhiato": "5" }' http://169.46.74.116:3000/order; done

Debugging the Application

To view the logs in a pod

$ kubectl logs [pod-name]
or if you have multiple containers in a pod
$ kubectl logs [pod-name] -c [container-name]

To execute a command in a pod

$ kubectl exec [options] [pod-name]
e.g. kubectl exec -ti coffee-app-1522168388-6v3nj /bin/sh
i option allows stdin to the container and t option makes it a tty
This will execute /bin/sh in the container

Deletion of resources

$ kubectl delete -f coffee-app.yaml
$ kubectl delete -f order-api.yaml
$ kubectl delete hpa coffee-app order-api

kubernetes-starter-coffee-app's People

Contributors

anthonyamanse avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

essodevops

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.