CS代考 2 – cscodehelp代写

2
Cloud Computing INFS3208
Updates

• •

Mask restrictions continue – carrying masks, wearing masks, check-in QLD
GCP coupons redeem (check the latest announcement)
The next Student Consultative Committee meeting will be taking place next Wednesday, 25 August.
Students can join the mailing list by emailing
CRICOS code 00025B 2
24/08/2021
The meeting details are as follows:
Date: Wednesday, 25 August, 2021
Time: 12:00 – 1:00 pm
Room: 50-T105 and via Zoom (link will be provided to mailing list and upon request)
2

3
Cloud Computing INFS3208
Re-cap
• Container
• What is Docker
• Basic concepts in Docker
– Images
– Containers
– Registry
– Layer architecture
• Docker Commands
• Containerisation and Dockerfile
– Dokcerfile instructions
CRICOS code 00025B 3
24/08/2021
3

4
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 4
24/08/2021
4

Cloud Computing INFS3208
One-size-for-all container?
Last week…
Image taken from web CRICOS code 00025B 5 5
24/08/2021
• •
• • •
Ubuntu base image
MySQL RDBMS, DB/Redis
Nginx or Apache HTTP Server Programming Language support:
Java, Python, Go, etc.
Should we have a one-size-for-all container for the project?
5

Cloud Computing INFS3208
Microservices
• Separate business logic functions
• Instead of one big program, several smaller applications • CommunicateviawelldefinedAPIs–usuallyHTTP
• In demand
24/08/2021
https://aws.amazon.com/microservices/
6
CRICOS code 00025B 6
6

Cloud Computing INFS3208
are an architectural and organizational approach to software development where software is composed of small independent services that communicate over well-defined APIs.
Monolithic Architecture
User Interface
Business Logic
Data Access Layer
DB
Microservices Architecture
24/08/2021
Microservice
User Interface
Microservice
Microservice
DB DB DB DB
https://aws.amazon.com/microservices/?nc1=h_ls
CRICOS code 00025B 7
7
7

8
Cloud Computing INFS3208
Microservices – Pros and Cons
Pros
• Technological Freedom – Language independent
• Easy Deployment – Fast iterations & Reusable Code
• Agility (Small teams)
• Resilience (Fault Isolation)
• Flexible Scaling (Scalable) Cons
• Infrastructure Overhead
– Servers and databases • Complicated networking
https://aws.amazon.com/microservices/?nc1=h_ls
CRICOS code 00025B 8
24/08/2021
8

9
Cloud Computing INFS3208
Question Revisited
Question: Should we have a One-size-for-all container for each project?
• Ubuntu base image
• MySQL RDBMS
• MongoDB/Redis
• Nginx or Apache HTTP Server
• Programming Language support: Java, Python, Go, etc.
Issues: Monolithic-like container is not scalable and chunky
Solution: containerize microservices and run multiple containers
CRICOS code 00025B 9
24/08/2021
9

Cloud Computing INFS3208
Question Revisited
Example: The first assignment • Php-fpm and nginx
# Build and start apps!
• docker build -> Images
• docker run a1:luo
# Make changes, rebuild image,
• docker build -> Images
• docker stop a1:luo
• docker rm a1:luo
• docker run a1:luo
10
What if we have another container, e.g., mariadb?
– When to start the db container?
– If the db container unexpectedly shut down?
CRICOS code 00025B 10
24/08/2021
10

11
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 11
24/08/2021
11

24/08/2021
12
Cloud Computing INFS3208
Docker Compose
• Compose is a tool for defining and running multi-container Docker applications.
• Use a Compose file (docker-compose.yml) to configure
application’s services.
• Use a single command to create and start all the services from the
configuration (docker-compose up).
• Three-step process:
1. Define your app’s environment with a Dockerfile
2. Define the services that make up your app in docker-
compose.yml so they can be run together in an
isolated environment.
3. Lastly, run docker-compose up and Compose will
start and run your entire app.
docker-compose –f docker-compose.json up
An example of docker-compose.yml CRICOS code 00025B 12
12

13
Cloud Computing INFS3208
Docker Compose
• Two basic concepts in docker compose:
– Service: running containers (one/multiple running instances of the same image)
– Project: a complete business unit (consists of multiple linked containers)
• Compose is targeting at the project management and has commands for
managing the whole lifecycle of your application:
– Start, stop and rebuild services
– View the status of running services
– Stream the log output of running services
24/08/2021
CRICOS code 00025B 13
13

Cloud Computing INFS3208
An Example of Docker Compose
• Web application in “app.py”
• Dockerfile
• docker-compose.yml
• Run docker-compose up
CRICOS code 00025B 14
24/08/2021
14
14

