Kubernetes
  • 序言
  • 基礎入門
    • Kubernetes 簡介
    • Kubernetes 基本概念
    • Kubernetes 101
    • Kubernetes 201
    • Kubernetes 集群
  • 核心原理
    • 核心原理
    • 架構原理
    • 設計理念
    • 核心組件
      • etcd
      • kube-apiserver
      • kube-scheduler
      • kube-controller-manager
      • kubelet
      • kube-proxy
      • kube-dns
      • Federation
      • kubeadm
      • hyperkube
      • kubectl
    • 資源對象
      • Autoscaling
      • ConfigMap
      • CronJob
      • CustomResourceDefinition
      • DaemonSet
      • Deployment
      • Ingress
      • Job
      • LocalVolume
      • Namespace
      • NetworkPolicy
      • Node
      • PersistentVolume
      • Pod
      • PodPreset
      • ReplicaSet
      • Resource Quota
      • Secret
      • SecurityContext
      • Service
      • ServiceAccount
      • StatefulSet
      • Volume
  • 部署配置
    • 部署指南
    • kubectl 安裝
    • 單機部署
    • 特性開關
    • 最佳配置
    • 版本支持
    • 集群部署
      • kubeadm
      • kops
      • Kubespray
      • Azure
      • Windows
      • LinuxKit
      • kubeasz
    • 附加組件
      • Addon-manager
      • DNS
      • Dashboard
      • 監控
      • 日誌
      • Metrics
      • GPU
      • Cluster Autoscaler
      • ip-masq-agent
    • Kubernetes-The-Hard-Way
      • 準備部署環境
      • 安裝必要工具
      • 創建計算資源
      • 配置創建證書
      • 配置生成配置
      • 配置生成密鑰
      • 部署 Etcd 群集
      • 部署控制節點
      • 部署計算節點
      • 配置 Kubectl
      • 配置網絡路由
      • 部署 DNS 擴展
      • 煙霧測試
      • 刪除集群
  • 插件擴展
    • API 擴展
      • Aggregation
      • CustomResourceDefinition
    • 訪問控制
      • 認證
      • RBAC 授權
      • 准入控制
    • Scheduler 擴展
    • 網絡插件
      • CNI
      • Flannel
      • Calico
      • Weave
      • Cilium
      • OVN
      • Contiv
      • SR-IOV
      • Romana
      • OpenContrail
      • Kuryr
    • 運行時插件 CRI
      • CRI-tools
      • Frakti
    • 存儲插件
      • 容器存儲接口 CSI
      • FlexVolume
      • glusterfs
    • 網絡策略
    • Ingress Controller
      • Ingress + Letsencrypt
      • minikube Ingress
      • Traefik Ingress
      • Keepalived-VIP
    • Cloud Provider 擴展
    • Device 插件
  • 服務治理
    • 服務治理
      • 一般準則
      • 滾動升級
      • Helm
      • Operator
      • Service Mesh
      • Linkerd
      • Linkerd2
    • Istio
      • 安裝
      • 流量管理
      • 安全管理
      • 策略管理
      • 度量管理
      • 排錯
      • 社區
    • Devops
      • Draft
      • Jenkins X
      • Spinnaker
      • Kompose
      • Skaffold
      • Argo
      • Flux GitOps
  • 實踐案例
    • 實踐概覽
    • 資源控制
    • 集群高可用
    • 應用高可用
    • 調試
    • 端口映射
    • 端口轉發
    • 用戶管理
    • GPU
    • HugePage
    • 安全
    • 審計
    • 備份恢復
    • 證書輪換
    • 大規模集群
    • 大數據與機器學習
      • Spark
      • Tensorflow
    • Serverless
  • 排錯指南
    • 排錯概覽
    • 集群排錯
    • Pod 排錯
    • 網絡排錯
    • PV 排錯
      • AzureDisk
      • AzureFile
    • Windows 排錯
    • 雲平臺排錯
      • Azure
    • 排錯工具
  • 社區貢獻
    • 開發指南
    • 單元測試和集成測試
    • 社區貢獻
  • 附錄
    • 生態圈
    • 學習資源
    • 國內鏡像
    • 如何貢獻
    • 參考文檔
Powered by GitBook
On this page
  1. 插件擴展

API 擴展

Previous刪除集群NextAggregation

Last updated 1 year ago

Kubernetes 的架構非常靈活,提供了從 API、認證授權、准入控制、網絡、存儲、運行時以及雲平臺等一系列的,方便用戶無侵入的擴展集群的功能。

從 API 的角度來說,可以通過 Aggregation 和 CustomResourceDefinition(CRD) 等擴展 Kubernetes API。

  • API Aggregation 允許在不修改 Kubernetes 核心代碼的同時將第三方服務註冊到 Kubernetes API 中,這樣就可以通過 Kubernetes API 來訪問外部服務。

  • CustomResourceDefinition 則可以在集群中新增資源對象,並可以與已有資源對象(如 Pod、Deployment 等)相同的方式來管理它們。

CRD 相比 Aggregation 更易用,兩者對比如下

CRDs
Aggregated API

無需編程即可使用 CRD 管理資源

需要使用 Go 來構建 Aggregated APIserver

不需要運行額外服務,但一般需要一個 CRD 控制器同步和管理這些資源

需要獨立的第三方服務

任何缺陷都會在 Kubernetes 核心中修復

可能需要定期從 Kubernetes 社區同步缺陷修復方法並重新構建 Aggregated APIserver.

無需額外管理版本

需要第三方服務來管理版本

更多的特性對比

Feature
Description
CRDs
Aggregated API

Validation

Help users prevent errors and allow you to evolve your API independently of your clients. These features are most useful when there are many clients who can’t all update at the same time.

Yes, arbitrary validation checks

Defaulting

See above

Yes, via a Mutating Webhook; Planned, via CRD OpenAPI schema.

Yes

Multi-versioning

Allows serving the same object through two API versions. Can help ease API changes like renaming fields. Less important if you control your client versions.

No, but planned

Yes

Custom Storage

If you need storage with a different performance mode (for example, time-series database instead of key-value store) or isolation for security (for example, encryption secrets or different

No

Yes

Custom Business Logic

Perform arbitrary checks or actions when creating, reading, updating or deleting an object

Yes, using Webhooks.

Yes

Scale Subresource

Allows systems like HorizontalPodAutoscaler and PodDisruptionBudget interact with your new resource

Yes

Status Subresource

Finer-grained access control: user writes spec section, controller writes status section.Allows incrementing object Generation on custom resource data mutation (requires separate spec and status sections in the resource)

Yes

Other Subresources

Add operations other than CRUD, such as “logs” or “exec”.

No

Yes

strategic-merge-patch

No, but similar functionality planned

Yes

Protocol Buffers

The new resource supports clients that want to use Protocol Buffers

No

Yes

OpenAPI Schema

Is there an OpenAPI (swagger) schema for the types that can be dynamically fetched from the server? Is the user protected from misspelling field names by ensuring only allowed fields are set? Are types enforced (in other words, don’t put an int in a string field?)

No, but planned

Yes

使用方法

詳細的使用方法請參考

Yes. Most validation can be specified in the CRD using . Any other validations supported by addition of a Validating Webhook.

The new endpoints support PATCH with Content-Type: application/strategic-merge-patch+json. Useful for updating objects that may be modified both locally, and by the server. For more information, see

擴展機制
Aggregation
CustomResourceDefinition
OpenAPI v3.0 validation
Yes
Yes
“Update API Objects in Place Using kubectl patch”