Demo microservices architecture with kubernetes
Different networking options within Docker:
-
Default docker bridge via docker 0 In a host: eth0 -- IP Tables/NAT -- Docker 0 -- container 1
\ container 2 -
User defined bridges to isolate containers in the same host In a host: eth0 -- IP Tables/NAT -- Brnet1 -- container 1
\ Brnet2 -- container 2 -
Overlay Network In host 1: eth0 -- IP Tables/NAT -- Docker 0 -- container 1
\ overlay(for containers to talk across multi hosts without NAT) / / In host 2: eth0 -- IP Tables/NAT -- Docker 0 -- container 2
Why do we need Docker?
- Faster development process
- Application encapsulation
- The same behaviour on local machine, dev, staging, production servers
- Easy and clear monitoring
- Easy to scale
To run web_server_hello via minikube:
-
Start minikube: minikube start --vm-driver=vmwarefusion
-
Set docker env: eval $(minikube docker-env)
-
Build image (go to ../b2bmicroservices/b2bhello/): docker build -t hello_image .
-
Run in minikube: kubectl run hello --image=hello_image --image-pull-policy=Never
-
Check that it's running: kubectl get pods
-
Check for output via logs: kubectl logs {pod-name} Note: get {pod-name} from 5)
To run web_server_bye via minikube:
-
Start minikube: minikube start --vm-driver=vmwarefusion
-
Set docker env: eval $(minikube docker-env)
-
Build image (go to ../b2bmicroservices/b2bbye/): docker build -t bye_image .
-
Run in minikube: kubectl run bye --image=bye_image --image-pull-policy=Never
-
Check that it's running: kubectl get pods
-
Check for output via logs: kubectl logs {pod-name} Note: get {pod-name} from 5)
To run web_server_hello nginx server via docker:
-
Go to ../b2bmicroservices/web_server_hello/examples/nginx
-
Execute command: docker run -it --name "test-nginx-hello" -p 8080:8080 -v $(pwd):/usr/share/nginx/html:ro nginx:latest /bin/bash
-
Inside shell, run: nginx -c /usr/share/nginx/html
-
Server is running now, go to localhost:8080/app1, and index.html will be served
To run web_server_bye nginx server via docker:
-
Go to ../b2bmicroservices/web_server_bye/examples/nginx
-
Execute command: docker run -it --name "test-nginx-bye" -p 8081:8080 -v $(pwd):/usr/share/nginx/html:ro nginx:latest /bin/bash
-
Inside shell, run: nginx -c /usr/share/nginx/html
-
Server is running now, go to localhost:8080/app2 on the web browser, and index.html will be served