通过腾讯案例研究深入了解 Cluster API

Cluster API 是一种 Kubernetes 项目,它将声明式 Kubernetes 风格的 API 引入集群管理中。它在 Kubernetes 核心功能之上还提供可选的附加功能。它尝试处理当前堆栈中分散的基础设施层。 在本次联合演讲中,Feng Min 将重温当下基础设施情况,并探寻集群 API 是如何融入其中的。Feng 还将研究集群 API 的结构,比如机器设备 / 机器部署,并查看它们如何帮助像升级这样的公共集群操作。作为一项案例研究,Zhiguo Hong 将讨论腾讯云如何支持集成,以及如何应用集群 API 来管理腾讯云中的 k8s 集群。 观众将清晰了解集群 API 架构以及如何将当前的集群管理转换为 Cluster API 的世界。
展开查看详情

1.Cluster API Deep Dive With a Tencent Case Study

2.闵峰 Feng Min 洪志国 Zhiguo Hong Staff Software Engineer at Google Software Architect at Tencent Cloud. Kubernetes team.

3. Agenda • What’s Cluster API • Upgrade as example • Bootstrapping • How to deploy • Demo

4.Where we are ● Cluster Management is a hard job. ● Fragmented tooling and ecosystem. ● Too many tools to choose from. ● Reinventing wheels.

5.What’s Cluster API? ● Cluster Declarative API ● Machine ● Machine Set + Machine Deployment ● Machine Lifecycle (incl. Provisioning) Common Logic ● Machine Upgrade ● Infrastructure platform (vSphere, GCP, AWS, etc.) Pluggable Architecture ● Support for various Operating Systems ● Cluster Bootstrapping, Upgrade Tooling, Services ● Auto-scaling, Repair, Node Auto-provisioning

6.What’s Cluster API Cluster Config with Declarative API

7. What is configured? apiVersion: "cluster-api.k8s.io/v1alpha1" ● Cluster-level Configuration kind: Cluster ○ Network metadata: • Machine setup name: kubecon-demo • # of machines? spec: • Platform-specific clusterNetwork: configuration services: • GCP project, machine type cidrBlocks: ["10.96.0.0/12"] • Software on those machines pods: • Kubelet Version cidrBlocks: ["192.168.0.0/16"] • Control Plane serviceDomain: "cluster.local"

8. What is configured? apiVersion: "cluster.k8s.io/v1alpha1" ● Cluster-level Configuration kind: MachineSet ○ Network metadata: • Machine setup name: my-first-machineset • # of machines? spec: • Platform-specific replicas: 3 configuration template: • GCP project, machine type metadata: • Software on those machines spec: • Kubelet Version ... • Control Plane roles: - Node

9. What is configured? apiVersion: "cluster.k8s.io/v1alpha1" ● Cluster-level Configuration kind: Machine ○ Network metadata: • Machine setup name: gce-master-kubecon • # of machines? spec: • Platform-specific providerConfig: > configuration { • GCP project, machine type "project": "gke-kubecon", • Software on those machines "zone": "us-central1-f", • Kubelet Version "machineType": "n1-standard-2", • Control Plane "image": "/path/to/ubuntu-1604-lts" }

10. What is configured? apiVersion: "cluster.k8s.io/v1alpha1" ● Cluster-level Configuration kind: Machine ○ Network metadata: • Machine setup name: gce-master-kubecon • # of machines? spec: • Platform-specific providerConfig: { configuration ... • GCP project, machine type } • Software on those versions: machines kubelet: 1.7.4 • Kubelet Version controlPlane: 1.7.4 • Control Plane

11.What’s Cluster API Tooling, YAML, CRDs, Controllers

12.Logical Flow - YAML to Objects

13.Logical Flow - Objects to Machines

14.Case Study: Upgrade How do we upgrade K8s Cluster using Cluster API?

15.Upgrade MachineDeployment - replicas: 3 - nodes: MyNodes - maxSurge: 1 - maxUnavailable: 0 - version: v1.8.3

16.Upgrade MachineDeployment - replicas: 3 - nodes: MyNodes - maxSurge: 1 - maxUnavailable: 0 - version: v1.9.3

17. Upgrade MachineSet - replicas: 3 - version: v1.8.3 - selector: - nodes: MyNodes

18. Upgrade MachineSet MachineSet - replicas: 3 - replicas: 0 - version: v1.8.3 - version: v1.9.3 - selector: - selector: - nodes: MyNodes - nodes: MyNodes

19. Upgrade MachineSet MachineSet - replicas: 3 - replicas: 1 - version: v1.8.3 - version: v1.9.3 - selector: - selector: - nodes: MyNodes - nodes: MyNodes

20. Upgrade MachineSet MachineSet - replicas: 2 - replicas: 2 - version: v1.8.3 - version: v1.9.3 - selector: - selector: - nodes: MyNodes - nodes: MyNodes

21. Upgrade MachineSet MachineSet - replicas: 1 - replicas: 3 - version: v1.8.3 - version: v1.9.3 - selector: - selector: - nodes: MyNodes - nodes: MyNodes

22. Upgrade MachineSet MachineSet - replicas: 0 - replicas: 3 - version: v1.8.3 - version: v1.9.3 - selector: - selector: - nodes: MyNodes - nodes: MyNodes

23.Bootstrapping How to get cluster api components up and running?

24.Bootstrapping - 10 km view CLI User Local Temporary Control External Cluster Plane

25.Bootstrapping - 10 km view CLI User Local Temporary Control External Cluster Plane Machine Controller Cluster Controller

26.Bootstrapping - 10 km view CLI User Local Temporary Control External Cluster Plane Machine Machine A Controller Cluster Cluster A Controller

27.Bootstrapping - 10 km view Control CLI User Cluster Plane Local Temporary Control External Cluster Plane Machine Machine A Controller Cluster Cluster A Controller

28.Bootstrapping - 10 km view Control CLI User Cluster Plane Machine A Local Temporary Control External Cluster Plane Cluster A Machine Machine A Controller Cluster Cluster A Controller

29.Bootstrapping - 10 km view Control CLI User Cluster Plane Machine Machine A Controller Local Temporary Control External Cluster Plane Cluster Cluster A Machine Controller Machine A Controller Cluster Cluster A Controller