Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kubernetes 硬起來
Search
Kyle Bai
February 16, 2019
Technology
1
160
Kubernetes 硬起來
- Kubernetes the hard way
- Kubernetes 核心元件
- Kubernetes 好用的 Addons 與 Projects
- 200+ Node 經驗分享
Kyle Bai
February 16, 2019
Tweet
Share
More Decks by Kyle Bai
See All by Kyle Bai
讓 Jenkins 老爺爺掌舵帶領開發者航向美好新世界
kairen
1
160
AWS Startup 2020 - AMIS
kairen
0
40
學習 Kubernetes 不是為了成為 YAML Engineer
kairen
0
250
How to make your container:Kubernetes is a bit more secure
kairen
0
140
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes(AWS))
kairen
0
67
Vishwakarma: Terraform modules for deploying EKS and Self-hosting Kubernetes
kairen
0
54
Chatbot as a Service on Container(Kubernetes)
kairen
0
820
IT IRONMAN 2020
kairen
0
54
Advanced Kubernetes For UMC
kairen
0
110
Other Decks in Technology
See All in Technology
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
500
iOS/Androidで同じUI体験をネ イティブで作成する際に気をつ けたい落とし穴
fumiyasac0921
1
110
スクラムチームを立ち上げる〜チーム開発で得られたもの・得られなかったもの〜
ohnoeight
2
350
Adopting Jetpack Compose in Your Existing Project - GDG DevFest Bangkok 2024
akexorcist
0
110
CysharpのOSS群から見るModern C#の現在地
neuecc
2
3.2k
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
SREが投資するAIOps ~ペアーズにおけるLLM for Developerへの取り組み~
takumiogawa
1
210
Lexical Analysis
shigashiyama
1
150
ノーコードデータ分析ツールで体験する時系列データ分析超入門
negi111111
0
410
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Faster Mobile Websites
deanohume
305
30k
Visualization
eitanlees
145
15k
What's new in Ruby 2.0
geeforr
343
31k
Side Projects
sachag
452
42k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Building Your Own Lightsaber
phodgson
103
6.1k
Automating Front-end Workflow
addyosmani
1366
200k
It's Worth the Effort
3n
183
27k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Done Done
chrislema
181
16k
Transcript
@k2r2bai Kubernetes 硬起來來 Cloud Native Taiwan User Group x openSUSE
Taiwan Meetup
@k2r2bai About Me ⽩白凱仁(Kyle Bai) • RDSS at inwinSTACK. •
Interested in emerging technologies. • Kubernetes Projects Contributor(200+ PR). • Certified Kubernetes Administrator. • CNTUG(Cloud Native Taiwan User Group) co-organizer • Kubernetes 200+ nodes experience @kairen(
[email protected]
) https://k2r2bai.com
@k2r2bai • Kubernetes the hard way • Kubernetes 核⼼心元件 •
Kubernetes 好⽤用的 Addons 與 Projects • 200+ Node 經驗分享 Agenda Today I would like to talk about
Kubernetes the hard way
@k2r2bai
@k2r2bai Kubernetes The Hard Way https://bit.ly/2GLxYFm
Kubernetes 核⼼心元件
@k2r2bai Kubernetes System Layers Nucleus: API and Execution Application Layer:
Deployment and Routing Governance Layer: Automation and Policy Enforcement Interface Layer: Client Libraries and Tools Ecosystem Container Runtime Network Plugin Volume Plugin Image Registry Cloud Provider Identity Provider Device Plugin
@k2r2bai Kubernetes Architecture UI CLI API Users Master Nodes etcd
scheduler controllers apiserver kubelet kube-proxy add-ons container runtime
@k2r2bai Etcd 是CoreOS 基於 Raft 開發的分散式 key-value 存儲,可⽤用於服務發現,共享配 置以及⼀一致性保障(如資料庫 Leader
election,分散式等等)。 etcd
@k2r2bai API server
@k2r2bai Kubernetes API 是以 JSON 作為其主要序列列化模型的 HTTP API,且能夠⽀支援協定快 取區,並⽤用於叢集內部溝通使⽤用。 •
提供叢集管理理的 REST API 介⾯面,⽤用來來進⾏行行資源 CRUD 操作、授權、認證與叢集狀狀態改變等。 • Kubernetes 有明確定義與規範 API。⽀支援 OpenAPI。 • 可擴展的 API。 • CRD(Custom Resource Definitions) • API server aggregation • Custom resources, controllers and apiservers Kubernetes API driven
Governance Layer: Automation and Policy Enforcement (APIs optional and pluggable)
Application Layer: Deployment and Routing (APIs required and pluggable) Nucleus: API and Execution (APIs required and not pluggable) CronJob batch/ v2alpha1 Job batch/v1 Deployment apps/v1 DaemonSet apps/v1 Pod core/v1 ReplicaSet apps/v1 StatefulSet apps/v1 ReplicationController core/v1 Endpoints core/v1 Ingress extensions/v1beta1 Service core/v1 ConfigMap core/v1 Secret core/v1 PersistentVolumeClaim core/v1 StorageClass storage/v1 ControllerRevision apps/v1 Event core/v1 LimitRange core/v1 ValidatingWebHookConfiguration admissionregistration/v1alpha1 HorizontalPodAutoscaler autoscaling/v1 APIService apiregistration/v1beta1 PodDisruptionBudget policy/v1beta1 PodPreset settings/v1alpha1 PodSecurityPolicy extensions/v1beta1 CertificateSigningRequest certificates/v1beta1 ClusterRole rbac/v1beta1 ClusterRoleBinding rbac/v1beta1 LocalSubjectAccessReview authorization/v1 Namespace core/v1 Node core/v1 PersistentVolume core/v1 ResourceQuota core/v1 Role rbac/v1beta1 RoleBinding rbac/v1beta1 SelfSubjectAccessReview authorization/v1 ServiceAccount core/v1 SubjectAccessReview authorization/v1 NetworkPolicy networking/v1 ComponentStatus core/v1 PriorityClass scheduling/v1alpha1 ClusterServiceBroker servicecatalog/v1beta1 ClusterServiceClass servicecatalog/v1beta1 ClusterServicePlan servicecatalog/v1beta1 ServiceInstance servicecatalog/v1beta1 ServiceBinding servicecatalog/v1beta1 MutatingWebHookConfiguration admissionregistration/v1alpha1 SelfSubjectRulesReview authorization/v1 TokenReview authentication/v1 CustomResourceDefinition apiextensions/v1beta1
@k2r2bai Controller Manager
@k2r2bai • 監聽資訊,以觀察實際狀狀態 • 找出抽象資源更更新差異異 • 驅使當前狀狀態 → 期望狀狀態 •
調解系統抽象資源狀狀態 • ⽀支援各種資源的 Controller,如 Deployments、 ReplicaSets 等等 Controller - Control loops observe diff act
@k2r2bai
@k2r2bai 負責將 Pod 排程到特定節點上,其⼯工作如下: • 你建立⼀一個 Pod • Scheduler 收到你建立的新
Pod 沒有被分配節點的通知 • Scheduler 將節點資訊塞到 Pod 中 • Kubelet 收到 Pod 更更新,發現裡⾯面(Pod.Spec.NodeName)有⾃自⼰己名稱,因此透過 Runtime 啟動容器 Scheduler
@k2r2bai 進⼀一步探討 Scheduler 流程 ❶ ❶ Watch for pods that:
• Are in PENDING phase • Have no Pod.Spec.NodeName assigned • Are explicitly requesting our scheduler (default otherwise)
進⼀一步探討 Scheduler 流程 ❷ ❷ Node selection algorithm(Filter and Rank):
• PodFitsHostPorts • … • LeastRequestedPriority • …
@k2r2bai 進⼀一步探討 Scheduler 流程 ❸ ❸ Post Pod <===> Node
binding to the API Server
@k2r2bai 進⼀一步探討 Scheduler 流程 ❹ ❹ Profit!!!
@k2r2bai Scheduler 選取節點流程 Host 1 Host 2 Host 3 Host
4 Host 5 Host 6
@k2r2bai Scheduler 選取節點流程 Host 1 Host 2 Host 3 Host
4 Host 5 Host 6 Host 1 Host 2 Host 3 Host 4 Host 5 Host 6 Predicate MatchNodeSelector PodSelectorMatches NoDiskConflict …
@k2r2bai Scheduler 選取節點流程 Host 1 Host 2 Host 3 Host
4 Host 5 Host 6 Host 1 Host 2 Host 3 Host 4 Host 5 Host 6 Predicate Host 2 Host 3 Host 4 Host 5 Priority Node Affinity Priority Selector Spread Priority Image Locality Priority …
@k2r2bai Scheduler 選取節點流程 Host 1 Host 2 Host 3 Host
4 Host 5 Host 6 Host 1 Host 2 Host 3 Host 4 Host 5 Host 6 Predicate Host 2 Host 3 Host 4 Host 5 Priority Host 3 Select
@k2r2bai kubelet • 每台 k8s 節點上都會執⾏行行 kubelet 程式 • kubelet
會在 API server 註冊節點資訊 • 定期向 Master 回報節點使⽤用情況(透過 cAdvisor 監控) • 接收並執⾏行行 Master 指令,如管理理 Pod、管理理 Container 與管理理 Volume 等 • 管理理 Static Pod 的⽣生命週期
@k2r2bai kube-proxy - services 功能實現者
@k2r2bai CoreDNS(kube-dns) • ⽤用 Go 語⾔言開發的 DNS server • Plugin
based 架構,⽅方便便擴展功能 • ⽀支援 DNS, DNS over TLS 與 DNS over gRPC • Caddy HTTP server fork • 專注 service discovery • 與 Kubernetes 原⽣生⽀支援
@k2r2bai
@k2r2bai Kubernetes 的容器引擎、網路路與儲存都是透過標準化的規範來來進⾏行行實作,開發者與 供應商只需要依據規範的介⾯面進⾏行行開發對應功能,就能夠與 Kubernetes 進⾏行行整合。 Built on standards(plugins)
@k2r2bai CRI 是 Kubernetes 社區提出的規範,由於隨著不同的容器引擎推成出新, Kubernetes 已不在只是管理理 Docker 的容器,CRI 將
Kubernetes 與具體容器實現進 ⾏行行解耦,來來增加 Kubernetes 的擴展。 Container Runtime Interface(CRI) https://github.com/kubernetes/kubernetes/tree/master/pkg/kubelet/server/streaming
@k2r2bai CNI 是 CNCF 容器網路路規範,更更是 Kubernetes 網路路插件基礎。其思想為在 Container Runtime 建立時,並建立
network namespace,之後呼叫 CNI 插件來來設 定 netns 網路路,最後提供給容器使⽤用。 Container Network Interface(CNI) https://github.com/containernetworking
@k2r2bai CSI 在今年正式進入 GA。其目標是制定一個標準容器儲存介面來提供給 SP(儲存供應 商)快速開發插件來在 Container Orchestration (CO) 系統上使用。
Container Storage Interface(CSI) https://github.com/kubernetes-csi
@k2r2bai Device Plugins 是 Kubernetes v1.8 加入的特性,⽬目標是以通⽤用介⾯面提供第三⽅方設備 廠商開發插件化⽅方式將裝置(如 GPU)資源串串接⾄至 Kubernetes
上,並且提供容器 Extended Resources。 ⽬目前關注度⾼高的 Device plugins: • NVIDIA device plugin for Kubernetes • AMD device plugin for Kubernetes • Solarflare Device Plugin Kubernetes Device Plugins
Kubernetes 好⽤用的 Addons 與 Projects
@k2r2bai Dashboard https://github.com/kubernetes/dashboard
@k2r2bai Monitoring: Prometheus + Grafana https://github.com/coreos/prometheus-operator
@k2r2bai
@k2r2bai Logging: EFK https://github.com/kubernetes/kubernetes/tree/master/cluster/addons/fluentd-elasticsearch
@k2r2bai
@k2r2bai Metrics Server 是實現了了資源 Metrics API 的元件,其⽬目標是取代 Heapster 作為 Pod
與 Node 提供資源的 Usage metrics,該元件會從每個 Kubernetes 節點上的 Kubelet 所公開的 Summary API 中收集 Metrics。 ⾸首先透過 kubectl 執⾏行行: $ kubectl top node $ kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes" | jq . Metrics Server https://github.com/kubernetes-incubator/metrics-server
@k2r2bai Ingress Controller 實現 Ingress 功能就是透過 Ingress Controller 來 達成︐它會負責監聽
Kubernetes API 中的 Ingress 與 Service 等資源物件︐並在發生資源變化時︐依 據資源預期的結果來設定 Proxy 到 Kubernetes 內 部 Service。
@k2r2bai • Ingress NGINX: Kubernetes 官⽅方維護的專案,也是本次安裝使⽤用的 Controller。 • F5 BIG-IP
Controller: F5 所開發的 Controller,它能夠讓管理理員透過 CLI 或 API 從 Kubernetes 與 OpenShift 管理理 F5 BIG-IP 設備。 • Ingress Kong: 著名的開源 API Gateway 專案所維護的 Kubernetes Ingress Controller。 • Træfik: 是⼀一套開源的 HTTP 反向代理理與負載平衡器,⽽而它也⽀支援了了 Ingress。 • Voyager: ⼀一套以 HAProxy 為底的 Ingress Controller。
@k2r2bai External DNS 是 Kubernetes 社區的孵化專案,被⽤用於定期同步 Kubernetes Service 與 Ingress
資源,並依據資源內容來來⾃自動設定公有雲 DNS 服務的資源紀錄(Record resources)。⽽而由於部署不是公有雲環境,因此需要透過 CoreDNS 提供⼀一個內部 DNS 伺服器,再由 ExternalDNS 與這個 CoreDNS 做串串接。 External DNS https://github.com/kubernet
@k2r2bai
@k2r2bai MetalLB hooks into your Kubernetes cluster, and provides a
network load- balancer implementation. • Address allocation. • External announcement. • Layer 2 mode (ARP for IPv4, NDP for IPv6). • Layer 3 mode (BGP). MetalLB https://metallb.universe.tf/
@k2r2bai Helm 是 Kubernetes Chart 的管理理⼯工具,Kubernetes Chart 是⼀一套預先組態的 Kubernetes 資源。其中Tiller
Server主要負責接收來來⾄至 Client 的指令,並透過 kube- apiserver 與 Kubernetes 叢集做溝通,根據 Chart 定義的內容,來來產⽣生與管理理各種 對應 API 物件的 Kubernetes 部署檔案(⼜又稱為 Release)。 Helm https://helm.sh/ https://helm.sh/
@k2r2bai Helm Hub https://hub.helm.sh/
200+ Node 經驗分享
@k2r2bai KAIREN OUT!! THANK YOU!!!
@k2r2bai • https://docs.google.com/spreadsheets/u/1/d/ 1LxSqBzjOxfGx3cmtZ4EbB_BGCxT_wlxW_xgHVVa23es/edit?usp=gmail • https://kubedex.com/kubernetes-network-plugins/ • https://docs.google.com/spreadsheets/d/1nAgDxQZYeAMLwz8iI3_aZ6lagDtEPg8X9PFqQvgtEjA/ edit?usp=drive_open&ouid=113275944218512027171 •
https://github.com/kelseyhightower/kubernetes-the-hard-way • https://www.cncf.io/certification/cka/ • https://github.com/walidshaari/Kubernetes-Certified-Administrator • https://github.com/hackstoic/kubernetes_practice • https://github.com/ramitsurana/awesome-kubernetes Refers