15-319 / 15-619 cloud computing › ~msakr › 15619-s18 › recitations › s18_recitation0… ·...

47
15-319 / 15-619 Cloud Computing Recitation 5 February 13 th , 2018

Upload: others

Post on 09-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

15-319 / 15-619Cloud Computing

Recitation 5

February 13th, 2018

Overview

● Administrative issues○ Office Hours, Piazza guidelines

● Last week’s reflection○ Project 2.1, OLI Unit 2 modules 5 and 6

● This week’s schedule○ Quiz 4 - February 16, 2018 (Modules 7, 8, 9)○ Project 2.2 - February 18, 2018

Announcements

• Monitor your expenses regularly- Check your bill frequently on TheProject.Zone- Check on AWS, use Cost Explorer & filter by tags- Check on the Azure portal since only $100/sem

• Terminate your resources when you are done - Stopping a VM still costs EBS money

($0.1/GB/month)- Amazon EC2 and Amazon Cloudwatch fees for

monitoring, ELB- AutoScaling Group - no additional fees

Announcements

● Use spot instances as much as possible

● Protect your credentials

○ Crawlers are looking for AWS credentials on

public repos!

● Primers released this week

○ P2.2 - Intro to Containers and Docker

○ P2.2 - Kubernetes and Container Orchestration

○ P3.1 - Storage I/O Benchmarking

P3.1 - Storage I/O Benchmarking

● Why is it important?○ Bottlenecks affect overall system performance○ I/O intensive applications are more sensitive to

storage latency

● Tagging○ Key: Project

Value: < Current Individual Project >

○ Key: PrimerValue: StorageBenchmarking

Last Week’s Reflection

● OLI: Conceptual Content○ Unit 2 - Modules 5 and 6:

■ Cloud Management & Software Deployment Considerations

○ Quiz 3 completed● P2.1: AWS EC2 APIs and Terraform

○ CLI, Java, Python● P2.1: Load Balancing and AutoScaling

○ Experience horizontal scaling○ Programmatically manage cloud resources and

deal with failure○ Initial experience with load balancing

6

Project 2.1

● To evaluate how well other people can read your code, we will be manually grading your submitted code○ AWS (Horizontal and Autoscaling)○ Terraform configuration file

○ To enhance readability ■ Use the Google Code Style guidelines

○ Always add comments especially for complex parts

7

Project 2.1

● You gained experience working with Cloud Service Provider's APIs.○ Documentation may be unclear or may

omit certain details.○ Have to ensure you’re referencing the

correct documentation version.● Considerations of cost vs performance● Used automation tools to manage cloud

infrastructure.

8

This Week: Content

● UNIT 3: Virtualizing Resources for the Cloud

○ Module 7: Introduction and Motivation○ Module 8: Virtualization○ Module 9: Resource Virtualization - CPU○ Module 10: Resource Virtualization - Memory ○ Module 11: Resource Virtualization – I/O ○ Module 12: Case Study○ Module 13: Network and Storage Virtualization

9

OLI Module 7 - VirtualizationIntroduction and Motivation

● Why virtualization

○ Elasticity

○ Resource sandboxing

○ Mixed OS environment

○ Resource sharing

○ Improved system utilization and reduced costs

10

OLI Module 8 - Virtualization

● What is Virtualization○ Involves the construction of an isomorphism that

maps a virtual guest system to a real (or physical) host system

○ Sequence of operations e modify guest state○ Mapping function V(Si)

● Virtual Machine Types○ Process Virtual Machines○ System Virtual Machines

11

OLI Module 9Resource Virtualization - CPU

● Steps of CPU Virtualization○ Multiplexing a physical CPU among virtual CPUs○ Virtualizing the ISA (Instruction Set Architecture) of a

CPU

● Code Patch, Full Virtualization and Paravirtualization● Emulation (Interpretation & Binary Translation)● Virtual CPU

12

This Week: Project

● P2.1: Horizontal Scaling and Autoscaling ○ MSB Interview

