5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod...

28

Transcript of 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod...

Page 1: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl
Page 2: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl
Page 3: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl
Page 4: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

青云QingCloud 容器及 Kubernetes 实践王渊命 | 青云QingCloud 容器平台负责人

Page 5: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

当我们谈论容器时我们在谈论什么?

Page 6: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

容器的两个视角

►资源隔离

►应用封装

Page 7: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

► 容器技术一家独大百花齐放

► Docker, Rocket, Mesos Universal container, LXC, Hyper Container

► Kubernetes, Mesos, Swarm

2016 Docker, Kubernetes, Mesos http://jolestar.com/container-ecosystem/

容器生态圈现状

Page 8: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Container@QingCloud

►资源视角

►应用视角

Page 9: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Container@QingCloud — 资源视角

►QingCloud IaaS

Container Instance

Hardware�

HostOS�

Hypervisor�

GuestOS�

Applica6ons�

Applica6ons�

VirtualInstance� ContainerInstance�

Page 10: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Container@QingCloud — 应用视角"container": { "type": "docker", "image": "zookeeper"}►AppCenter 支持

Docker 镜像

Page 11: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Container@QingCloud — 应用视角

►AppCenter 支持各

种容器编排系统

Page 12: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes@QingCloud

网络 存储 负载均衡 弹性

Page 13: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 概览

PodPod

schedulingactuator

RESTpods,services,

rep.contollers)

authenticationauthorization

kubectluser commands

SchedulerScheduler

controller manager

APIs

Master componentsDistributedWatchable

Storage(implemented via etcd)

kubelet Proxy

cAdvisorcAdvisor

cAdvisorcontainer

cAdvisorcontainer

Firewall

Internet

Pod

docker

Node

PodPod

kubelet Proxy

cAdvisorcAdvisor

cAdvisorcontainer

cAdvisorcontainer

Pod

docker

Node

Page 14: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 抽象概念

Service StatefulSet(PetSet)

Job PersistentVolume

ReplicaSet(ReplicationController) PersistentVolumeClaim

Deployment Namespace

DaemonSet Label/Selector

Page 15: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes • CNI (Container Network

Interface)

- Flannel

- Calico

- Contiv

• ClusterIP

- Virtual IP

- Iptables

► 容器之间可以直接互通,不需要 NAT

► 节点可以喝容器直接互通,不需要 NAT

► 容器看到自己的 IP 应该和其他容器看到的一样

Page 16: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 网络之 ClusterIP{ "kind": "Service", "apiVersion": "v1", "metadata": { "name": "my-service" }, "spec": { "selector": { "app": "MyApp" }, "ports": [ { "protocol": "TCP", "port": 80, "targetPort": 9376 } ] "clusterIP": "10.0.171.239", "type": “LoadBalancer /NodePort" } }

Page 17: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes flannel► Discovery

• etcd

• kube-subnet-mgr

► Backend

• vxlan

• aws-vpc

Page 18: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 网络之 QingCloud

VPCPod

Pod

Nic1(192.168.1.10)

Nic1(192.168.1.11)

NicX(192.168.1.X)

...

Nic0(192.168.0.10)

PodNode1

LoadBalancer

Internet

Legacy App VM1

Public LoadBalancer

Pod

Pod

Nic1(192.168.2.10)

Nic1(192.168.2.11)

NicX(192.168.2.X)

...

Nic0(192.168.0.11)

PodNode2

Page 19: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 存储

Container(MySQL)

Node1 LocalDisk

Container(MySQL)

Node2 LocalDisk

Controller Manager

X

scheduler

Container(MySQL)

Node1

DistributeDisk

Container(MySQL)

Node2

Controller Manager

OK

scheduler

Page 20: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes ► DistributeDisk

• nfs

• ceph

• glusterfs

• PersistentVolume plugin - gcePersistentDisk

- awsElasticBlockStore

- qingCloudStore

Page 21: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 存储之 QingCloudStore► PersistentVolume Plugin

► PersistentVolume

► StorageClass

► PersistentVolumeClaim

Page 22: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 存储之 QingCloudStorekind: PersistentVolume apiVersion: v1 metadata: name: qingcloud-pv labels: type: qingcloud spec: capacity: storage: 10Gi accessModes: - ReadWriteOnce qingCloudStore: volumeID: vol-caoxtgg3 fsType: ext4

kind: PersistentVolumeClaimapiVersion: v1 metadata: name: qingcloud-pvc annotations: volume.beta.kubernetes.io/storage-class: qingcloud-storageclassspec: accessModes: - ReadWriteOnce resources: requests: storage: 3Gi

kind: StorageClassapiVersion: storage.k8s.io/v1beta1 metadata: name: qingcloud-storageclassprovisioner: kubernetes.io/qingcloud-volume parameters: type: "3"

Page 23: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 负载均衡器Internet

LoadBalancer

kube-proxy/iptables

NodePort

B

B

kube-proxy/iptables

NodePort

B

Page 24: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 之 QingCloudLB

VPCPod

Pod

Nic1(192.168.1.10)

Nic1(192.168.1.11)

NicX(192.168.1.X)

...

Nic0(192.168.0.10)

PodNode1

LoadBalancer

Internet

Legacy App VM1

Public LoadBalancer

Pod

Pod

Nic1(192.168.1.10)

Nic1(192.168.1.11)

NicX(192.168.1.X)

...

Nic0(192.168.0.10)

PodNode1

Page 25: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes 自动伸缩► Deployment

► 集群的自动伸缩 TriggeredScaleUp Event

kubectl autoscale deployment php-apache --cpu-percent=50 --min=1 --max=10

gcloud container clusters create mytestcluster \—zone=us-central1-b --enable-autoscaling --min-nodes=3 --max-nodes=10 --num-nodes=5

Page 26: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

Kubernetes@QingCloud

► 网络 (SDN Passthrough)

► 存储 (PersistentVolumePlugin)

► 负载均衡 (LB + SDN)

► 自动伸缩 (Event + IaaS API)

Page 27: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl

计划► 5 月份公开试用

► AppCenter 支持 Kubernetes 应用规范

► Kubernetes 之上的服务

Page 28: 5.青云QingCloud 容器及 Kubernetes 实践 · 2017-05-15 · Kubernetes 概览 Pod Pod scheduling actuator REST pods,services, rep.contollers) authentication authorization kubectl