|
| 1 | +# This repo is used for kubernetes learning |
| 2 | + |
| 3 | +## Origin |
| 4 | + |
| 5 | +Original article can be found in [Learn Kubernetes in Under 3 Hours: A Detailed Guide to Orchestrating Containers](https://medium.freecodecamp.org/learn-kubernetes-in-under-3-hours-a-detailed-guide-to-orchestrating-containers-114ff420e882) |
| 6 | + |
| 7 | +Original Repository can be found [here](https://github.com/rinormaloku/k8s-mastery) |
| 8 | + |
| 9 | +## What's new |
| 10 | + |
| 11 | +- Add kubernetes config at each repo (instead of gathering them) |
| 12 | +- Try to deploy on AWS EKS |
| 13 | +- Try advance features like logging or monitoring |
| 14 | +- Know how to develop at local |
| 15 | + |
| 16 | +## Application Demo |
| 17 | + |
| 18 | +The application takes one sentence as input, using Text Analysis, calculates the emotion of the sentence. |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +From the technical perspective, the application consists of three microservices. Each has one specific functionality: |
| 23 | + |
| 24 | +* SA-Frontend: a Nginx web server that serves our ReactJS static files. |
| 25 | +* SA-WebApp: a Java Web Application that handles requests from the frontend. |
| 26 | +* SA-Logic: a python application that performs Sentiment Analysis. |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +This interaction is best illustrated by showing how the data flows between them: |
| 31 | + |
| 32 | +1. A client application requests the index.html (which in turn requests bundled scripts of ReactJS application) |
| 33 | +2. The user interacting with the application triggers requests to the Spring WebApp. |
| 34 | +3. Spring WebApp forwards the requests for sentiment analysis to the Python app. |
| 35 | +4. Python Application calculates the sentiment and returns the result as a response. |
| 36 | +5. The Spring WebApp returns the response to the React app. (Which then represents the information to the user.) |
| 37 | + |
| 38 | +## Check each service |
| 39 | + |
| 40 | +### Front-end |
| 41 | + |
| 42 | +```javascript |
| 43 | +npm install |
| 44 | +npm start |
| 45 | +``` |
| 46 | + |
| 47 | +You should access it on localhost:3000 to take a look. Now make front-end production ready by: |
| 48 | + |
| 49 | +```javascript |
| 50 | +npm run build |
| 51 | +``` |
| 52 | + |
| 53 | +This generates a folder named build in your project tree, which contains all the static files needed for our ReactJS application. |
| 54 | + |
| 55 | +Next, let's dockerize front-end. |
| 56 | + |
| 57 | +```javascript |
| 58 | +docker build -f Dockerfile -t sa-frontend . |
| 59 | +docker run -d -p 80:80 sa-frontend |
| 60 | +``` |
| 61 | + |
| 62 | +You should be able to access the react application at `locahost:80` |
| 63 | + |
| 64 | +### Logic |
| 65 | + |
| 66 | +```javascript |
| 67 | + |
| 68 | +docker build -f Dockerfile -t sa-logic . |
| 69 | +docker run -d -p 5050:5000 sa-logic |
| 70 | +``` |
| 71 | + |
| 72 | +### Webapp |
| 73 | + |
| 74 | +```javascript |
| 75 | +bash build.bash |
| 76 | +docker build -f Dockerfile -t sa-webapp . |
| 77 | +docker run -d -p 8080:8080 -e SA_LOGIC_API_URL='http://<container_ip or docker machine ip>:5000' sa-webapp |
| 78 | +``` |
| 79 | + |
| 80 | +<container_ip or docker machine ip> can be found by using |
| 81 | + |
| 82 | +```javascript |
| 83 | +docker inspect <sa-logic-container-id> |
| 84 | +``` |
| 85 | + |
| 86 | +Now you get your microservices running: |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | +Try some sentences *I like it* to check if it works |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +If there are any issues, use `docker container logs` to check service. |
| 95 | + |
| 96 | + |
| 97 | +## Bring kubernetes to your application |
| 98 | + |
| 99 | +Check out this [post]() to have an overview of kubernetes architecture |
| 100 | + |
| 101 | +Our application in kubernetes could be organized like this: |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | +Deployment steps we will proceed include: |
| 109 | + |
| 110 | +* Install tools |
| 111 | +* Create and start a kubernetes cluster |
| 112 | +* Verify cluster |
| 113 | +* Deploy kubernetes dashboard |
| 114 | +* Access dashboard |
| 115 | +* Deploy service to cluster |
| 116 | +* Setup logging |
| 117 | +* View logs |
| 118 | +* .... |
| 119 | + |
| 120 | +### Install tools |
| 121 | + |
| 122 | +Since we will use EKS to deploy Kubernetes so you should have one with administration access. You also need fork the repo so you can have Github access token to setup CI/CD later. This part only focuses on deploy locally so having an ubuntu OS is enough ! |
| 123 | + |
| 124 | +* |
0 commit comments