程序代写 INFS3208

CRICOS code 00025BCRICOS code 00025B

Copyright By PowCoder代写 加微信 powcoder

Cloud Computing

• Microservices

• Docker Compose

• Docker Swam

• Docker Machine

• Create a Swarm

• Deploy Services to a Swarm

• Deploy a Stack to a Swarm

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Evolution of Kubernetes

Cloud Computing

• Amazon Web Services (AWS) changed the world when it

brought us modern day cloud computing.

• Kubernetes ( (koo-ber-net-eez) or K8s in short) was originally

designed by Google and is now maintained by the Cloud Native

Computing Foundation (CNCF).

• K8s provides automating deployment, scaling and management

of containerised applications across multiple hosts.

• It works with a range of container tools, including Docker.

CRICOS code 00025BCRICOS code 00025B

• Automated rollouts and rollbacks

• Storage orchestration

• Self-healing

• Service discovery and load balancing

• Horizontal scaling

Why Kubernetes?

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Master Node (Control Plane)

• Multi-master high availability (HA) is a must have

• Scheduling, detect, or respond to cluster events

Kubernetes Architecture

Cloud Computing

Source: https://knowitinfo.com/what-is-kubernetes-control-plane/

API Server

• Central component

• Provides k8s APIs and authentication

CRICOS code 00025BCRICOS code 00025B

Master Node (Control Plane)

• Multi-master high availability (HA) is a must have

• Scheduling, detect, or respond to cluster events

Kubernetes Architecture

Cloud Computing

• Watch for the unassigned ‘task’

• Assign it to a node which has available resources

(CPU & memory) matching the requirement

• Perform predicate checks and rank nodes

Source: https://knowitinfo.com/what-is-kubernetes-control-plane/

CRICOS code 00025BCRICOS code 00025B

Master Node (Control Plane)

• Multi-master high availability (HA) is a must have

• Scheduling, detect, or respond to cluster events

Kubernetes Architecture

Cloud Computing

Controller manger

• Node controller

• ReplicaSet (Replication) controller

• Endpoint controller

• Namespace controller

• consistent and highly-avail key value store

(cluster info)

Source: https://knowitinfo.com/what-is-kubernetes-control-plane/

CRICOS code 00025BCRICOS code 00025B

Worker Node

1. Watch the API server for new work assignments

2. Execute new work assignments

3. Report back to the control plane (via the API server)

Kubernetes Architecture

Cloud Computing

Source: https://knowitinfo.com/what-is-kubernetes-control-plane/

• Core agent; runs on every worker nodes in the cluster

• Register the node with the cluster

• Watch the API server, execute the task, maintain the

reporting channel

• Reports task failure

CRICOS code 00025BCRICOS code 00025B

Worker Node

1. Watch the API server for new work assignments

2. Execute new work assignments

3. Report back to the control plane (via the API server)

Kubernetes Architecture

Cloud Computing

Source: https://knowitinfo.com/what-is-kubernetes-control-plane/

Container Runtime

• Perform container-related tasks

• Other choices e.g., Kata and containerd

Kube-proxy

• Responsible for local cluster networking

• Make sure each node gets its unique IP address

• Handle routing and load-balancing (IPTABLES / IPVS)

CRICOS code 00025BCRICOS code 00025B

For an application to run on a Kubernetes cluster…

1. Being packaged as a container

2. Being wrapped in a Pod

3. Being deployed via a declarative manifest file

Packing Apps for Kubernetes

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

• The atomic unit of scheduling in K8s – Pod

• Containers must always run inside of Pods

• Literally, Pod: a group of whale

• Simplest model: one container per Pod;

Advanced use cases that run multiple

containers inside a single Pod

• e.g., helper container that pulls the latest

What is a Pod?

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/workloads/pods/

https://kubernetes.io/docs/concepts/workloads/pods/

CRICOS code 00025BCRICOS code 00025B

• Multiple containers in a Pod share the same

Pod environment

• Networking, as a unique cluster IP address

• Shared storage, as Volumes

• Information about how to run each container,

– (e.g. the container image version or specific

ports to use)

What is a Pod?

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/workloads/pods/

https://kubernetes.io/docs/concepts/workloads/pods/

CRICOS code 00025BCRICOS code 00025B

• Scaling: Pods are minimum unit of scaling

• Deployment: A single Pod can only be

scheduled to a single node

• Lifecycle: is associated with a new

ID and IP address

What is a Pod?

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/workloads/pods/

For an application to run on a Kubernetes cluster…

1. Being packaged as a container

2. Being wrapped in a Pod

3. Being deployed via a declarative manifest file

https://kubernetes.io/docs/concepts/workloads/pods/

CRICOS code 00025BCRICOS code 00025B

• The declarative model and the concept of desired state are at the very heart of K8s.

• In K8s, the declarative model works like:

Declarative v.s. Imperative

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/workloads/pods/

Manifest File

