https://github.com/boweihan/kubernetes-setup
Setting up kubernetes...for science
https://github.com/boweihan/kubernetes-setup
Last synced: 2 months ago
JSON representation
Setting up kubernetes...for science
- Host: GitHub
- URL: https://github.com/boweihan/kubernetes-setup
- Owner: boweihan
- Created: 2018-11-25T16:28:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-26T16:22:12.000Z (over 6 years ago)
- Last Synced: 2025-01-31T09:45:42.262Z (4 months ago)
- Language: JavaScript
- Size: 41.4 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kubernetes
This repo will deploy three 'microservices'
1) ReactJS front end
* docker run -d -p 80:80 boweihan/sentiment-analysis-frontend
2) Java web application
* docker run -d -p 8080:8080 -e SA_LOGIC_API_URL='http://:5000' boweihan/sa-webapp
3) Python sentiment analysis application
* docker run -d -p 5000:5000 boweihan/sa-logic
### Contents
* Build / package and run ReactJS, Java and Python applications
* building and publishing docker containers with Dockerfiles to container registry
* Kubernetes - Pods, Services, Deployments, Zero-downtime deployments, Scaling
* Migrate microservice application to kubernetes cluster### Running in minikube
```
minikube startkubectl create -f resource-manifests/sa-frontend-pod.yaml
kubectl port-forward sa-frontend 80:80
kubectl get podsDEPLOY WEB ON ANOTHER POD
sudo kubectl create -f resource-manifests/sa-frontend-pod2.yaml
kubectl get podsCREATE SERVICE FOR FRONTENDS
kubectl create -f resource-manifests/service-sa-frontend-lb.yaml
kubectl get svcTO RUN THE LOAD BALANCED APPLICATION
kubectl get svcCREATE A DEPLOYMENT INSTEAD OF TWO SEPARATE PODS
kubectl apply -f resource-manifests/sa-frontend-deployment.yamlDELETE THE OLD PODS
kubectl delete pod sa-frontend
kubectl delete pod sa-frontend2*** IF YOU DELETE A DEPLOYMENT POD NOW IT WILL BE RECREATED ***
DEPLOY A NEW GREEN IMAGE (--record=true will create a history description)
kubectl apply -f resource-manifests/sa-frontend-deployment-green.yaml --record=trueCHECK DEPLOYMENT ROLLOUT
kubectl rollout status deployment sa-frontendLIST DEPLOYMENT HISTORY
kubectl rollout history deployment sa-frontendROLLBACK TO REVISION 1
kubectl rollout undo deployment sa-frontend --to-revision=1DEPLOY PYTHON SERVICE (labelled with sa-logic)
kubectl apply -f sa-logic-deployment.yaml --recordCREATE SERVICE THAT ACTS AS AN ENTRY POINT FOR PYTHON APP
kubectl apply -f service-sa-logic.yaml*** SERVICES ARE EXPOSED VIA kube-dns so you can access via http://sa-logic ***
DEPLOY JAVA WEB APP
kubectl apply -f sa-web-app-deployment.yaml --recordCREATE SERVICE AS ENTRY POINT FOR JAVA APP
kubectl apply -f service-sa-web-app-lb.yamlUPDATE THE FRONT END TO POINT TO JAVA SERVICE INSTEAD OF LOCALHOST:8000
minikube service list (get the IP of sa-web-app-lb)
modify App.js
npm run build
docker build -f Dockerfile -t $DOCKER_USER_ID/sentiment-analysis-frontend:minikube .
docker push $DOCKER_USER_ID/sentiment-analysis-frontend:minikube
kubectl apply -f sa-frontend-deployment.yamlSERVE WITH NGROK TO THE PUBLIC
./ngrok http $DEPLOYMENT_IP:$DEPLOYMENT_PORT```