Orchestration (25%) Flashcards

Orchestration (25%)

1
Q

Which command do you use to create a new swarm?

A

docker swarm init –advertise-addr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is this flag –advertise-addr for?

A

This flag configures the IP address for the manager node and The other nodes in the swarm must be able to access the manager at the IP address.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you know the current status of the swarm?

A

docker info // you can find the info under the swarm section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which command do you use to find the information about the nodes in the swarm?

A

docker node ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to add another manager to the swarm?

A

// it generate the instructions for the manager to be addeddocker swarm join-token manager

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to add another worker node to the swarm?

A

// it generate the instructions for the worker to be addeddocker swarm join-token worker

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to run the container?

A

docker run

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the autolock feature in the Docker swarm?

A

When Docker restarts, both the TLS key used to encrypt communication among swarm nodes, and the key used to encrypt and decrypt Raft logs on disk, are loaded into each manager node’s memory.Docker 1.13 introduces the ability to protect the mutual TLS encryption key and the key used to encrypt and decrypt Raft logs at rest, by allowing you to take ownership of these keys and to require manual unlocking of your managers. This feature is called autolock.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to lock the swarm?

A

// This command produces unlock key. You need to place that in safe placedocker swarm init –autolock

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to unlock the swarm?

A

docker swarm unlock

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Are we able to enable autolock feature only when we create a swarm for the first time?

A

No. You can lock the existing swarm as well

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to enable or disable autolock on the existing swarm?

A

//enable autolockdocker swarm update –autolock=true//disable autolockdocker swarm update –autolock=false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to view the current unlock key for the running swarm?

A

docker swarm unlock-key

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to rotate the unlock key?

A

docker swarm unlock-key –rotate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

If the key was rotated after one of the manager nodes became unavailable and if you don’t have access to the previous key you may need to force the manager to leave the swarm and join it back as a new manager. Is this statement correct?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How to deploy a service in the docker swarm?

A

// for the nginx imagedocker create service –replicas 3 –name nginx-web nginx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How to list the services in the Docker swarm?

A

docker service ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How to list the tasks of the service in the Docker swarm?

A

docker service ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How to inspect the service on the swarm?

A

docker service inspect

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How to inspect the service on the swarm so that it will print limited information in an easily readable format?

A

docker service inspect –pretty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How to find out which nodes are running the service?

A

docker service ps SERVICE_ID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How to find out more details of the container running these tasks of the service?

A

// you need to run this command on the particular nodedocker ps

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

If you are running co-related services in the docker swarm, what do you call this?

A

stack

24
Q

What is Docker stack?

A

A stack is a group of interrelated services that share dependencies, and can be orchestrated and scaled together.

25
Q

Explain the several commands associated with Docker stack?

A

// deploy the new stack or updatedocker stack deploy -c // list services in the stackdocker stack services// list the tasks in the stackdocker stack ps// remove the stackdocker stack rm//List stackdocker stack ls

26
Q

How to filter the services in the stack?

A

// with the help of –filter flagdocker stack service nginx-web –filter name=web

27
Q

How to format the output of the docker stack services command?

A

docker stack services –format “{{.ID}}: {{.Mode}} {{.Replicas}}”

28
Q

How to increase the number of replicas?

A

docker service scale SERVICE=REPLICAS// exampledocker service scale frontend=50// you can scale multiple services as welldocker service scale frontend=50 backend=30// you can also scale with the update commanddocker service update –replicas=50 frontend

29
Q

How to revert the changes for the service configuration?

A

docker service rollback my-service

30
Q

What are the networks available for the docker services?

A

overlay networks: manage communications among the Docker daemons participating in the swarm.You can attach a service to one or more existing overlay networks as well, to enable service-to-service communication.ingress network: is a special overlay network that facilitates load balancing among a service’s nodes. When any swarm node receives a request on a published port, it hands that request off to a module called IPVS. IPVS keeps track of all the IP addresses participating in that service, selects one of them, and routes the request to it, over the ingress network.docker_gwbridge: is a bridge network that connects the overlay networks (including the ingress network) to an individual Docker daemon’s physical network.

31
Q

Is the ingress network created automatically when you initialize or join a swarm?

A

yes

32
Q

Is docker_gwbridge network created automatically when you initialize or join a swarm?

A

yes

33
Q

How to create an overlay network?