15
Cloud Computing INFS3208
Compose commands
The objectives of most of compose commands are either project (by default) or services/containers within the project.
docker-compose [-f=…] [options] [COMMAND] [ARGS…]
CRICOS code 00025B 15
24/08/2021
15

16
Cloud Computing INFS3208
Compose commands – up
docker-compose up [options] [–scale SERVICE=NUM…] [SERVICE…]
• •
• • •
• •
Builds, (re)creates, starts, and attaches to containers for a service. Important options:
“-d”: keep all the containers in yaml file running in the background. “–build”: force to rebuild the image
“–no-recreate”: ignore existing running containers and start all the stopped containers.
“–force-recreate”: force Compose to stop and recreate all containers. “–no-deps -d ”: stop, recreate, and restart a specific
container.
CRICOS code 00025B 16
24/08/2021
16

Cloud Computing INFS3208
Compose commands – change state
For all services…
docker-compose build
docker-compose down [options]
• Stops containers and removes containers, networks, volumes, and images created by up.
For a certain service…
docker-compose run [SERVICE…]
• creates containers from images built for the services mentioned in the compose file
docker-compose start [SERVICE…]
• Starts runs any stopped containers for a service.
docker-compose stop, restart, kill, rm (un)paused
https://docs.docker.com/compose/reference/overview/
17
CRICOS code 00025B 17
24/08/2021
17

Cloud Computing INFS3208
Compose commands – check information
docker-compose logs [options] [SERVICE…]
• Displays log output from services.
docker-compose images
• Lists images included in the docker- compose.yml file.
docker-compose ps [options] [SERVICE…]
• Lists containers.
docker-compose top
• Displays the running processes.
18
24/08/2021
CRICOS code 00025B 18
18

24/08/2021
19
Cloud Computing INFS3208
Compose files
Multi-service applications are defined in a configuration file
• docker-compose.yml (by default, but can use “-f” to read .yml file with a customised file name).
• YAML is a superset of JSON.
• consists of multiple layers that are split using tab stops or spaces
• Four main components in each Compose-File:
– Compose file’s version
– Services (containers)
– Volumes (storage)
– Networks (linking)
CRICOS code 00025B 19
19

24/08/2021
20
Cloud Computing INFS3208
Compose files
Second-level definitions in “services”:
• “db” (relational database – mysql)
• “wordpress” (Free and open-source CMS – WP). Instructions in “db“:
• “image” (or “build”):
– pulls the latest image of mysql and use it to create the container for this service
– “build” can be used with “Dockerfile” to build the customised image
• “volumes”: mounts folder db_data (source) to /var/lib/mysql.
• “restart”: specify restart policy for containers.
• “environment”: Add environment variables.
– Boolean values (i.e. true/false, yes/no) need to be quoted (i.e. restart: “no”).
CRICOS code 00025B 20
20

24/08/2021
21
Cloud Computing INFS3208
Compose files
Instructions in “wordpress”:



“depends_on”: expresses dependency between services. Service dependencies cause the following behaviours:





docker-compose up starts services in dependency order. E.g. “db” is started before “wordpress”.
docker-compose up [SERVICE] automatically includes SERVICE’s dependencies.
E.g. docker-compose up wordpress also creates and starts “db”. docker-compose stop stops services in dependency order.
E.g. “wordpress” is stopped before “db”.
“ports”: exposes or maps ports
– (HOST_PORT:CONTAINER_PORT) or (CONTAINER_PORT)
 E.g. “ports: 8000:80” or “ports: 80” – Port range: “-” and protocal: “/”
 E.g. “127.0.0.1:8000-8009:5000-5009” and “6000:6000/tcp” “networks”: defines the communication rules between containers

CRICOS code 00025B 21
21

22
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 22
24/08/2021
22

23
Cloud Computing INFS3208
Orchestration
• The portability and reproducibility of a containerised process help us
– migrate containerised applications to clouds efficiently;
– scale the containerised applications on the clouds effectively.
• How do we make docker work across multiple nodes?
– Share containers among each other
– replace failed containers automatically,
– manage the rollout of updates and reconfigurations of those containers during their lifecycle.
– etc.
CRICOS code 00025B 23
24/08/2021
23

24
Cloud Computing INFS3208
Orchestration
• Definition: automated configuration, management, and coordination of computer systems, applications, and services.
• Tools to manage, scale, and maintain containerised applications are called orchestrators
– Examples: Apache Mesos, Kubernetes, Docker Swarm, Amazon ECS.
24/08/2021
CRICOS code 00025B 24
24

