InterviewSolution
| 1. |
Explain Docker Orchestration |
|
Answer» As the number of docker machines increases, there needs to be a system to manage them all. Docker Orchestration is a virtual docker MANAGER and allows us to start, stop, pause, unpause or kill the docker nodes(machines). Docker has an in-built utility called “docker swarm”. Kubernetes is another popular and versatile docker orchestration system used. A CLUSTER of dockers is called a ‘swarm’. Swarm turns a collection of docker engines into a single virtual docker engine. In a swarm orchestration arrangement, one machine acts as a swarm manager that controls all the other machines connected to the cluster that acts as swarm nodes. This is how I created a swarm of dockers and managed them on my machine: We need docker services and docker machines to run these services on.Finally, we need a docker swarm to manage the docker nodes/machines
Create a docker swarm and manage the services on different nodes and port numbers.
Step 1: Create docker machines: manager, node1, node2, node3, node4 docker-machine create --driver virtualbox manager docker-machine create --driver virtualbox node1 docker-machine create --driver virtualbox node2 docker-machine create --driver virtualbox node3 docker-machine create --driver virtualbox node4 --Every node is started as a virtualbox machine. --set docker machine ‘manager’ as active eval $(docker-machine env manager) --List the docker machinesStep 2: Create a docker swarm --Initialize a swarm and add ‘manager’ to the swarm cluster using its ip address: 192.168.99.100 Step 3: Add the nodes as workers(or another manager) to the swarm --Connect to each node and run the above swarm join command There can be more than one ‘manager’ node in a swarm --connect to node1 and join node1 to the swarm as a worker docker-machine ssh node1 --List the nodes connected in the swarm connect to manager node: $docker-machine ssh manager Step 4: From the ‘manager’ node create new docker services docker-machine ssh manager --Create service replicating them on more than 1 nodes and expose them on the mentioned port. This command pulls the docker image from docker hub. Step 5: list the docker services created also use -ps flag to view the node machines these services are running on. --List the services that will be shared among different swarm nodes
Swarm randomly assigns nodes to the running services when we replicate the services. --service ‘httpd’ running on 3 nodes: node1, node2 and node3
--service ‘couchbase’ is running on 2 nodes: node1 and manager at port: 8091 --’couchbase’ service can be accessed via ‘node1’ (ip: 192.168.99.101) and ‘manager’ (ip: 192.168.99.100) at port : 8091 as show below
Screenshots of the running services: ‘manager’ node can create/inspect/list/scale or remove a service. Refer docker service --help Conclusion: A number of services are balanced over different nodes(machines) in a swarm cluster.A node declared as a ‘manager’ controls the other nodes.Basic ‘docker commands’ works from within a ‘manager’ node. |
|