A
docker network create --driver overlay my-network
// you can customize it 
docker network create \  
--driver overlay \  
--subnet 10.0.9.0/24 \  
--gateway 10.0.9.99 \  
my-network
34
Q

How to inspect the network?

A

docker network inspect my-network

35
Q

How to attach a service to an overlay network?

A

docker service create \ –replicas 3 \ –name my-web \ –network my-network \ nginx

36
Q

Can service containers connected to the overlay network communicate with each other?

A

yes

37
Q

How to find which networks the service is connected to?

A

docker network inspect my-network
or
docker service ls // for the name
docker service ps // to list the networks

38
Q

Customize the ingress network involves removing and creating a new one and you need to do that before you create any services in the swarm. Is this statement correct?

A

yes

39
Q

How to remove and create an ingress network?

A

docker network rm ingressdocker network create \ –driver overlay \ –ingress \ –subnet=10.11.0.0/16 \ –gateway=10.11.0.2 \ –opt com.docker.network.mtu=1200 \ my-ingress

40
Q

What is the difference between -v and –mount flags in terms of creating volumes?

A

Originally, the -v or –volume flag was used for standalone containers and the –mount flag was used for swarm services. However, starting with Docker 17.06, you can also use –mount with standalone containers. In general, –mount is more explicit and verbose.

41
Q

How to create a service with volume?

A

docker service create -d \ –replicas=4 \ –name devtest-service \ –mount source=myvol2,target=/app \ nginx:latest

42
Q

Does docker service create command supports -v or — volume flag?

A

No

43
Q

What are the volume drivers?

A

When building fault-tolerant applications, you might need to configure multiple replicas of the same service to have access to the same files.Volume drivers allow you to abstract the underlying storage system from the application logic. For example, if your services use a volume with an NFS driver, you can update the services to use a different driver, as an example to store data in the cloud, without changing the application logic.

44
Q

How to create a volume with the volume driver?

A

docker volume create –driver vieux/sshfs \ -o sshcmd=test@node2:/home/test \ -o password=testpassword \ sshvolume

45
Q

How to create a service with volume driver?

A

docker service create -d \ –name nfs-service \ –mount ‘type=volume,source=nfsvolume,target=/app,volume-driver=local,volume-opt=type=nfs,volume-opt=device=:/var/docker-nfs,volume-opt=o=addr=10.0.0.10’ \ nginx:latest

46
Q

I created a deployment that runs exactly one task on every node. which type of service deployment is this?

A

global

47
Q

I created a deployment that runs several identical tasks on nodes. which type of service deployment is this?

A

replicated

48
Q

If you want to troubleshoot the UCP clusters what is the best method?

A

it’s always best practice to use client bundle to troubleshoot UCP clusters

49
Q

What is the general flow when troubleshooting services or clusters?

A

docker service lsdocker service ps docker service inspect docker inspect docker inspect docker logs

50
Q

How to update metadata about a node?

A

you can use labels to add metadata about the node

51
Q

How to add a label to the node?

A

docker node update –label-add foo worker1// add multiple labelsdocker node update –label-add foo –label-add bar worker1

52
Q

How to remove the label from the node?

A

docker node update –label-rm foo worker1

53
Q

How to set up the service to divide tasks evenly over different categories of nodes?

A

–placement-pref// example: if we have three datacenters 3 replicas will be placed on each datacenterdocker service create \ –replicas 9 \ –name redis_2 \ –placement-pref ‘spread=node.labels.datacenter’ \ redis:3.0.6

54
Q

How to limit your service on particular nodes?

A

–constraint// example: the following limits tasks for the redis service to nodes where the node type label equals queuedocker service create \ –name redis_2 \ –constraint ‘node.labels.type == queue’ \ redis:3.0.6

55
Q

Which algorithm does the docker engine use when it is in swarm mode to manage the global cluster state?

A

Raft Consensus Algorithm

56
Q

What is a quorum and why it is important?

A

Quorun ensure that the cluster state stays consistent in the presence of failures by requiring a majority of nodes to agree on values.Raft tolerates up to (N-1)/2 failures and requires a majority or quorum of (N/2)+1 members to agree on values proposed to the cluster.without quorun swarm wont be able to serve the requests

57
Q

What are the supported flags for creating services with templates?

A

–env–mount–hostname// exampleservice create –name hosttempl \ –hostname=”{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}”\ busybox top