作者 | 平名 阿里服務端開發技術專家
導讀:Kubernetes 作爲雲原生時代的“操作系統”,熟悉和使用它是每名用戶的必備技能。本篇文章概述了容器服務 Kubernetes 的知識圖譜,部分內容參考了網上的知識圖譜,旨在幫助用戶更好的瞭解 K8s 的相關知識。
概述
容器服務 Kubernetes 知識圖譜,部分內容參考網上一知識圖譜,更加結合阿里雲容器服務。
原圖 by 楊傳勝
原圖鏈接地址https://www.processon.com/view/link/5ac64532e4b00dc8a02f05eb#map
知識鏈接和備註
Docker 原理
- KVM--> ECS
https://blog.csdn.net/weixin_43695104/article/details/88554443#32_kvm_web_192
- 網絡隧道技術-->VPC
https://blog.csdn.net/wangjianno2/article/details/75208036
- NameSpace
https://blog.csdn.net/a352193394/article/details/53344167
備註:Linux 容器中用來實現“隔離”的技術手段:Namespace,Namespace 技術實際上修改了應用進程看待整個計算機的範圍,它的訪問範圍被操作系統做了限制,只能“看到”某些指定的內容。
- CGroup
https://blog.csdn.net/wudongxu/article/details/8474198
備註:Linux Control Group。它最主要的作用,就是限制一個進程組能夠使用的資源上限,包括 CPU、內存、磁盤、網絡帶寬等等。
- RootFS(Union FS)
https://coolshell.cn/articles/17061.html
備註:rootfs 只是一個操作系統所包含的文件、配置和目錄,並不包括操作系統內核。在 Linux 操作系統中,這兩部分是分開存放的,操作系統只有在開機啓動時纔會加載指定版本的內核鏡像。
- windows 2019
備註:windowserver 2019開始支持 namespace
容器服務部署
- Docker Desktop
https://www.docker.com/products/docker-desktop
備註:Mac 機器上強烈建議安裝該軟件作爲學習使用
- kubernetes
http://docs.kubernetes.org.cn/
備註:kubernetes 集羣,aliyun容器服務支持
- DashBoard
https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
備註:kubernetes 集羣的圖形界面管理工具,容器服務控制檯整合了該應用並擴展
- EasyPack
https://github.com/liumiaocn/easypack
備註:一批部署 kubernetes 等集羣的腳本集合
- minikube
https://kubernetes.io/docs/tasks/tools/install-minikube/
備註:mini 新 K8s
工具組件
- kubectl
http://docs.kubernetes.org.cn/61.html
備註:kubectl 用於運行 Kubernetes 集羣命令的管理工具
- kubeadm
https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/Kubernetes
備註:官方提供的用於快速安裝配置 Kubernetes 集羣的工具
- Helm
備註:類似 rpm,yum,是 K8s 用於安裝組件(軟件包:chart)的工具
- APP Hub
https://developer.aliyun.com/hub
備註:在開放雲原生應用中心當中,所有默認的 Helm Charts(Helm 格式的應用),都定時同步自 Helm Hub 北美官方站並託管在 Github 上。在這個過程中,雲原生應用中心會自動對同步過來的所有 Charts 進行“本地化”操作。
- CFSSL
https://github.com/cloudflare/cfssl
備註:CFSSL 是開源的一款 PKI/TLS 工具,常用於 K8s 證書製作
- aliyun 私有鏡像倉庫
https://cr.console.aliyun.com/aliyun
備註:推出的鏡像倉庫,建議採用企業版
- 雲效配置鏡像倉庫
https://cn.aliyun.com/product/yunxiao
備註:雲效企業設置,配置支持從阿里雲私有鏡像倉庫拉取鏡像
- Harbor 鏡像倉庫
https://goharbor.io
備註:開源免費的存儲和分發Docker鏡像的企業級Registry服務器
組件
- kube-apiserver(Master)
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/
備註:在 generic server 上封裝的一層官方默認的 apiserver(static pod)
- etcd(Master)
https://etcd.io
備註:類 zk 基於 Raft 協議的實現,啓動進程
- Kube-scheduler(Master)
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-scheduler/
備註:負責 pod 分佈到 Node 上的調度器 (static pod)
- kube-controller-manager(Master)
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-controller-manager/
備註:Deployment 等基礎對象的控制器 (static pod)
- cloud-controller-manager(Master)
https://kubernetes.io/docs/reference/command-line-tools-reference/cloud-controller-manager/
備註:用於雲資源使用的控制器,是雲服務進行集成的控制器 (Daemonset)
- kubelet(Node)
https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/
備註:與 Master 通信,對 worker(Node) 進行生命週期管理
- kube-proxy(Node)
https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/
備註:節點上運行的網絡代理 (Daemonset)
- containner runtime(Node)
備註:CRI 接口
- DNS
https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/
備註:aliyun容器服務採用 CoreDNS(deployment)
- Ingress controller
https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/
備註:aliyun容器服務採用nginx ingress controller, 可以作爲 https 服務的統一路由(deployment)
- Heapster & influxdb
備註:監控數據採集與存儲用的時序數據庫(Deployment)
- Federation
https://kubernetes.io/docs/concepts/cluster-administration/federation/
備註:集羣聯盟,實現高可用,同步資源等
- kube-flannel
備註:官方網絡插件,aliyun 另外提供了自己開發的 Terway 組件(daemonset)
- logtail
https://help.aliyun.com/document_detail/28979.html?spm=a2c4g.11186623.6.595.439d7218wQhzsH
備註:aliyun 日誌採集組件 (daemonset)
基礎對象
- POD
http://docs.kubernetes.org.cn/312.html 容器組,運行應用容器基本單位,kubectl get pods
- Node
http://docs.kubernetes.org.cn/304.html集羣節點服務器,Kubernetes中的工作節點。
- NameSpace
http://docs.kubernetes.org.cn/242.html備註:用以區分和隔離應用
- Deployement
http://docs.kubernetes.org.cn/317.html
備註:無狀態部署,最常用部署配置
- Daemonset
https://kubernetes.io/docs/concepts/workloads/controllers/daemonset/
備註:類似守護進程
- StatefulSet
http://docs.kubernetes.org.cn/443.html
備註:有狀態部署
- Job & CronJob
https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/
備註:調度任務
- Static POD
https://kubernetes.io/docs/tasks/configure-pod-container/static-pod/
備註:靜態 pod 配置,yaml 位於 Master
- HPA
https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/
備註:水平伸縮調度器
- Service
https://kubernetes.io/docs/concepts/services-networking/service/
備註:服務暴露配置,包括 Cluster,NodePort,SLB 等
- Ingress
https://www.kubernetes.org.cn/1885.html
備註:路由,阿里雲默認提供 nginx ingress
- Secret
https://kubernetes.io/docs/concepts/configuration/secret/
備註:保密字典,包括 tls,私有倉庫密鑰,Opaque 幾種
- ServiceAccount
https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/
備註:用於資源對象的賬號,比如給一個 Namespace 授予某私有鏡像訪問權限
- RBAC
https://kubernetes.io/docs/reference/access-authn-authz/rbac/
備註:K8s 基於角色的訪問控制,role,rolebinding
- Volume
https://kubernetes.io/docs/concepts/storage/volumes/
備註:映射磁盤
- Storge Class
https://kubernetes.io/docs/concepts/storage/storage-classes/
- CustomResourceDefinition
備註:自定義擴展資源
插件擴展
- CNI(Falnnel/Terway)
https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/
備註:容器網絡接口
- FlexVolume
https://github.com/fstab/cifs
備註:開源 Volume 實現插件,阿里雲使用中
- Cloud Provider
備註:雲服務供應接口
容器服務優化-最佳實踐
- Master 選型及磁盤規格
[1] https://yq.aliyun.com/articles/599169?spm=5176.11065265.1996646101.searchclickresult.7bea1a8bgCTYH7
[2] https://yq.aliyun.com/articles/621108?
- 網絡選擇
https://yq.aliyun.com/articles/594943?
- Worker 節點選型
https://yq.aliyun.com/articles/602932?spm=a2c4e
-
Ingress Controller 獨立部署
- Master 變配
- 節點變配或重啓、摘除、加入
- 基礎鏡像開發
-
Service 與 SLB 結合
- 集羣審計
- Deployment實現分批發布
- StatefulSet 分批發布
https://yq.aliyun.com/articles/622898?spm=a2c4e.11155435.0.0.1b8e3312bSGmSe
- 堡壘機上按照應用設置權限
https://yq.aliyun.com/articles/715809
- Pod 均勻分佈部署
https://yq.aliyun.com/articles/715808
- 應用優雅下線,優雅退出
- ApiServer 訪問
- 監控
服務治理
- Istio
https://istio.io
備註:當前最流行的網格服務架構,aliyun 支持
- Linkerd
https://linkerd.io/2/overview/
備註:最早提出網格服務公司的產品
- 雲效
https://www.aliyun.com/product/yunxiao
備註:支持容器服務 K8s 的 CI/CD 阿里雲上產
- Jenkins
https://jenkins.io/zh/
備註:著名的最常用的 CI/CD 產品,容器服務由一鍵安裝產品
雲原生技術公開課
https://edu.aliyun.com/roadmap/cloudnative
備註:阿里雲聯合 CNCF (雲原生計算基金會)共同開發了本套雲原生技術公開課,課程全程免費!
『本文轉載自阿里雲開發者社區』
原文鏈接:
https://developer.aliyun.com/article/715805?utm_content=g_1000073582