0%

Kubernetes模式

目录#

基础模式#

声明式的Deployment#

Rolling deployment, 滚动发布
Fixed deployment
Blue-green release, 蓝绿部署
Canary release, 灰度发布

受管理的声明周期#

SIGTERM Signal: SIGTERM 是通知进程优雅退出的信号
SIGKILL Signal: SIGKILL 是硬终止的信号
Poststart Hook
Prestop Hook

Kubernetes 中如何保证优雅地停止 Pod
Kubernetes 中如何保证优雅地停止 Pod
PingCAP 吴叶磊

行为模式#

Batch Job#

参考:
kube-batch

Singleton Service#
  • Out-of-application locking mechanism
    replicas =1

  • In-application locking mechanism:
    replicas>1 + 分布式锁

Stateful Service#

参考:

  • [Go to Page 2](k8sStatefulSet.md)     self
    
Service Discovery#
Name Configuration Client type Summary
ClusterIP type: ClusterIP
.spec.selector
Internal The most common internal discovery mechanism
Manual IP type: ClusterIP
kind: Endpoints
Internal External IP discovery
Manual FQDN type: ExternalName
.spec.externalName
Internal External FQDN discovery
Headless Service type: ClusterIP
.spec.clusterIP: None
Internal DNS-based discovery without a virtual IP
NodePort type: NodePort External Preferred for non-HTTP traffic
LoadBalancer type: LoadBalancer External Requires supporting cloud infrastructure
Ingress kind: Ingress External L7/HTTP-based smart routing mechanism

参考:

结构模式#

Init Container#
Sidecar#

场景:

高级模式#

控制器模式#

参考:
sample-controller 官方控制器的例子 git
kubebuilder git

Operator#
Elastic Scale#
  • 类型

    • VPA
    • HPA
    • CA
  • 资源模型概念

    • QoS
    • requests, limits

参考:

参考#

  1. 《Kubernetes Patterns - Reusable Elements for Designing Cloud-Native Applications》 Bilgin Ibryam@RedHat, Roland Huß@RedHat

  2. K8S 中的设计模式- 读《Kubernetes Patterns》

  3. Kubernetes Patterns