● P2.2: Containers and Kubernetes○ Building a Coding Interview Playground○ Working with Docker and Kubernetes

● P2.3: Functions as a Service○ Functions and serverless computing○ Video processing pipeline

13

Containers

● Provides OS-level virtualization.● Provides private namespace, network

interface and IP address, etc.● Big difference with VMs is that containers

share the host system’s kernel with other containers.

14

Why Containers?

● Faster deployment● Portable● Modularity● Consistent Environment

Build once, run anywhere

15

Docker

● Docker is an open platform for developing, shipping, and running applications.

● Dockerfile● Docker Image● Docker Container

16

Dockerfile

● Dockerfile tells Docker how to build an image:○ Base Image○ Commands○ Files○ Ports○ Startup Command

● In short, Dockerfile is a recipe for Docker images

Let’s go through a sample Dockerfile!

17

Example Dockerfile# Debian as the base image

FROM debian:latest

# Install additional packages

RUN apk add --update emacs

RUN apk add --update apache

# index.html must be in the current directory

ADD index.html /home/demo/

# Define the command which runs when the container starts

CMD ["cat /home/demo/index.html"]

# Use bash as the container's entry point. CMD is the argument to this entry point

ENTRYPOINT ["/bin/bash", "-c"]

18

Example Dockerfile# Debian Linux as the base image

FROM debian:latest

# Install additional packages

RUN apk add --update emacs

RUN apk add --update apache

# index.html must be in the current directory

ADD index.html /home/demo/

# Define the command which runs when the container starts

CMD ["cat /home/demo/index.html"]

# Use bash as the container's entry point. CMD is the argument to this entry point

ENTRYPOINT ["/bin/bash", "-c"]

19

Example Dockerfile# Alpine Linux as the base image

FROM debian:latest

# Install additional packages

RUN apk add --update emacs

RUN apk add --update apache

# index.html must be in the current directory

ADD index.html /home/demo/

# Define the command which runs when the container starts

CMD ["cat /home/demo/index.html"]

# Use bash as the container's entry point. CMD is the argument to this entry point

ENTRYPOINT ["/bin/bash", "-c"]

20

Example Dockerfile# Alpine Linux as the base image

FROM debian:latest

# Install additional packages

RUN apk add --update emacs

RUN apk add --update apache

# index.html must be in the current directory

ADD index.html /home/demo/

# Define the command which runs when the container starts

CMD ["cat /home/demo/index.html"]

# Use bash as the container's entry point. CMD is the argument to this entry point

ENTRYPOINT ["/bin/bash", "-c"]

21

Example Dockerfile# Alpine Linux as the base image

FROM debian:latest

# Install additional packages

RUN apk add --update emacs

RUN apk add --update apache

# index.html must be in the current directory

ADD index.html /home/demo/

# Define the command which runs when the container starts

CMD ["cat /home/demo/index.html"]

# Use bash as the container's entry point. CMD is the argument to this entry point

ENTRYPOINT ["/bin/bash", "-c"]

22

Images & Containers

● docker build ○ builds an image

● docker run ○ runs a container based off of an image

● Images are immutable (Like a Class)○ View these with docker images

● Containers are a ‘running instance of an Image’ (Like an Object)○ View these with docker ps

23

Docker Engine

● A client-server application○ Docker Daemon○ Docker CLI○ REST API

24

Docker Daemon

● Listens for Docker API requests● Manages Docker objects● The Daemon does not have to be on the

same machine as the Client

25

Docker CLI

● Communicates with Daemon using api● When you type:

docker build nginx

You are telling the Docker client to forward the build nginx

instruction to the Daemon

26

Docker Registries

• Store Docker Images• Docker Hub and Docker Cloud• GCP Container Registry

• docker pull• docker push

27

Useful, but Management?

● Containers can do many good things for us

● However, what do you still have to do manually?○ Load Balancing○ Fault Tolerance

● How should we do this?

28

Kubernetes● Kubernetes is an open-source platform for automating

deployment, scaling, and operations of application