Cloud Computing INFS3208
Docker Swarm
• Docker Swarm manages a cluster of Docker nodes and schedule containers
24/08/2021
• Each node of a docker swarm is a Docker daemon and all Docker daemons interact using the Docker API
• Docker daemon is responsible for
• Pulling images, starting containers
• Managing volumes, networks
• The REST API provides access to the daemon
• The Docker CLI is simply making API requests
https://docs.docker.com/machine/
25
Architecture of Docker Engine
CRICOS code 00025B 25
25

26
Cloud Computing INFS3208
• •
Docker Swarm
Docker Swarm manages a cluster of Docker nodes and schedule containers
Each node of a docker swarm is a Docker daemon and all Docker daemons
interact using the Docker API Containers
Docker daemons
Reschedule containers on node failure
Failure
Manager Nodes
•maintaining cluster state •scheduling services
26
CRICOS code 00025B
Worker Nodes
24/08/2021
26

27
Cloud Computing INFS3208
• •
Docker Swarm
Docker Swarm manages a cluster of Docker nodes and schedule containers Each node of a docker swarm is a Docker daemon and all Docker daemons
interact using the Docker API Containers
Docker daemons
CRICOS code 00025B 27
24/08/2021
27

Cloud Computing INFS3208
Key Features of Docker Swarm
• Cluster management integrated with Docker Engine
• Decentralized Design
• Scaling
• Load Balancing
• Secure by Default
• Rolling Updates
28
CRICOS code 00025B 28
24/08/2021
28

Cloud Computing INFS3208
• • • •
Getting Started with Swarm Mode
Initialize a cluster of Docker Engines in swarm mode
Adding nodes to swarm
Deploying application services to the swarm
Managing the swarm once you have everything running
https://docs.docker.com/engine/swarm/swarm-tutorial/
29
CRICOS code 00025B 29
24/08/2021
29

30
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 30
24/08/2021
30

Cloud Computing INFS3208
Docker Machine – Docker Hosts Management
Docker Machine allows you to provision Docker machines in a variety of environments,
• virtualmachineseitheronlocalsystemsoroncloudproviders,
• physicalcomputers.
Docker Machine creates a Docker host, and you use the Docker Engine client as needed to build images and create containers on the host.
VM or physical machine VM or physical machine VM or physical machine
CRICOS code 00025B 31
24/08/2021
Docker host
Docker host
Docker host
31
31

24/08/2021
32
Cloud Computing INFS3208
Docker Machine – Docker Hosts Management
Example: Create three different machines using docker-machine create 1. Manager1 (docker-machine create –driver virtualbox manager1)
2. Worker1 (docker-machine create –driver virtualbox worker1)
3. Worker2 (docker-machine create –driver virtualbox worker2)
CRICOS code 00025B 32
32

Cloud Computing INFS3208
Docker Machine – Docker Hosts Management
To create a virtual machine, you supply Docker Machine with the name of the driver you want to use.
• • •
For a local Mac or Windows system, the driver is typically Oracle VirtualBox. For provisioning physical machines, a generic driver is provided.
For cloud providers, Docker Machine supports drivers such as AWS, Microsoft Azure, Google Compute Engine, etc.
https://docs.docker.com/machine/drivers/gce/
CRICOS code 00025B 33
24/08/2021
33
33

Cloud Computing INFS3208
Docker Machine – GCP
1. Stop the vm instance and edit the vm setting
• in API access scopes select “Allow full access to all Cloud APIs” and click in save
https://docs.docker.com/machine/drivers/gce/
CRICOS code 00025B 34
24/08/2021
2. 3.
Restart the vm instance, install docker-machine Then run:
34
34

Cloud Computing INFS3208
Docker Machine – Additional Network Check
The following ports must be available. On some systems, these ports are open by default.
• TCP port 2377 for cluster management communications
• TCP and UDP port 7946 for communication among nodes • UDP port 4789 for overlay network traffic
https://docs.docker.com/engine/swarm/swarm-tutorial/
24/08/2021
CRICOS code 00025B 35
35
35

36
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 36
24/08/2021
36

Cloud Computing INFS3208
Create a Swarm
Make sure the Docker Engine daemon is started on the host machines.
1. Open a terminal and ssh into the machine where you want to run your manager node. If you use Docker Machine, you can connect to it via SSH using the following command:
https://docs.docker.com/engine/swarm/swarm-tutorial/
24/08/2021
CRICOS code 00025B 37
37
37

Cloud Computing INFS3208
Create a Swarm
2. Run the following command to create a new swarm on the manager node:
24/08/2021
https://docs.docker.com/engine/swarm/swarm-tutorial/
CRICOS code 00025B 38
38
38

