kubernetes20151017a

Post on 22-Jan-2018

353 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Kubernetes

a study note

Outline

• Container– Docker, Rocket, LXC/LXD, …

• Cluster– CoreOS

• Cluster Management– Kubernetes, ...

• Demo– Vagrant, Google Cloud

2

rocket

20151021 cc by-nc 3.0

Container

• An isolated Linux execution environment.

• leverages OS virtualization.

• runs in different OS, cloud providers.

320151021 cc by-nc 3.0

CoreOS

• Light weight OS based on Linux

• Distributed storage

• Auto-update

420151021 cc by-nc 3.0

CoreOS

20151021 cc by-nc 3.0 5

etcd

write:$ etcdctl set /message Hello

or

$ curl -L -X PUT http://127.0.0.1:4001/v2/keys/message -d value="Hello"

read: $ etcdctl get /message

or

$ curl -L http://127.0.0.1:4001/v2/keys/message

20151021 cc by-nc 3.0 6

fleet

Manage nodes, pods, services via fleetctl

COMMANDS:

cat Output the contents of a submitted unit

destroy Destroy one or more units in the cluster

fd-forward Proxy stdin and stdout to a unix domain socket

help Show a list of commands or help for one command

journal Print the journal of a unit in the cluster to stdout

list-machines Enumerate the current hosts in the cluster

list-unit-files List the units that exist in the cluster.

list-units List the current state of units in the cluster

load Schedule one or more units in the cluster, first submitting them if necessary.

ssh Open interactive shell on a machine in the cluster

start Instruct systemd to start one or more units in the cluster, first submitting and loading if necessary.

status Output the status of one or more units in the cluster

stop Instruct systemd to stop one or more units in the cluster.

submit Upload one or more units to the cluster without starting them

unload Unschedule one or more units in the cluster.

verify DEPRECATED - No longer works

version Print the version and exit

20151021 cc by-nc 3.0 7

820151021 cc by-nc 3.0

Why?

Challenges:• Commodity hardware not reliable• App execution environment moves around• Different developing and deployment software stacks, and many best

practices• Varies events occur at wide geographic area that effects our context, the

information are different type, changes very fast, large amount

Containers, Cluster OS and management system can help us to deal with the problems.

920151021 cc by-nc 3.0

1020151021 cc by-nc 3.0

Kubernetes

• Is a platform for hosting containers in a clustered environment with multiple hosts

• Provides container grouping, load balancing, auto scaling, and self-healing

• Started by Google,

[google white paper]:http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43438.pdf

20151021 cc by-nc 3.0 11

1220151021 cc by-nc 3.0

http://blog.arungupta.me/wp-content/uploads/2015/01/kubernetes-architecture.png

Kubernetes Architecture

1320151021 cc by-nc 3.0

Main Components

Master• maintains state of kubernetes server

with etcd.• is the entry point of Kubernetes

client to configure and manage Nodes, Pods, Replicators, Services.

• reconcile the difference between the current state and desired state.

Worker Node• run a command from master node• report current node state

20151021 cc by-nc 3.0 14

Master

Replication Controller

• Uses Pod Templates to create Pods

• Uses Label to monitor and maintain the desired Pods level at any one time

Service Registry

• Is a wrapper on top of etcd persistent storage, which keep track of services

• can be performed on registry: create service, update, delete, ...

API Server

• Scheduler

• AuthenticationDistributed Watchable Storage

• States of Kubernetes

• Configuration

• Watch changes

20151021 cc by-nc 3.0 15

Work Node

Service

• An abstraction layer defined a logic set of Pods and access policy to deliver the functions.

• Selector gets a set of Pods per their Labels.

• Elements of service: Name, Port of Proxy, Selector, Uses load balance

Pod

• Label

• Share Volume

• visible IP

• single or multiple containers

• template

20151021 cc by-nc 3.0 16

Kubectl

• run on each node, manage life cycle of Pods

• 1:1 map to host

• communicate among themselves to keep information up to date, data is stored in a distributed, watchable storage

• main elements:

– cAdviser: monitor and display Pods status

– etcd client: interface with central storage

– docker client: for create, start, stop, delete container

Functions:

• run a action on a Pod

• bind a Volume to container

• bind ports to containers

• provide container health information

• interface with host

20151021 cc by-nc 3.0 17

Demo

1820151021 cc by-nc 3.0

Kubernetes on gcloud

## create a cluster ➜ gcloud container clusters create guestbook

## create redis master controller ➜ kubectl create -f redis-master-controller.json`

## get pods info ➜ kubectl get pods -l name=redis-master

## login container ➜ gcloud compute ssh gke-guestbook-7dc33b44-node-9tlv

## get available docker images rkuo@gke-guestbook-7dc33b44-node-9tlv:~$ sudo docker images

## create redis master service ➜ kubectl create -f redis-master-service.json`

## create the guestbook web server pods

## create frontend controller ➜ kubectl create -f frontend-controller.json

## start frontend web service: ➜ kubectl get services

20151021 cc by-nc 3.0 19

Thank You!

richard kuo

2020151021 cc by-nc 3.0

2120151021 cc by-nc 3.0

20151021 cc by-nc 3.0 22

top related