containers.

○ Horizontal Scaling

○ Self-Healing

○ Service Discovery

○ Automated Rollbacks

○ Utilization

Kubernetes Overview

● API Objects○ Pods - Collection of Containers○ Deployment - Manages Pods○ Service - Network Endpoint

● Desired State Management○ YAML (YAML Ain’t a Markdown Language)

● Kubectl - CLI for Kubernetes○ kubectl create config.yaml

30

Kubernetes Cluster - Master

● Master Node○ API Server○ Controller Manager○ Scheduler

31

Kubernetes Cluster - Worker

● Worker Nodes○ Kubelet Daemon○ Kube-Proxy

32

apiVersion: apps/v1beta1kind: Podmetadata: name: Sample-Pod labels: app: webspec: containers: – name: front-end image: gcr.io/samples/hello-frontend:1.0 ports: – containerPort: 80 – name: hello-app image: gcr.io/samples/hello-app:1.0 ports: – containerPort: 8080

Sample Kubernetes Config YAML

33

Project 2.2 - Containers & Kubernetes

● Build a service to compile and run user code submitted through a front end.

● Five tasks:○ Task 1: Containerize an Nginx server and run container

locally.○ Task 2: Build a Python backend to run Python code.○ Task 3: Build a Python frontend service that makes requests

to the backend from task 2.○ Task 4: Multi-cloud deployment. The Python code

evaluation service will be replicated across clouds.○ Task 5: Implementing fault tolerance and autoscaling rules.

34

Task 1 - Docker

● Work with Dockerfiles● Master the Docker CLI, including useful

commands like:○ docker build○ docker images○ docker run○ docker ps

● Think about integration between the host and the container

35

Task 1 - Docker

● Configure a Docker container with an Nginx web server

● Nginx server listening on port 15619● Port 15619 of host VM mapped to the container

port

<ec2.***.amazonaws.com:15619> <nginx-container-1:80>

36

Task 2 - Code Execution Backend

● Developing a code execution backend○ Accepts Python code via HTTP POST requests○ Use the provided API specification to develop

your application■ Service that consumes and produces JSON

● Define a Kubernetes YAML configuration○ Deploy your application as a load balanced

service

37

Task 2 - Code Execution Backend

● Python code evaluation service architecture.

● The backend application accepts POST requests at /py/eval

38

Task 3 - Code Execution as a Service

● Deploy a code execution UI○ Modify the provided UI application to make POST

requests to the code evaluation service from Task 2.

● Modify your Kubernetes YAML configuration○ Application for a UI, exposed as a service via LB.○ Connects to the backend service running in the

same cluster.

39

Task 3 - Code Execution as a Service

● Python code evaluation service architecture.

● The UI is exposed on the internet, accepts GET / POST requests.

40

Task 4 - Multi-Cloud System

● Builds on Task 3. Introduces Kubernetes clusters in Azure.

● Replicate backend deployment to Azure cluster. Update frontend to route traffic to both clusters.

41

Task 4 - Multi-Cloud System

42

Task 5 - Fault Tolerance● Task 5 will build on Task 4

○ Same architecture, but have to consider downstream service failures.

● Achieve high availability!○ Multi cloud deployment! ○ Autoscaling Kubernetes deployments to

accommodated increased traffic due to failures.

○ HorizontalPodAutoscaler Kubernetes API object.

43

Tips, Trips, and Tricks

● Debug, debug, debug○ This project has many moving pieces!○ Where is the issue occurring?○ What is the expected behavior of the system?

● Pods and Logs○ Did my pod start?

■ (kubectl get pods , kubectl describe pods)○ Is my pod generating any logs?

■ (kubectl logs …)

44

Project 2.2 Penalties

45

Upcoming Deadlines

46

• Quiz 4: Modules 7, 8 and 9:

Due: Friday February 16, 2018 11:59PM Pittsburgh

• Project 2.2: Docker and Kubernetes

Due: Sunday February, 18 2018 11:59PM Pittsburgh

Questions?

47