Cloud Computing INFS3208
Create a Swarm
3. Jump to a worker node and join to the swarm:
24/08/2021
https://docs.docker.com/engine/swarm/swarm-tutorial/
Change to the internal IP of the manager node
CRICOS code 00025B 39
39
39

40
Cloud Computing INFS3208
Manage Nodes in a Swarm
docker node ls
• Displays view a list of nodes in the swarm
docker node promote/depromote [HOSTNAME]
• Change the role of node e.g., manager to worker
docker node rm [HOSTNAME]
• Delete a node
https://docs.docker.com/engine/swarm/manage-nodes/
CRICOS code 00025B 40
24/08/2021
40

41
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 41
24/08/2021
41

Cloud Computing INFS3208
Deploy Services to a Swarm
• Service: specified by its desired state: which image, how many instances
• The leader uses different subsystems to break down services in to tasks.
• Task: corresponds to a specific container, assigned to a specific node
https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/
42
CRICOS code 00025B 42
24/08/2021
42

Cloud Computing INFS3208
Deploy Services to a Swarm
24/08/2021
https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/
43
CRICOS code 00025B 43
43

Cloud Computing INFS3208
Deploy Services to a Swarm
24/08/2021
https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/
44
CRICOS code 00025B 44
44

45
Cloud Computing INFS3208
Deploy Services to a Swarm
• Open a terminal and ssh into the machine where you run your manager node
• specify a command that the service’s containers should run, by adding it after the image name. The below example starts a service called helloworld which uses an alpine image and runs the command ping docker.com:
CRICOS code 00025B 45
24/08/2021
45

46
Cloud Computing INFS3208
Deploy Services to a Swarm
• Run docker service ps helloworld to see which nodes are running the service:
• Run docker ps on the node where the task is running to see details about the containers
CRICOS code 00025B 46
24/08/2021
46

Cloud Computing INFS3208
Scale Services in a Swarm
• Run the following command to change the desired scale of the service running in the swarm
24/08/2021
docker service scale SERVICE=REPLICAS [SERVICE=REPLICAS…]
How to scale down the service helloworld?
CRICOS code 00025B 47
47
47

48
Cloud Computing INFS3208
Rolling Updates
• Run the following command to change the desired scale of the service running in the swarm
CRICOS code 00025B 48
24/08/2021
48

49
Cloud Computing INFS3208
Publish Ports
When you create a swarm service, you can publish that service’s ports to hosts outside the swarm in two ways:
• Routing Mesh: swarm makes the service accessible at the target port on every node
• Publish a service task’s port directly on the swarm node.
CRICOS code 00025B 49
24/08/2021
49

Cloud Computing INFS3208
Routing Mesh
• Routing Mesh: swarm makes the service accessible at the target port on every node
https://docs.docker.com/engine/swarm/ingress/
50
24/08/2021
CRICOS code 00025B 50
50

Cloud Computing INFS3208
Bypassing Routing Mesh
• [Host Mode]: when you access the bound port on a given node, you are always accessing the instance of the service running on that node.
https://docs.docker.com/engine/swarm/ingress/
51
CRICOS code 00025B 51
24/08/2021
51

52
Cloud Computing INFS3208
Outline
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 52
24/08/2021
52

53

Deploy a Stack to a Swarm
When running Docker Engine in swarm mode, you can use docker stack deploy to deploy a complete application stack to the swarm. The deploy command accepts a stack description in the form of a Compose file.
CRICOS code 00025B 53
Cloud Computing INFS3208
24/08/2021
53

Cloud Computing INFS3208
Example: Deploy a Stack to a Swarm
24/08/2021
• https://training.play-with-docker.com/swarm-stack-intro/ 54
CRICOS code 00025B 54
54

55
Cloud Computing INFS3208
Recap
• Microservices
• •
• • • •
Docker Compose Docker Swam
Docker Machine
Create a Swarm
Deploy Services to a Swarm Deploy a Stack to a Swarm
CRICOS code 00025B 55
24/08/2021
55

56
Cloud Computing INFS3208
Tutorial & Practical for Week 5
Tutorial 4 (Week 5)
1. What are Microservices?
2. What is Docker Compose?
3. Discuss the benefits of Docker Compose.
4. Discuss the key features of Docker Swarm.
Practical 4 (Week 5)
1. Familarise installations of Nginx and PHP on a Virtual Machine;
2. Practise writing Dockerfiles to build a scientific computing environment;
3. Practise writing Docker-compose.yml and use docker compose to run multiple containers.
CRICOS code 00025B 56
24/08/2021
56

57
Cloud Computing INFS3208
Next (Week 6) Topic:
Docker III: Kubernetes
CRICOS code 00025B 57
24/08/2021
57

Leave a Reply

Your email address will not be published. Required fields are marked *