1.Declare the desired state of an application (microservice) in a manifest file
2.POST it to the API server

https://kubernetes.io/docs/concepts/workloads/pods/

CRICOS code 00025BCRICOS code 00025B

• The declarative model and the concept of desired state are at the very heart of K8s.

• In K8s, the declarative model works like:

Declarative v.s. Imperative

Cloud Computing INFS3208

Manifest File

3. Kubernetes stores it in the Etcd as the application’s desired state
4. Kubernetes implements the desired state on the cluster
5. Kubernetes implements watch loops -> current state of the application doesn’t vary from the
desired state

Implement the desired state

& add watch loop

CRICOS code 00025BCRICOS code 00025B

• Imperative model: issue long lists of platform-specific commands to build things

• Declarative model:

• Simpler: concise file vs long scripts of imperative commands

• Self-healing

• Version control

Declarative v.s. Imperative

Cloud Computing INFS3208

For an application to run on a Kubernetes cluster…

1. Being packaged as a container

2. Being wrapped in a Pod

3. Being deployed via a declarative manifest file

CRICOS code 00025BCRICOS code 00025B

• Test playground: Play with Kubernetes (https://labs.play-with-k8s.com/)

• Hosted Kubernetes: zero-effort production-grade Kubernetes as you will get, e.g.,

• GCP: Google Kubernetes Engine (GKE), AWS: Elastic Kubernetes Service (EKS)

Example: Setup for Deployments

Cloud Computing INFS3208

https://labs.play-with-k8s.com/

CRICOS code 00025BCRICOS code 00025B

• Some tools are pre-installed: Kubectl (Kubernetes client) & Kubeadm (create cluster)

Example: Setup for Deployments

Cloud Computing INFS3208

https://kubernetes.io/docs/reference/kubectl/cheatsheet/

https://kubernetes.io/docs/reference/kubectl/cheatsheet/

CRICOS code 00025BCRICOS code 00025B

• Some tools are pre-installed: Kubectl (Kubernetes client) & Kubeadm (create cluster)

Example: Setup for Deployments

Cloud Computing INFS3208

https://kubernetes.io/docs/tutorials/kubernetes-basics/create-

cluster/cluster-interactive/

MiniKube: Easy to install, light;

Single-node only Kubeadm: production-level;

Hard Installation, heavy

https://kubernetes.io/docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive/

CRICOS code 00025BCRICOS code 00025B

• Some tools are pre-installed: Kubectl (Kubernetes client) & Kubeadm (create cluster)

Example: Setup for Deployments

Cloud Computing INFS3208

Play-with-k8s Playground

Tips: ctrl + insert = copy

shift + insert = paste

CRICOS code 00025BCRICOS code 00025B

• Now let’s go to the playground and give it a try

Demo: Try it Yourself

Cloud Computing INFS3208

Play-with-k8s Playground (https://labs.play-with-k8s.com/)

CRICOS code 00025BCRICOS code 00025B

• Now let’s go to the playground and give it a try

Demo: Try it Yourself

Cloud Computing INFS3208

Play-with-k8s Playground

Tips: ctrl + insert = copy

shift + insert = paste
• This is because you haven’t configured the Pod network yet

CRICOS code 00025BCRICOS code 00025B

• Create a Pod with Mongo in an imperative way

Demo: Try it Yourself

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

• Create a Pod with Mongo in an declarative way

Demo: Try it Yourself

Cloud Computing INFS3208

Mandatory keywords:

• apiVersion: version of Pod API

• kind: type of object

• Metadata: a name and labels

• spec: define the container

CRICOS code 00025BCRICOS code 00025B

Pod’s scheduling sequence

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Deployments

Cloud Computing INFS3208

Deployment controller

• Deployment: object type in K8s API

• Use Replicasets provide self-

healing and scaling

Replicasets controller

• Ensure the specified number of

replicas of a service are always

CRICOS code 00025BCRICOS code 00025B

Deployments

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

Demo: Google Kubernetes Engine (GKE) – Create a Cluster

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Demo: GKE – Create a Cluster

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Demo: GKE – Log in using Cloud Shell

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Replicaset YAML file

• apiVersion, kind, metadata

• replicas: desired number of replicas

• selector: select which pods should be

• template: required field, same schema as a

Pod specification

Demo: Deploy Replicasets

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Demo: Deploy Replicasets

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Demo: Deploy Replicasets – Self-healing

Cloud Computing

• Destroy a Pod in the cluster as a simulation of failure

CRICOS code 00025BCRICOS code 00025B

Deployments

Cloud Computing INFS3208

Deployment controller

• Deployment: object type in K8s API

• Use Replicasets provide self-

healing and scaling

CRICOS code 00025BCRICOS code 00025B

Deployments

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

Demo: Deployments

Cloud Computing INFS3208

Deployment YAML file

• minReadySeconds: minimum

number of seconds before

Kubernetes starts considering the

Pods healthy

• revisionHistoryLimit

• strategy: RollingUpdate/Recreate

CRICOS code 00025BCRICOS code 00025B

Demo: Deployments

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

Demo: Deployments – Rolling Updates

Cloud Computing INFS3208

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Cloud Computing INFS3208

Motivation

• There are no communication path

• Pods are unreliable

• gets a new address

Definition

• Services provide reliable networking

for a set of Pods

CRICOS code 00025B

Cloud Computing INFS3208

• REST object in the API that you

define in a manifest and POST to

the API server

• Every Service gets its own stable IP

address, its own stable DNS name

and its own stable port.

• Leverage labels to dynamically

select the Pods they will send traffic

CRICOS code 00025BCRICOS code 00025B

Cloud Computing INFS3208

Kubernetes NodesKubernetes Master

CRICOS code 00025BCRICOS code 00025B

Cloud Computing INFS3208

Container tries to connect…

Kubelet configured the nameserver

Visit Kube-dns

Iptables maintained by kube-proxy
Iptable forwards request to just

one endpoint

CRICOS code 00025BCRICOS code 00025B

Create services by exposing ports

Cloud Computing INFS3208

• Specified -> expose a deployment object

• Name it as ‘cc-demo-service’

• The port to expose (28017 for Mongodb)

• ClusterIP (default): expose the port only inside the cluster

• NodePort: expose the target port on every node to the outside

• LoadBalancer: only useful when combined with cloud provider’s load balancer

CRICOS code 00025B

Create services with YAML file (kubectl apply –f service.yml)

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/services-networking/ingress/

https://kubernetes.io/docs/concepts/services-networking/ingress/

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

• Persistent Volume Subsystem:

Kubernetes Storage

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html

• Persistent Volume (PV): how you

map external storage onto the

cluster; resource

• Persistent Volume Claim (PVC): a

request for storage by a user; claim

checks to the resource

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volumes.html

CRICOS code 00025BCRICOS code 00025B

Kubernetes Storage

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

1. Create the PV.

2. Create the PVC.

3. Define the volume.

4. Mount it into a container.

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

CRICOS code 00025BCRICOS code 00025B

Kubernetes Storage

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

gke-pv.yml

•ReadWriteOnce (RWO)
•ReadWriteMany (RWM)
•ReadOnlyMany (ROM)

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

CRICOS code 00025BCRICOS code 00025B

Persistent Volume Claim: like a ticket that grants the Pod to the PV

Kubernetes Storage

Cloud Computing INFS3208

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

https://kubernetes.io/docs/concepts/storage/persistent-volumes/

CRICOS code 00025BCRICOS code 00025B

Kubernetes vs Docker Swarm

Cloud Computing

https://medium.com/edureka/kubernetes-vs-docker-45231abeeaf1

Source: quarterly report on developer trends in the cloud by Digital Ocean

https://medium.com/edureka/kubernetes-vs-docker-45231abeeaf1
https://www.digitalocean.com/currents/june-2018/

CRICOS code 00025BCRICOS code 00025B

• Kubernetes (K8s)

• Architecture: Master and Worker Nodes

• Replicasets & Deployment

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

What’s Next?

Getting more hands-on practice

• Play with Kubernetes classroom: https://training.play-with-kubernetes.com/kubernetes-

Getting prepared for certification

• https://cloud.google.com/certification/cloud-architect

Remember to stop GKE clusters when not in use…

Cloud Computing

https://training.play-with-kubernetes.com/kubernetes-workshop/
https://cloud.google.com/certification/cloud-architect

CRICOS code 00025BCRICOS code 00025B

What’s Next?

A few more things to explore…

• Kubernetes Dashboard (https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-

dashboard/)

• ConfigMaps (https://kubernetes.io/docs/concepts/configuration/configmap/)

• Threat Modeling (https://kubernetes.io/docs/tasks/administer-cluster/securing-a-cluster/)

Cloud Computing

https://kubernetes.io/docs/concepts/configuration/configmap/

https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
https://kubernetes.io/docs/concepts/configuration/configmap/
https://kubernetes.io/docs/tasks/administer-cluster/securing-a-cluster/
https://kubernetes.io/docs/concepts/configuration/configmap/

CRICOS code 00025BCRICOS code 00025B

Tutorial & Practical for Week 6

Tutorial 5 (Week 6)

1. Please describe what Kubernetes (K8s) is.

2. What are the motivations of using Kubernetes?

3. Please describe the components and their functions in a Kubernetes cluster?

4. Please generally summarise the workflow of Kubernetes

Practical 5 (Week 6)

1. Use Docker commands to deploy a PHP-based web development environment with four

containers.

2. Consultation for A1

Cloud Computing

CRICOS code 00025BCRICOS code 00025B

Databases in Cloud Computing NoSQL: Redis

Next (Week 7) Topic:

Cloud Computing

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com