Docker – cluster
What is a Docker cluster
What is a cluster
1. Cluster your life first
2. Cluster in software
3, the final conclusion
Summary: A cluster is a collection of different service instances that provide services together
The cluster type
1, first look at two cluster examples: nginx cluster, Redis cluster
2. Then summarize
1. Symmetric clusters
Different service instances with equal functional status (each instance offers the same functional opportunity)
Positioning: data calculation
2. Asymmetric clusters
Different service instances with unequal functional status (each instance has a different opportunity to provide functionality)
Location: Data store
What is a Docker cluster
What do you think a Docker cluster is
conclusion
1. Docker clusters are unusual clusters
See the figure for analysis
Why use docker clusters
Docker cluster diagram to analyze, Docker inside the running container, if Docker down?
Docker container provides external access. If the number of visits is larger, the concurrency of a Docker is limited after all
Conclusion:
1. Single point of failure
2. Performance issues
So in order to solve these two problems, docker clusters appear
Docker cluster is implemented
1, the swarm
2, k8s
But we are only going to talk about swarm. Swarm is our choice today
Select reason
Docker swarm is an official cluster tool provided by Docker
2. K8s was developed by Google
3. K8s is difficult to understand and use
How does swarm manage docker clusters
Swarm is a swarm.
Swarm is like a subway ticket machine installer. Swarm is a subway ticket machine installer
Docker Swarm is a Docker cluster management tool. It turns the Docker host pool into a single virtual Docker host. Docker Swarm provides the standard Docker API, and all tools that already communicate with Docker daemons can be easily extended to multiple hosts using Swarm.
Swarm internal concept
1. Node
2. Task concept – Introduced later
3. The concept of Service – introduced later
4. Stack concept – Introduced later
The docker cluster is maintained by assigning roles to nodes
Node is the alias of docker, just like, we go to work, everyone has a work number, the work number is our alias, so node is the alias of Docker, but node has two types, manager and work, so docker is divided into two types, just like, There are bosses and employees in a company. “Manager” is the boss and “work” is the employee. The boss is in charge and the employee is responsible for the work. Sometimes when the labor is not enough, the boss also comes to do things.
1. Node: docker host
2. Management Node (Manager)
Manage the Docker cluster
1. Cluster configuration
2. Container service management.
3. Load balancing
4. Cluster Management?
3. Work node (Worker)
1. Provide container services
How does swarm operate on cluster node containers? === Not at the moment
Swarm 50% Swarm 50% Swarm 50% Swarm 50% Swarm 50% Swarm 50% Swarm
The following operations are based on these concepts
What is service?
A collection of different node containers used to maintain the container
What is a task?
Used to run containers in a clustered environment
What is stack?
Stack is a collection of stacks used to maintain services
Docker swarm creates docker clusters
conditions
1. More than two Docker hosts
2, docker swarm
steps
1. Install two docker hosts using Linux or centos7.0 or above
Docker 1.12 or later will be supported by default on the host
How to use Docker swarm?
Docker docker docker docker docker docker docker docker docker
docker swarm
2. Enter the docker swarm command
You can see a lot of help commands
3. Create a cluster management node
Docker swarm init –advertise-addr 123.57.164.54
4. Create a work node
docker swarm join –token SWMTKN-1-2bomg3tb4cs8f5g7oqrw34k1mql9i0tr2msn8leqyphgac5hct-db4iwy32sdr6m0bmqyhi47jyn 123.57.164.54:2377
5. View cluster messages, working nodes, and management nodes
docker info
Swarm how to manage containers in a swarm?
If you use service, what else does a company have besides the human? Is there some manager
It’s like a department manager in a company
conditions
1. Rmcore mirroring
2. Nginx mirroring
3, docker service
steps
1. View rMCore images and Nginx images
Use rMCore images for cluster service deployment
How to use docker service?
Docker command output, you will see a service management command
docker service
2. Enter the docker service command
There are many help commands available
3. Create a service
Docker service create –replicas 1 — name rmcoreService rmcore
–replicas Configures service replicas (containers start on different nodes)
–name Service name
4. List services
docker service ls
5. Check which node the service is running on
docker service ps rmcore-service
6. View the service deployment details
docker service inspect –pretty rmcoreservice
7. Service extension (add service copies to other nodes)
docker service scale rmcoreservice=2
8. Delete services
docker service rm rmcoreservice
9. How can the service be accessed externally
Docker service create –replicas 1 — name –publish 6066:80 rmCOREService
–publish Publish port for example, 6066:80
10. Access the Internet
111.229.181.115:6066
123.57.164.54:6066
Swarm how to manage different containers in swarm?
If you think about the stack, in addition to the human, there are some managers in the company, what else is the general manager, so stack is the general manager
It’s like a department manager in a company
conditions
1. Rmcore mirroring
2. Nginx mirroring
3, the docker – compose. Yml
4, the stack
1. View rMCore images and Nginx images
Use rMCore images for cluster service deployment
How to use Docker Stack?
Docker command output, you will see a service management command
docker stack
2. Enter the Docker stack command
There are a lot of help commands
3. Create stack (collection of services)
Create a stack directory (create a stack directory under current directory /root)
mkdir stack
2. Configure the YML file
Add configuration to existing docker.compose. Yml
Version: ‘3.4’
Gloab replicas: 2 replicas
3. Create stack
docker stack deploy -c docker-compose.yml rmstack
-c specifies the docker-comemage. yml file
Rmcorestack Specifies the stack id (name)
4. View the Stack list
docker stack ls
5. View the stack service list
docker stack ps rmstack
Or docker service ls
5. Delete the Stack
docker stack rm rmstack
Check whether all information is deleted on both nodes
version: '3'
services:
rmcore:
image: rmcore
ports:
- 8088:80
- 8089:443
deploy:
mode:
replicated
replicas: 2
nginx:
image: nginx
ports:
- 8090:80
deploy:
mode:
replicated
replicas: 2
Copy the code
6. Access the Internet
111.229.181.115:6066
123.57.164.54:6066
How does Swarm run containers
Run the container using Task
How does swarm listen for container state?
Swarm couldn’t do it
Use k8S to do so
How does swarm log containers?
Swarm couldn’t do it
Use k8S to do so