2020-06-19 14:52:56 +08:00
<!DOCTYPE HTML>
< html lang = "zh-hans" >
< head >
< meta charset = "UTF-8" >
< meta content = "text/html; charset=utf-8" http-equiv = "Content-Type" >
< title > Deployment · Kubernetes Handbook - Kubernetes中文指南/云原生应用架构实践手册 by Jimmy Song(宋净超)< / title >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" / >
< meta name = "description" content = "" >
< meta name = "generator" content = "GitBook 3.2.3" >
< meta name = "author" content = "Jimmy Song( 宋净超) " >
< link rel = "stylesheet" href = "../gitbook/style.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-splitter/splitter.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-page-toc-button/plugin.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-image-captions/image-captions.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-back-to-top-button/plugin.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-search-plus/search.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-prism/prism-ghcolors.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-lightbox/css/lightbox.min.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-alerts/style.css" >
< link rel = "stylesheet" href = "../gitbook/gitbook-plugin-fontsettings/website.css" >
< meta name = "HandheldFriendly" content = "true" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1, user-scalable=no" >
< meta name = "apple-mobile-web-app-capable" content = "yes" >
< meta name = "apple-mobile-web-app-status-bar-style" content = "black" >
< link rel = "apple-touch-icon-precomposed" sizes = "152x152" href = "../gitbook/images/apple-touch-icon-precomposed-152.png" >
< link rel = "shortcut icon" href = "../gitbook/images/favicon.ico" type = "image/x-icon" >
< link rel = "next" href = "statefulset.html" / >
< link rel = "prev" href = "controllers.html" / >
< link rel = "shortcut icon" href = '../favicon.ico' type = "image/x-icon" >
< link rel = "bookmark" href = '../favicon.ico' type = "image/x-icon" >
< style >
@media only screen and (max-width: 640px) {
.book-header .hidden-mobile {
display: none;
}
}
< / style >
< script >
window["gitbook-plugin-github-buttons"] = {"repo":"rootsongjc/kubernetes-handbook","types":["star"],"size":"small"};
< / script >
< / head >
< body >
< div class = "book" >
< div class = "book-summary" >
< div id = "book-search-input" role = "search" >
< input type = "text" placeholder = "输入并搜索" / >
< / div >
< nav role = "navigation" >
< ul class = "summary" >
< li >
< a href = "https://jimmysong.io" target = "_blank" class = "custom-link" > 回到主页< / a >
< / li >
< li >
< a href = "https://jimmysong.io/awesome-cloud-native" target = "_blank" class = "custom-link" > Awesome Cloud Native< / a >
< / li >
< li >
< a href = "https://cloudnative.to" target = "_blank" class = "custom-link" > 云原生社区< / a >
< / li >
< li >
< a href = "https://cloudnativeindustryalliance.github.io/whitepaper2020/" target = "_blank" class = "custom-link" > 中国云原生发展白皮书2020< / a >
< / li >
< li >
< a href = "https://jimmysong.io/guide-to-cloud-native-app/" target = "_blank" class = "custom-link" > 云原生应用白皮书< / a >
< / li >
< li class = "divider" > < / li >
< li class = "header" > 前言< / li >
< li class = "chapter " data-level = "1.1" data-path = "../" >
< a href = "../" >
< b > 1.1.< / b >
序言
< / a >
< / li >
< li class = "header" > 云原生< / li >
< li class = "chapter " data-level = "2.1" data-path = "../cloud-native/cloud-native-definition.html" >
< a href = "../cloud-native/cloud-native-definition.html" >
< b > 2.1.< / b >
云原生( Cloud Native) 的定义
< / a >
< / li >
< li class = "chapter " data-level = "2.2" data-path = "../cloud-native/cloud-native-philosophy.html" >
< a href = "../cloud-native/cloud-native-philosophy.html" >
< b > 2.2.< / b >
云原生的设计哲学
< / a >
< / li >
< li class = "chapter " data-level = "2.3" data-path = "../cloud-native/play-with-kubernetes.html" >
< a href = "../cloud-native/play-with-kubernetes.html" >
< b > 2.3.< / b >
Play with Kubernetes
< / a >
< / li >
< li class = "chapter " data-level = "2.4" data-path = "../cloud-native/cloud-native-local-quick-start.html" >
< a href = "../cloud-native/cloud-native-local-quick-start.html" >
< b > 2.4.< / b >
快速部署一个云原生本地实验环境
< / a >
< / li >
< li class = "chapter " data-level = "2.5" data-path = "../cloud-native/setup-kubernetes-with-rancher-and-aliyun.html" >
< a href = "../cloud-native/setup-kubernetes-with-rancher-and-aliyun.html" >
< b > 2.5.< / b >
使用 Rancher 在阿里云上部署 Kubenretes 集群
< / a >
< / li >
< li class = "chapter " data-level = "2.6" data-path = "../cloud-native/kubernetes-and-cloud-native-app-overview.html" >
< a href = "../cloud-native/kubernetes-and-cloud-native-app-overview.html" >
< b > 2.6.< / b >
Kubernetes 与云原生应用概览
< / a >
< / li >
< li class = "chapter " data-level = "2.7" data-path = "../cloud-native/from-kubernetes-to-cloud-native.html" >
< a href = "../cloud-native/from-kubernetes-to-cloud-native.html" >
< b > 2.7.< / b >
云原生应用之路 —— 从 Kubernetes 到 Cloud Native
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8" data-path = "../cloud-native/define-cloud-native-app.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/define-cloud-native-app.html" >
2020-06-19 14:52:56 +08:00
< b > 2.8.< / b >
2020-06-24 16:47:22 +08:00
定义云原生应用
2020-06-19 14:52:56 +08:00
< / a >
< ul class = "articles" >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1" data-path = "../cloud-native/oam.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/oam.html" >
2020-06-19 14:52:56 +08:00
< b > 2.8.1.< / b >
2020-06-24 16:47:22 +08:00
OAM
2020-06-19 14:52:56 +08:00
< / a >
2020-06-24 16:47:22 +08:00
< ul class = "articles" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1.1" data-path = "../cloud-native/workload.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/workload.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.8.1.1.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
Workload
2020-06-19 14:52:56 +08:00
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1.2" data-path = "../cloud-native/component.html" >
< a href = "../cloud-native/component.html" >
< b > 2.8.1.2.< / b >
Component
< / a >
2020-06-19 14:52:56 +08:00
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1.3" data-path = "../cloud-native/trait.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/trait.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.8.1.3.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
Trait
2020-06-19 14:52:56 +08:00
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1.4" data-path = "../cloud-native/application-scope.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/application-scope.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.8.1.4.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
Application Scope
2020-06-19 14:52:56 +08:00
< / a >
2020-06-24 16:47:22 +08:00
< / li >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.8.1.5" data-path = "../cloud-native/application-configuration.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/application-configuration.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.8.1.5.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
Application Configuration
2020-06-19 14:52:56 +08:00
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< / ul >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< / li >
< li class = "chapter " data-level = "2.8.2" data-path = "../cloud-native/crossplane.html" >
< a href = "../cloud-native/crossplane.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.8.2.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
Crossplane
2020-06-19 14:52:56 +08:00
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< / ul >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< / li >
< li class = "chapter " data-level = "2.9" data-path = "../cloud-native/cloud-native-programming-languages.html" >
< a href = "../cloud-native/cloud-native-programming-languages.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.9.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
云原生编程语言
2020-06-19 14:52:56 +08:00
< / a >
2020-06-24 16:47:22 +08:00
< ul class = "articles" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.9.1" data-path = "../cloud-native/cloud-native-programming-language-ballerina.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/cloud-native-programming-language-ballerina.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.9.1.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
云原生编程语言 Ballerina
2020-06-19 14:52:56 +08:00
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.9.2" data-path = "../cloud-native/cloud-native-programming-language-pulumi.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< a href = "../cloud-native/cloud-native-programming-language-pulumi.html" >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
< b > 2.9.2.< / b >
2020-06-19 14:52:56 +08:00
2020-06-24 16:47:22 +08:00
云原生编程语言 Pulumi
2020-06-19 14:52:56 +08:00
< / a >
< / li >
< / ul >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "2.10" data-path = "../cloud-native/the-future-of-cloud-native.html" >
< a href = "../cloud-native/the-future-of-cloud-native.html" >
< b > 2.10.< / b >
云原生的未来
< / a >
< / li >
2020-06-19 14:52:56 +08:00
< li class = "header" > 概念与原理< / li >
< li class = "chapter " data-level = "3.1" data-path = "./" >
< a href = "./" >
< b > 3.1.< / b >
Kubernetes 架构
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.1.1" data-path = "concepts.html" >
< a href = "concepts.html" >
< b > 3.1.1.< / b >
设计理念
< / a >
< / li >
< li class = "chapter " data-level = "3.1.2" data-path = "etcd.html" >
< a href = "etcd.html" >
< b > 3.1.2.< / b >
Etcd 解析
< / a >
< / li >
< li class = "chapter " data-level = "3.1.3" data-path = "open-interfaces.html" >
< a href = "open-interfaces.html" >
< b > 3.1.3.< / b >
开放接口
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.1.3.1" data-path = "cri.html" >
< a href = "cri.html" >
< b > 3.1.3.1.< / b >
CRI - Container Runtime Interface( 容器运行时接口)
< / a >
< / li >
< li class = "chapter " data-level = "3.1.3.2" data-path = "cni.html" >
< a href = "cni.html" >
< b > 3.1.3.2.< / b >
CNI - Container Network Interface( 容器网络接口)
< / a >
< / li >
< li class = "chapter " data-level = "3.1.3.3" data-path = "csi.html" >
< a href = "csi.html" >
< b > 3.1.3.3.< / b >
CSI - Container Storage Interface( 容器存储接口)
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.2" data-path = "networking.html" >
< a href = "networking.html" >
< b > 3.2.< / b >
Kubernetes 中的网络
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.2.1" data-path = "flannel.html" >
< a href = "flannel.html" >
< b > 3.2.1.< / b >
Kubernetes 中的网络解析 —— 以 flannel 为例
< / a >
< / li >
< li class = "chapter " data-level = "3.2.2" data-path = "calico.html" >
< a href = "calico.html" >
< b > 3.2.2.< / b >
Kubernetes 中的网络解析 —— 以 calico 为例
< / a >
< / li >
< li class = "chapter " data-level = "3.2.3" data-path = "cilium.html" >
< a href = "cilium.html" >
< b > 3.2.3.< / b >
具备 API 感知的网络和安全性管理开源软件 Cilium
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.2.3.1" data-path = "cilium-concepts.html" >
< a href = "cilium-concepts.html" >
< b > 3.2.3.1.< / b >
Cilium 架构设计与概念解析
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.3" data-path = "objects.html" >
< a href = "objects.html" >
< b > 3.3.< / b >
资源对象与基本概念解析
< / a >
< / li >
< li class = "chapter " data-level = "3.4" data-path = "pod-state-and-lifecycle.html" >
< a href = "pod-state-and-lifecycle.html" >
< b > 3.4.< / b >
Pod 状态与生命周期管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.4.1" data-path = "pod-overview.html" >
< a href = "pod-overview.html" >
< b > 3.4.1.< / b >
Pod 概览
< / a >
< / li >
< li class = "chapter " data-level = "3.4.2" data-path = "pod.html" >
< a href = "pod.html" >
< b > 3.4.2.< / b >
Pod 解析
< / a >
< / li >
< li class = "chapter " data-level = "3.4.3" data-path = "init-containers.html" >
< a href = "init-containers.html" >
< b > 3.4.3.< / b >
Init 容器
< / a >
< / li >
< li class = "chapter " data-level = "3.4.4" data-path = "pause-container.html" >
< a href = "pause-container.html" >
< b > 3.4.4.< / b >
Pause 容器
< / a >
< / li >
< li class = "chapter " data-level = "3.4.5" data-path = "pod-security-policy.html" >
< a href = "pod-security-policy.html" >
< b > 3.4.5.< / b >
Pod 安全策略
< / a >
< / li >
< li class = "chapter " data-level = "3.4.6" data-path = "pod-lifecycle.html" >
< a href = "pod-lifecycle.html" >
< b > 3.4.6.< / b >
Pod 的生命周期
< / a >
< / li >
< li class = "chapter " data-level = "3.4.7" data-path = "pod-hook.html" >
< a href = "pod-hook.html" >
< b > 3.4.7.< / b >
Pod Hook
< / a >
< / li >
< li class = "chapter " data-level = "3.4.8" data-path = "pod-preset.html" >
< a href = "pod-preset.html" >
< b > 3.4.8.< / b >
Pod Preset
< / a >
< / li >
< li class = "chapter " data-level = "3.4.9" data-path = "pod-disruption-budget.html" >
< a href = "pod-disruption-budget.html" >
< b > 3.4.9.< / b >
Pod 中断与 PDB( Pod 中断预算)
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.5" data-path = "cluster.html" >
< a href = "cluster.html" >
< b > 3.5.< / b >
集群资源管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.5.1" data-path = "node.html" >
< a href = "node.html" >
< b > 3.5.1.< / b >
Node
< / a >
< / li >
< li class = "chapter " data-level = "3.5.2" data-path = "namespace.html" >
< a href = "namespace.html" >
< b > 3.5.2.< / b >
Namespace
< / a >
< / li >
< li class = "chapter " data-level = "3.5.3" data-path = "label.html" >
< a href = "label.html" >
< b > 3.5.3.< / b >
Label
< / a >
< / li >
< li class = "chapter " data-level = "3.5.4" data-path = "annotation.html" >
< a href = "annotation.html" >
< b > 3.5.4.< / b >
Annotation
< / a >
< / li >
< li class = "chapter " data-level = "3.5.5" data-path = "taint-and-toleration.html" >
< a href = "taint-and-toleration.html" >
< b > 3.5.5.< / b >
Taint 和 Toleration( 污点和容忍)
< / a >
< / li >
< li class = "chapter " data-level = "3.5.6" data-path = "garbage-collection.html" >
< a href = "garbage-collection.html" >
< b > 3.5.6.< / b >
垃圾收集
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.6" data-path = "controllers.html" >
< a href = "controllers.html" >
< b > 3.6.< / b >
控制器
< / a >
< ul class = "articles" >
< li class = "chapter active" data-level = "3.6.1" data-path = "deployment.html" >
< a href = "deployment.html" >
< b > 3.6.1.< / b >
Deployment
< / a >
< / li >
< li class = "chapter " data-level = "3.6.2" data-path = "statefulset.html" >
< a href = "statefulset.html" >
< b > 3.6.2.< / b >
StatefulSet
< / a >
< / li >
< li class = "chapter " data-level = "3.6.3" data-path = "daemonset.html" >
< a href = "daemonset.html" >
< b > 3.6.3.< / b >
DaemonSet
< / a >
< / li >
< li class = "chapter " data-level = "3.6.4" data-path = "replicaset.html" >
< a href = "replicaset.html" >
< b > 3.6.4.< / b >
ReplicationController 和 ReplicaSet
< / a >
< / li >
< li class = "chapter " data-level = "3.6.5" data-path = "job.html" >
< a href = "job.html" >
< b > 3.6.5.< / b >
Job
< / a >
< / li >
< li class = "chapter " data-level = "3.6.6" data-path = "cronjob.html" >
< a href = "cronjob.html" >
< b > 3.6.6.< / b >
CronJob
< / a >
< / li >
< li class = "chapter " data-level = "3.6.7" data-path = "horizontal-pod-autoscaling.html" >
< a href = "horizontal-pod-autoscaling.html" >
< b > 3.6.7.< / b >
Horizontal Pod Autoscaling
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.6.7.1" data-path = "custom-metrics-hpa.html" >
< a href = "custom-metrics-hpa.html" >
< b > 3.6.7.1.< / b >
自定义指标 HPA
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.6.8" data-path = "admission-controller.html" >
< a href = "admission-controller.html" >
< b > 3.6.8.< / b >
准入控制器( Admission Controller)
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.7" data-path = "service-discovery.html" >
< a href = "service-discovery.html" >
< b > 3.7.< / b >
服务发现
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.7.1" data-path = "service.html" >
< a href = "service.html" >
< b > 3.7.1.< / b >
Service
< / a >
< / li >
< li class = "chapter " data-level = "3.7.2" data-path = "ingress.html" >
< a href = "ingress.html" >
< b > 3.7.2.< / b >
Ingress
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.7.2.1" data-path = "traefik-ingress-controller.html" >
< a href = "traefik-ingress-controller.html" >
< b > 3.7.2.1.< / b >
Traefik Ingress Controller
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.8" data-path = "authentication-and-permission.html" >
< a href = "authentication-and-permission.html" >
< b > 3.8.< / b >
身份与权限控制
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.8.1" data-path = "serviceaccount.html" >
< a href = "serviceaccount.html" >
< b > 3.8.1.< / b >
ServiceAccount
< / a >
< / li >
< li class = "chapter " data-level = "3.8.2" data-path = "rbac.html" >
< a href = "rbac.html" >
< b > 3.8.2.< / b >
RBAC—— 基于角色的访问控制
< / a >
< / li >
< li class = "chapter " data-level = "3.8.3" data-path = "network-policy.html" >
< a href = "network-policy.html" >
< b > 3.8.3.< / b >
NetworkPolicy
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.9" data-path = "storage.html" >
< a href = "storage.html" >
< b > 3.9.< / b >
存储
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.9.1" data-path = "secret.html" >
< a href = "secret.html" >
< b > 3.9.1.< / b >
Secret
< / a >
< / li >
< li class = "chapter " data-level = "3.9.2" data-path = "configmap.html" >
< a href = "configmap.html" >
< b > 3.9.2.< / b >
ConfigMap
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.9.2.1" data-path = "configmap-hot-update.html" >
< a href = "configmap-hot-update.html" >
< b > 3.9.2.1.< / b >
ConfigMap 的热更新
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.9.3" data-path = "volume.html" >
< a href = "volume.html" >
< b > 3.9.3.< / b >
Volume
< / a >
< / li >
< li class = "chapter " data-level = "3.9.4" data-path = "persistent-volume.html" >
< a href = "persistent-volume.html" >
< b > 3.9.4.< / b >
Persistent Volume( 持久化卷)
< / a >
< / li >
< li class = "chapter " data-level = "3.9.5" data-path = "storageclass.html" >
< a href = "storageclass.html" >
< b > 3.9.5.< / b >
Storage Class
< / a >
< / li >
< li class = "chapter " data-level = "3.9.6" data-path = "local-persistent-storage.html" >
< a href = "local-persistent-storage.html" >
< b > 3.9.6.< / b >
本地持久化存储
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.10" data-path = "extension.html" >
< a href = "extension.html" >
< b > 3.10.< / b >
集群扩展
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.10.1" data-path = "custom-resource.html" >
< a href = "custom-resource.html" >
< b > 3.10.1.< / b >
使用自定义资源扩展 API
< / a >
< / li >
< li class = "chapter " data-level = "3.10.2" data-path = "crd.html" >
< a href = "crd.html" >
< b > 3.10.2.< / b >
使用 CRD 扩展 Kubernetes API
< / a >
< / li >
< li class = "chapter " data-level = "3.10.3" data-path = "aggregated-api-server.html" >
< a href = "aggregated-api-server.html" >
< b > 3.10.3.< / b >
Aggregated API Server
< / a >
< / li >
< li class = "chapter " data-level = "3.10.4" data-path = "apiservice.html" >
< a href = "apiservice.html" >
< b > 3.10.4.< / b >
APIService
< / a >
< / li >
< li class = "chapter " data-level = "3.10.5" data-path = "service-catalog.html" >
< a href = "service-catalog.html" >
< b > 3.10.5.< / b >
Service Catalog
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "3.11" data-path = "scheduling.html" >
< a href = "scheduling.html" >
< b > 3.11.< / b >
资源调度
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "3.11.1" data-path = "qos.html" >
< a href = "qos.html" >
< b > 3.11.1.< / b >
QoS( 服务质量等级)
< / a >
< / li >
< / ul >
< / li >
< li class = "header" > 用户指南< / li >
< li class = "chapter " data-level = "4.1" data-path = "../guide/" >
< a href = "../guide/" >
< b > 4.1.< / b >
用户指南
< / a >
< / li >
< li class = "chapter " data-level = "4.2" data-path = "../guide/resource-configuration.html" >
< a href = "../guide/resource-configuration.html" >
< b > 4.2.< / b >
资源对象配置
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "4.2.1" data-path = "../guide/configure-liveness-readiness-probes.html" >
< a href = "../guide/configure-liveness-readiness-probes.html" >
< b > 4.2.1.< / b >
配置 Pod 的 liveness 和 readiness 探针
< / a >
< / li >
< li class = "chapter " data-level = "4.2.2" data-path = "../guide/configure-pod-service-account.html" >
< a href = "../guide/configure-pod-service-account.html" >
< b > 4.2.2.< / b >
配置 Pod 的 Service Account
< / a >
< / li >
< li class = "chapter " data-level = "4.2.3" data-path = "../guide/secret-configuration.html" >
< a href = "../guide/secret-configuration.html" >
< b > 4.2.3.< / b >
Secret 配置
< / a >
< / li >
< li class = "chapter " data-level = "4.2.4" data-path = "../guide/resource-quota-management.html" >
< a href = "../guide/resource-quota-management.html" >
< b > 4.2.4.< / b >
管理 namespace 中的资源配额
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "4.3" data-path = "../guide/command-usage.html" >
< a href = "../guide/command-usage.html" >
< b > 4.3.< / b >
命令使用
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "4.3.1" data-path = "../guide/docker-cli-to-kubectl.html" >
< a href = "../guide/docker-cli-to-kubectl.html" >
< b > 4.3.1.< / b >
Docker 用户过渡到 kubectl 命令行指南
< / a >
< / li >
< li class = "chapter " data-level = "4.3.2" data-path = "../guide/using-kubectl.html" >
< a href = "../guide/using-kubectl.html" >
< b > 4.3.2.< / b >
kubectl 命令概览
< / a >
< / li >
< li class = "chapter " data-level = "4.3.3" data-path = "../guide/kubectl-cheatsheet.html" >
< a href = "../guide/kubectl-cheatsheet.html" >
< b > 4.3.3.< / b >
kubectl 命令技巧大全
< / a >
< / li >
< li class = "chapter " data-level = "4.3.4" data-path = "../guide/using-etcdctl-to-access-kubernetes-data.html" >
< a href = "../guide/using-etcdctl-to-access-kubernetes-data.html" >
< b > 4.3.4.< / b >
使用 etcdctl 访问 kubernetes 数据
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "4.4" data-path = "../guide/cluster-security-management.html" >
< a href = "../guide/cluster-security-management.html" >
< b > 4.4.< / b >
集群安全性管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "4.4.1" data-path = "../guide/managing-tls-in-a-cluster.html" >
< a href = "../guide/managing-tls-in-a-cluster.html" >
< b > 4.4.1.< / b >
管理集群中的 TLS
< / a >
< / li >
< li class = "chapter " data-level = "4.4.2" data-path = "../guide/kubelet-authentication-authorization.html" >
< a href = "../guide/kubelet-authentication-authorization.html" >
< b > 4.4.2.< / b >
kubelet 的认证授权
< / a >
< / li >
< li class = "chapter " data-level = "4.4.3" data-path = "../guide/tls-bootstrapping.html" >
< a href = "../guide/tls-bootstrapping.html" >
< b > 4.4.3.< / b >
TLS bootstrap
< / a >
< / li >
< li class = "chapter " data-level = "4.4.4" data-path = "../guide/kubectl-user-authentication-authorization.html" >
< a href = "../guide/kubectl-user-authentication-authorization.html" >
< b > 4.4.4.< / b >
创建用户认证授权的 kubeconfig 文件
< / a >
< / li >
< li class = "chapter " data-level = "4.4.5" data-path = "../guide/ip-masq-agent.html" >
< a href = "../guide/ip-masq-agent.html" >
< b > 4.4.5.< / b >
IP 伪装代理
< / a >
< / li >
< li class = "chapter " data-level = "4.4.6" data-path = "../guide/auth-with-kubeconfig-or-token.html" >
< a href = "../guide/auth-with-kubeconfig-or-token.html" >
< b > 4.4.6.< / b >
使用 kubeconfig 或 token 进行用户身份认证
< / a >
< / li >
< li class = "chapter " data-level = "4.4.7" data-path = "../guide/authentication.html" >
< a href = "../guide/authentication.html" >
< b > 4.4.7.< / b >
Kubernetes 中的用户与身份认证授权
< / a >
< / li >
< li class = "chapter " data-level = "4.4.8" data-path = "../guide/kubernetes-security-best-practice.html" >
< a href = "../guide/kubernetes-security-best-practice.html" >
< b > 4.4.8.< / b >
Kubernetes 集群安全性配置最佳实践
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "4.5" data-path = "../guide/access-kubernetes-cluster.html" >
< a href = "../guide/access-kubernetes-cluster.html" >
< b > 4.5.< / b >
访问 Kubernetes 集群
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "4.5.1" data-path = "../guide/access-cluster.html" >
< a href = "../guide/access-cluster.html" >
< b > 4.5.1.< / b >
访问集群
< / a >
< / li >
< li class = "chapter " data-level = "4.5.2" data-path = "../guide/authenticate-across-clusters-kubeconfig.html" >
< a href = "../guide/authenticate-across-clusters-kubeconfig.html" >
< b > 4.5.2.< / b >
使用 kubeconfig 文件配置跨集群认证
< / a >
< / li >
< li class = "chapter " data-level = "4.5.3" data-path = "../guide/connecting-to-applications-port-forward.html" >
< a href = "../guide/connecting-to-applications-port-forward.html" >
< b > 4.5.3.< / b >
通过端口转发访问集群中的应用程序
< / a >
< / li >
< li class = "chapter " data-level = "4.5.4" data-path = "../guide/service-access-application-cluster.html" >
< a href = "../guide/service-access-application-cluster.html" >
< b > 4.5.4.< / b >
使用 service 访问群集中的应用程序
< / a >
< / li >
< li class = "chapter " data-level = "4.5.5" data-path = "../guide/accessing-kubernetes-pods-from-outside-of-the-cluster.html" >
< a href = "../guide/accessing-kubernetes-pods-from-outside-of-the-cluster.html" >
< b > 4.5.5.< / b >
从外部访问 Kubernetes 中的 Pod
< / a >
< / li >
< li class = "chapter " data-level = "4.5.6" data-path = "../guide/cabin-mobile-dashboard-for-kubernetes.html" >
< a href = "../guide/cabin-mobile-dashboard-for-kubernetes.html" >
< b > 4.5.6.< / b >
Cabin - Kubernetes 手机客户端
< / a >
< / li >
< li class = "chapter " data-level = "4.5.7" data-path = "../guide/kubernetes-desktop-client.html" >
< a href = "../guide/kubernetes-desktop-client.html" >
< b > 4.5.7.< / b >
Kubernetic - Kubernetes 桌面客户端
< / a >
< / li >
< li class = "chapter " data-level = "4.5.8" data-path = "../guide/kubernator-kubernetes-ui.html" >
< a href = "../guide/kubernator-kubernetes-ui.html" >
< b > 4.5.8.< / b >
Kubernator - 更底层的 Kubernetes UI
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "4.6" data-path = "../guide/application-development-deployment-flow.html" >
< a href = "../guide/application-development-deployment-flow.html" >
< b > 4.6.< / b >
在 Kubernetes 中开发部署应用
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "4.6.1" data-path = "../guide/deploy-applications-in-kubernetes.html" >
< a href = "../guide/deploy-applications-in-kubernetes.html" >
< b > 4.6.1.< / b >
适用于 kubernetes 的应用开发部署流程
< / a >
< / li >
< li class = "chapter " data-level = "4.6.2" data-path = "../guide/migrating-hadoop-yarn-to-kubernetes.html" >
< a href = "../guide/migrating-hadoop-yarn-to-kubernetes.html" >
< b > 4.6.2.< / b >
迁移传统应用到 Kubernetes 中 —— 以 Hadoop YARN 为例
< / a >
< / li >
< li class = "chapter " data-level = "4.6.3" data-path = "../guide/using-statefulset.html" >
< a href = "../guide/using-statefulset.html" >
< b > 4.6.3.< / b >
使用 StatefulSet 部署用状态应用
< / a >
< / li >
< / ul >
< / li >
< li class = "header" > 最佳实践< / li >
< li class = "chapter " data-level = "5.1" data-path = "../practice/" >
< a href = "../practice/" >
< b > 5.1.< / b >
最佳实践概览
< / a >
< / li >
< li class = "chapter " data-level = "5.2" data-path = "../practice/install-kubernetes-on-centos.html" >
< a href = "../practice/install-kubernetes-on-centos.html" >
< b > 5.2.< / b >
在 CentOS 上部署 Kubernetes 集群
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.2.1" data-path = "../practice/create-tls-and-secret-key.html" >
< a href = "../practice/create-tls-and-secret-key.html" >
< b > 5.2.1.< / b >
创建 TLS 证书和秘钥
< / a >
< / li >
< li class = "chapter " data-level = "5.2.2" data-path = "../practice/create-kubeconfig.html" >
< a href = "../practice/create-kubeconfig.html" >
< b > 5.2.2.< / b >
创建 kubeconfig 文件
< / a >
< / li >
< li class = "chapter " data-level = "5.2.3" data-path = "../practice/etcd-cluster-installation.html" >
< a href = "../practice/etcd-cluster-installation.html" >
< b > 5.2.3.< / b >
创建高可用 etcd 集群
< / a >
< / li >
< li class = "chapter " data-level = "5.2.4" data-path = "../practice/kubectl-installation.html" >
< a href = "../practice/kubectl-installation.html" >
< b > 5.2.4.< / b >
安装 kubectl 命令行工具
< / a >
< / li >
< li class = "chapter " data-level = "5.2.5" data-path = "../practice/master-installation.html" >
< a href = "../practice/master-installation.html" >
< b > 5.2.5.< / b >
部署 master 节点
< / a >
< / li >
< li class = "chapter " data-level = "5.2.6" data-path = "../practice/flannel-installation.html" >
< a href = "../practice/flannel-installation.html" >
< b > 5.2.6.< / b >
安装 flannel 网络插件
< / a >
< / li >
< li class = "chapter " data-level = "5.2.7" data-path = "../practice/node-installation.html" >
< a href = "../practice/node-installation.html" >
< b > 5.2.7.< / b >
部署 node 节点
< / a >
< / li >
< li class = "chapter " data-level = "5.2.8" data-path = "../practice/kubedns-addon-installation.html" >
< a href = "../practice/kubedns-addon-installation.html" >
< b > 5.2.8.< / b >
安装 kubedns 插件
< / a >
< / li >
< li class = "chapter " data-level = "5.2.9" data-path = "../practice/dashboard-addon-installation.html" >
< a href = "../practice/dashboard-addon-installation.html" >
< b > 5.2.9.< / b >
安装 dashboard 插件
< / a >
< / li >
< li class = "chapter " data-level = "5.2.10" data-path = "../practice/heapster-addon-installation.html" >
< a href = "../practice/heapster-addon-installation.html" >
< b > 5.2.10.< / b >
安装 heapster 插件
< / a >
< / li >
< li class = "chapter " data-level = "5.2.11" data-path = "../practice/efk-addon-installation.html" >
< a href = "../practice/efk-addon-installation.html" >
< b > 5.2.11.< / b >
安装 EFK 插件
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.3" data-path = "../practice/install-kubernetes-with-kubeadm.html" >
< a href = "../practice/install-kubernetes-with-kubeadm.html" >
< b > 5.3.< / b >
生产级的 Kubernetes 简化管理工具 kubeadm
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.3.1" data-path = "../practice/install-kubernetes-on-ubuntu-server-16.04-with-kubeadm.html" >
< a href = "../practice/install-kubernetes-on-ubuntu-server-16.04-with-kubeadm.html" >
< b > 5.3.1.< / b >
使用 kubeadm 在 Ubuntu Server 16.04 上快速构建测试集群
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.4" data-path = "../practice/service-discovery-and-loadbalancing.html" >
< a href = "../practice/service-discovery-and-loadbalancing.html" >
< b > 5.4.< / b >
服务发现与负载均衡
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.4.1" data-path = "../practice/traefik-ingress-installation.html" >
< a href = "../practice/traefik-ingress-installation.html" >
< b > 5.4.1.< / b >
安装 Traefik ingress
< / a >
< / li >
< li class = "chapter " data-level = "5.4.2" data-path = "../practice/distributed-load-test.html" >
< a href = "../practice/distributed-load-test.html" >
< b > 5.4.2.< / b >
分布式负载测试
< / a >
< / li >
< li class = "chapter " data-level = "5.4.3" data-path = "../practice/network-and-cluster-perfermance-test.html" >
< a href = "../practice/network-and-cluster-perfermance-test.html" >
< b > 5.4.3.< / b >
网络和集群性能测试
< / a >
< / li >
< li class = "chapter " data-level = "5.4.4" data-path = "../practice/edge-node-configuration.html" >
< a href = "../practice/edge-node-configuration.html" >
< b > 5.4.4.< / b >
边缘节点配置
< / a >
< / li >
< li class = "chapter " data-level = "5.4.5" data-path = "../practice/nginx-ingress-installation.html" >
< a href = "../practice/nginx-ingress-installation.html" >
< b > 5.4.5.< / b >
安装 Nginx ingress
< / a >
< / li >
< li class = "chapter " data-level = "5.4.6" data-path = "../practice/dns-installation.html" >
< a href = "../practice/dns-installation.html" >
< b > 5.4.6.< / b >
安装配置 DNS
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.4.6.1" data-path = "../practice/configuring-dns.html" >
< a href = "../practice/configuring-dns.html" >
< b > 5.4.6.1.< / b >
安装配置 Kube-dns
< / a >
< / li >
< li class = "chapter " data-level = "5.4.6.2" data-path = "../practice/coredns.html" >
< a href = "../practice/coredns.html" >
< b > 5.4.6.2.< / b >
安装配置 CoreDNS
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.5" data-path = "../practice/operation.html" >
< a href = "../practice/operation.html" >
< b > 5.5.< / b >
运维管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.5.1" data-path = "../practice/master-ha.html" >
< a href = "../practice/master-ha.html" >
< b > 5.5.1.< / b >
Master 节点高可用
< / a >
< / li >
< li class = "chapter " data-level = "5.5.2" data-path = "../practice/service-rolling-update.html" >
< a href = "../practice/service-rolling-update.html" >
< b > 5.5.2.< / b >
服务滚动升级
< / a >
< / li >
< li class = "chapter " data-level = "5.5.3" data-path = "../practice/app-log-collection.html" >
< a href = "../practice/app-log-collection.html" >
< b > 5.5.3.< / b >
应用日志收集
< / a >
< / li >
< li class = "chapter " data-level = "5.5.4" data-path = "../practice/configuration-best-practice.html" >
< a href = "../practice/configuration-best-practice.html" >
< b > 5.5.4.< / b >
配置最佳实践
< / a >
< / li >
< li class = "chapter " data-level = "5.5.5" data-path = "../practice/monitor.html" >
< a href = "../practice/monitor.html" >
< b > 5.5.5.< / b >
集群及应用监控
< / a >
< / li >
< li class = "chapter " data-level = "5.5.6" data-path = "../practice/data-persistence-problem.html" >
< a href = "../practice/data-persistence-problem.html" >
< b > 5.5.6.< / b >
数据持久化问题
< / a >
< / li >
< li class = "chapter " data-level = "5.5.7" data-path = "../practice/manage-compute-resources-container.html" >
< a href = "../practice/manage-compute-resources-container.html" >
< b > 5.5.7.< / b >
管理容器的计算资源
< / a >
< / li >
< li class = "chapter " data-level = "5.5.8" data-path = "../practice/federation.html" >
< a href = "../practice/federation.html" >
< b > 5.5.8.< / b >
集群联邦
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.6" data-path = "../practice/storage.html" >
< a href = "../practice/storage.html" >
< b > 5.6.< / b >
存储管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.6.1" data-path = "../practice/glusterfs.html" >
< a href = "../practice/glusterfs.html" >
< b > 5.6.1.< / b >
GlusterFS
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.6.1.1" data-path = "../practice/using-glusterfs-for-persistent-storage.html" >
< a href = "../practice/using-glusterfs-for-persistent-storage.html" >
< b > 5.6.1.1.< / b >
使用 GlusterFS 做持久化存储
< / a >
< / li >
< li class = "chapter " data-level = "5.6.1.2" data-path = "../practice/using-heketi-gluster-for-persistent-storage.html" >
< a href = "../practice/using-heketi-gluster-for-persistent-storage.html" >
< b > 5.6.1.2.< / b >
使用 Heketi 作为 Kubernetes 的持久存储 GlusterFS 的 external provisioner
< / a >
< / li >
< li class = "chapter " data-level = "5.6.1.3" data-path = "../practice/storage-for-containers-using-glusterfs-with-openshift.html" >
< a href = "../practice/storage-for-containers-using-glusterfs-with-openshift.html" >
< b > 5.6.1.3.< / b >
在 OpenShift 中使用 GlusterFS 做持久化存储
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.6.2" data-path = "../practice/glusterd-2.0.html" >
< a href = "../practice/glusterd-2.0.html" >
< b > 5.6.2.< / b >
GlusterD-2.0
< / a >
< / li >
< li class = "chapter " data-level = "5.6.3" data-path = "../practice/ceph.html" >
< a href = "../practice/ceph.html" >
< b > 5.6.3.< / b >
Ceph
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.6.3.1" data-path = "../practice/ceph-helm-install-guide-zh.html" >
< a href = "../practice/ceph-helm-install-guide-zh.html" >
< b > 5.6.3.1.< / b >
用 Helm 托管安装 Ceph 集群并提供后端存储
< / a >
< / li >
< li class = "chapter " data-level = "5.6.3.2" data-path = "../practice/using-ceph-for-persistent-storage.html" >
< a href = "../practice/using-ceph-for-persistent-storage.html" >
< b > 5.6.3.2.< / b >
使用 Ceph 做持久化存储
< / a >
< / li >
< li class = "chapter " data-level = "5.6.3.3" data-path = "../practice/rbd-provisioner.html" >
< a href = "../practice/rbd-provisioner.html" >
< b > 5.6.3.3.< / b >
使用 rbd-provisioner 提供 rbd 持久化存储
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.6.4" data-path = "../practice/openebs.html" >
< a href = "../practice/openebs.html" >
< b > 5.6.4.< / b >
OpenEBS
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.6.4.1" data-path = "../practice/using-openebs-for-persistent-storage.html" >
< a href = "../practice/using-openebs-for-persistent-storage.html" >
< b > 5.6.4.1.< / b >
使用 OpenEBS 做持久化存储
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.6.5" data-path = "../practice/rook.html" >
< a href = "../practice/rook.html" >
< b > 5.6.5.< / b >
Rook
< / a >
< / li >
< li class = "chapter " data-level = "5.6.6" data-path = "../practice/nfs.html" >
< a href = "../practice/nfs.html" >
< b > 5.6.6.< / b >
NFS
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.6.6.1" data-path = "../practice/using-nfs-for-persistent-storage.html" >
< a href = "../practice/using-nfs-for-persistent-storage.html" >
< b > 5.6.6.1.< / b >
利用 NFS 动态提供 Kubernetes 后端存储卷
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.7" data-path = "../practice/monitoring.html" >
< a href = "../practice/monitoring.html" >
< b > 5.7.< / b >
集群与应用监控
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.7.1" data-path = "../practice/heapster.html" >
< a href = "../practice/heapster.html" >
< b > 5.7.1.< / b >
Heapster
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.7.1.1" data-path = "../practice/using-heapster-to-get-object-metrics.html" >
< a href = "../practice/using-heapster-to-get-object-metrics.html" >
< b > 5.7.1.1.< / b >
使用 Heapster 获取集群和对象的 metric 数据
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.7.2" data-path = "../practice/prometheus.html" >
< a href = "../practice/prometheus.html" >
< b > 5.7.2.< / b >
Prometheus
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.7.2.1" data-path = "../practice/using-prometheus-to-monitor-kuberentes-cluster.html" >
< a href = "../practice/using-prometheus-to-monitor-kuberentes-cluster.html" >
< b > 5.7.2.1.< / b >
使用 Prometheus 监控 kubernetes 集群
< / a >
< / li >
< li class = "chapter " data-level = "5.7.2.2" data-path = "../practice/promql.html" >
< a href = "../practice/promql.html" >
< b > 5.7.2.2.< / b >
Prometheus 查询语言 PromQL 使用说明
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.7.3" data-path = "../practice/vistio-visualize-your-istio-mesh.html" >
< a href = "../practice/vistio-visualize-your-istio-mesh.html" >
< b > 5.7.3.< / b >
使用 Vistio 监控 Istio 服务网格中的流量
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.8" data-path = "../practice/distributed-tracing.html" >
< a href = "../practice/distributed-tracing.html" >
< b > 5.8.< / b >
分布式跟踪
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.8.1" data-path = "../practice/opentracing.html" >
< a href = "../practice/opentracing.html" >
< b > 5.8.1.< / b >
OpenTracing
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.9" data-path = "../practice/services-management-tool.html" >
< a href = "../practice/services-management-tool.html" >
< b > 5.9.< / b >
服务编排管理
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.9.1" data-path = "../practice/helm.html" >
< a href = "../practice/helm.html" >
< b > 5.9.1.< / b >
使用 Helm 管理 Kubernetes 应用
< / a >
< / li >
< li class = "chapter " data-level = "5.9.2" data-path = "../practice/create-private-charts-repo.html" >
< a href = "../practice/create-private-charts-repo.html" >
< b > 5.9.2.< / b >
构建私有 Chart 仓库
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.10" data-path = "../practice/ci-cd.html" >
< a href = "../practice/ci-cd.html" >
< b > 5.10.< / b >
持续集成与发布
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.10.1" data-path = "../practice/jenkins-ci-cd.html" >
< a href = "../practice/jenkins-ci-cd.html" >
< b > 5.10.1.< / b >
使用 Jenkins 进行持续集成与发布
< / a >
< / li >
< li class = "chapter " data-level = "5.10.2" data-path = "../practice/drone-ci-cd.html" >
< a href = "../practice/drone-ci-cd.html" >
< b > 5.10.2.< / b >
使用 Drone 进行持续集成与发布
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.11" data-path = "../practice/update-and-upgrade.html" >
< a href = "../practice/update-and-upgrade.html" >
< b > 5.11.< / b >
更新与升级
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.11.1" data-path = "../practice/manually-upgrade.html" >
< a href = "../practice/manually-upgrade.html" >
< b > 5.11.1.< / b >
手动升级 Kubernetes 集群
< / a >
< / li >
< li class = "chapter " data-level = "5.11.2" data-path = "../practice/dashboard-upgrade.html" >
< a href = "../practice/dashboard-upgrade.html" >
< b > 5.11.2.< / b >
升级 dashboard
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "5.12" data-path = "../practice/controller-extended.html" >
< a href = "../practice/controller-extended.html" >
< b > 5.12.< / b >
扩展控制器
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "5.12.1" data-path = "../practice/openkruise.html" >
< a href = "../practice/openkruise.html" >
< b > 5.12.1.< / b >
OpenKruise
< / a >
2020-06-22 17:07:42 +08:00
< ul class = "articles" >
< li class = "chapter " data-level = "5.12.1.1" data-path = "../practice/in-place-update.html" >
< a href = "../practice/in-place-update.html" >
< b > 5.12.1.1.< / b >
原地升级
< / a >
< / li >
< / ul >
2020-06-19 14:52:56 +08:00
< / li >
< / ul >
< / li >
< li class = "header" > 领域应用< / li >
< li class = "chapter " data-level = "6.1" data-path = "../usecases/" >
< a href = "../usecases/" >
< b > 6.1.< / b >
领域应用概览
< / a >
< / li >
< li class = "chapter " data-level = "6.2" data-path = "../usecases/microservices.html" >
< a href = "../usecases/microservices.html" >
< b > 6.2.< / b >
微服务架构
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.2.1" data-path = "../usecases/service-discovery-in-microservices.html" >
< a href = "../usecases/service-discovery-in-microservices.html" >
< b > 6.2.1.< / b >
微服务中的服务发现
< / a >
< / li >
< li class = "chapter " data-level = "6.2.2" data-path = "../usecases/microservices-for-java-developers.html" >
< a href = "../usecases/microservices-for-java-developers.html" >
< b > 6.2.2.< / b >
使用 Java 构建微服务并发布到 Kubernetes 平台
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.2.2.1" data-path = "../usecases/spring-boot-quick-start-guide.html" >
< a href = "../usecases/spring-boot-quick-start-guide.html" >
< b > 6.2.2.1.< / b >
Spring Boot 快速开始指南
< / a >
< / li >
< / ul >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3" data-path = "../usecases/service-mesh.html" >
< a href = "../usecases/service-mesh.html" >
< b > 6.3.< / b >
Service Mesh 服务网格
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.1" data-path = "../usecases/the-enterprise-path-to-service-mesh-architectures.html" >
< a href = "../usecases/the-enterprise-path-to-service-mesh-architectures.html" >
< b > 6.3.1.< / b >
企业级服务网格架构
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.1.1" data-path = "../usecases/service-mesh-fundamental.html" >
< a href = "../usecases/service-mesh-fundamental.html" >
< b > 6.3.1.1.< / b >
Service Mesh 基础
< / a >
< / li >
< li class = "chapter " data-level = "6.3.1.2" data-path = "../usecases/comparing-service-mesh-technologies.html" >
< a href = "../usecases/comparing-service-mesh-technologies.html" >
< b > 6.3.1.2.< / b >
Service Mesh 技术对比
< / a >
< / li >
< li class = "chapter " data-level = "6.3.1.3" data-path = "../usecases/service-mesh-adoption-and-evolution.html" >
< a href = "../usecases/service-mesh-adoption-and-evolution.html" >
< b > 6.3.1.3.< / b >
采纳和演进
< / a >
< / li >
< li class = "chapter " data-level = "6.3.1.4" data-path = "../usecases/service-mesh-customization-and-integration.html" >
< a href = "../usecases/service-mesh-customization-and-integration.html" >
< b > 6.3.1.4.< / b >
定制和集成
< / a >
< / li >
< li class = "chapter " data-level = "6.3.1.5" data-path = "../usecases/service-mesh-conclusion.html" >
< a href = "../usecases/service-mesh-conclusion.html" >
< b > 6.3.1.5.< / b >
总结
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3.2" data-path = "../usecases/istio.html" >
< a href = "../usecases/istio.html" >
< b > 6.3.2.< / b >
Istio
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.2.1" data-path = "../usecases/istio-installation.html" >
< a href = "../usecases/istio-installation.html" >
< b > 6.3.2.1.< / b >
安装并试用 Istio service mesh
< / a >
< / li >
< li class = "chapter " data-level = "6.3.2.2" data-path = "../usecases/sidecar-spec-in-istio.html" >
< a href = "../usecases/sidecar-spec-in-istio.html" >
< b > 6.3.2.2.< / b >
Istio 中 sidecar 的注入规范及示例
< / a >
< / li >
< li class = "chapter " data-level = "6.3.2.3" data-path = "../usecases/istio-community-tips.html" >
< a href = "../usecases/istio-community-tips.html" >
< b > 6.3.2.3.< / b >
如何参与 Istio 社区及注意事项
< / a >
< / li >
< li class = "chapter " data-level = "6.3.2.4" data-path = "../usecases/istio-tutorials-collection.html" >
< a href = "../usecases/istio-tutorials-collection.html" >
< b > 6.3.2.4.< / b >
Istio 免费学习资源汇总
< / a >
< / li >
< li class = "chapter " data-level = "6.3.2.5" data-path = "../usecases/understand-sidecar-injection-and-traffic-hijack-in-istio-service-mesh.html" >
< a href = "../usecases/understand-sidecar-injection-and-traffic-hijack-in-istio-service-mesh.html" >
< b > 6.3.2.5.< / b >
Sidecar 的注入与流量劫持
< / a >
< / li >
< li class = "chapter " data-level = "6.3.2.6" data-path = "../usecases/envoy-sidecar-routing-of-istio-service-mesh-deep-dive.html" >
< a href = "../usecases/envoy-sidecar-routing-of-istio-service-mesh-deep-dive.html" >
< b > 6.3.2.6.< / b >
Envoy Sidecar 代理的路由转发
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3.3" data-path = "../usecases/linkerd.html" >
< a href = "../usecases/linkerd.html" >
< b > 6.3.3.< / b >
Linkerd
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.3.1" data-path = "../usecases/linkerd-user-guide.html" >
< a href = "../usecases/linkerd-user-guide.html" >
< b > 6.3.3.1.< / b >
Linkerd 使用指南
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3.4" data-path = "../usecases/conduit.html" >
< a href = "../usecases/conduit.html" >
< b > 6.3.4.< / b >
Conduit
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.4.1" data-path = "../usecases/conduit-overview.html" >
< a href = "../usecases/conduit-overview.html" >
< b > 6.3.4.1.< / b >
Condiut 概览
< / a >
< / li >
< li class = "chapter " data-level = "6.3.4.2" data-path = "../usecases/conduit-installation.html" >
< a href = "../usecases/conduit-installation.html" >
< b > 6.3.4.2.< / b >
安装 Conduit
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3.5" data-path = "../usecases/envoy.html" >
< a href = "../usecases/envoy.html" >
< b > 6.3.5.< / b >
Envoy
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.3.5.1" data-path = "../usecases/envoy-terminology.html" >
< a href = "../usecases/envoy-terminology.html" >
< b > 6.3.5.1.< / b >
Envoy 的架构与基本术语
< / a >
< / li >
< li class = "chapter " data-level = "6.3.5.2" data-path = "../usecases/envoy-front-proxy.html" >
< a href = "../usecases/envoy-front-proxy.html" >
< b > 6.3.5.2.< / b >
Envoy 作为前端代理
< / a >
< / li >
< li class = "chapter " data-level = "6.3.5.3" data-path = "../usecases/envoy-mesh-in-kubernetes-tutorial.html" >
< a href = "../usecases/envoy-mesh-in-kubernetes-tutorial.html" >
< b > 6.3.5.3.< / b >
Envoy mesh 教程
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.3.6" data-path = "../usecases/mosn.html" >
< a href = "../usecases/mosn.html" >
< b > 6.3.6.< / b >
MOSN
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.4" data-path = "../usecases/big-data.html" >
< a href = "../usecases/big-data.html" >
< b > 6.4.< / b >
大数据
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.4.1" data-path = "../usecases/spark-standalone-on-kubernetes.html" >
< a href = "../usecases/spark-standalone-on-kubernetes.html" >
< b > 6.4.1.< / b >
Spark standalone on Kubernetes
< / a >
< / li >
< li class = "chapter " data-level = "6.4.2" data-path = "../usecases/running-spark-with-kubernetes-native-scheduler.html" >
< a href = "../usecases/running-spark-with-kubernetes-native-scheduler.html" >
< b > 6.4.2.< / b >
运行支持 Kubernetes 原生调度的 Spark 程序
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.5" data-path = "../usecases/serverless.html" >
< a href = "../usecases/serverless.html" >
< b > 6.5.< / b >
Serverless 架构
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.5.1" data-path = "../usecases/understanding-serverless.html" >
< a href = "../usecases/understanding-serverless.html" >
< b > 6.5.1.< / b >
理解 Serverless
< / a >
< / li >
< li class = "chapter " data-level = "6.5.2" data-path = "../usecases/faas.html" >
< a href = "../usecases/faas.html" >
< b > 6.5.2.< / b >
FaaS( 函数即服务)
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "6.5.2.1" data-path = "../usecases/openfaas-quick-start.html" >
< a href = "../usecases/openfaas-quick-start.html" >
< b > 6.5.2.1.< / b >
OpenFaaS 快速入门指南
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "6.5.3" data-path = "../usecases/knative.html" >
< a href = "../usecases/knative.html" >
< b > 6.5.3.< / b >
Knative
< / a >
< / li >
< / ul >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "6.6" data-path = "../usecases/edge-computing.html" >
2020-06-19 14:52:56 +08:00
< a href = "../usecases/edge-computing.html" >
2020-06-24 16:47:22 +08:00
< b > 6.6.< / b >
2020-06-19 14:52:56 +08:00
边缘计算
< / a >
< / li >
2020-06-24 16:47:22 +08:00
< li class = "chapter " data-level = "6.7" data-path = "../usecases/ai.html" >
2020-06-19 14:52:56 +08:00
< a href = "../usecases/ai.html" >
2020-06-24 16:47:22 +08:00
< b > 6.7.< / b >
2020-06-19 14:52:56 +08:00
人工智能
< / a >
< / li >
< li class = "header" > 开发指南< / li >
< li class = "chapter " data-level = "7.1" data-path = "../develop/" >
< a href = "../develop/" >
< b > 7.1.< / b >
开发指南概览
< / a >
< / li >
< li class = "chapter " data-level = "7.2" data-path = "../develop/sigs-and-working-group.html" >
< a href = "../develop/sigs-and-working-group.html" >
< b > 7.2.< / b >
SIG 和工作组
< / a >
< / li >
< li class = "chapter " data-level = "7.3" data-path = "../develop/developing-environment.html" >
< a href = "../develop/developing-environment.html" >
< b > 7.3.< / b >
开发环境搭建
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "7.3.1" data-path = "../develop/using-vagrant-and-virtualbox-for-development.html" >
< a href = "../develop/using-vagrant-and-virtualbox-for-development.html" >
< b > 7.3.1.< / b >
本地分布式开发环境搭建(使用 Vagrant 和 Virtualbox)
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "7.4" data-path = "../develop/testing.html" >
< a href = "../develop/testing.html" >
< b > 7.4.< / b >
单元测试和集成测试
< / a >
< / li >
< li class = "chapter " data-level = "7.5" data-path = "../develop/client-go-sample.html" >
< a href = "../develop/client-go-sample.html" >
< b > 7.5.< / b >
client-go 示例
< / a >
< / li >
< li class = "chapter " data-level = "7.6" data-path = "../develop/operator.html" >
< a href = "../develop/operator.html" >
< b > 7.6.< / b >
Operator
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "7.6.1" data-path = "../develop/operator-sdk.html" >
< a href = "../develop/operator-sdk.html" >
< b > 7.6.1.< / b >
operator-sdk
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "7.7" data-path = "../develop/kubebuilder.html" >
< a href = "../develop/kubebuilder.html" >
< b > 7.7.< / b >
kubebuilder
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "7.7.1" data-path = "../develop/kubebuilder-example.html" >
< a href = "../develop/kubebuilder-example.html" >
< b > 7.7.1.< / b >
使用 kubebuilder 创建 operator 示例
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "7.8" data-path = "../develop/advance-developer.html" >
< a href = "../develop/advance-developer.html" >
< b > 7.8.< / b >
高级开发指南
< / a >
< / li >
< li class = "chapter " data-level = "7.9" data-path = "../develop/contribute.html" >
< a href = "../develop/contribute.html" >
< b > 7.9.< / b >
社区贡献
< / a >
< / li >
< li class = "chapter " data-level = "7.10" data-path = "../develop/minikube.html" >
< a href = "../develop/minikube.html" >
< b > 7.10.< / b >
Minikube
< / a >
< / li >
< li class = "header" > CNCF( 云原生计算基金会) < / li >
< li class = "chapter " data-level = "8.1" data-path = "../cloud-native/cncf.html" >
< a href = "../cloud-native/cncf.html" >
< b > 8.1.< / b >
CNCF - 云原生计算基金会简介
< / a >
< / li >
< li class = "chapter " data-level = "8.2" data-path = "../cloud-native/cncf-charter.html" >
< a href = "../cloud-native/cncf-charter.html" >
< b > 8.2.< / b >
CNCF 章程
< / a >
< / li >
< li class = "chapter " data-level = "8.3" data-path = "../cloud-native/cncf-sig.html" >
< a href = "../cloud-native/cncf-sig.html" >
< b > 8.3.< / b >
CNCF 特别兴趣小组( SIG) 说明
< / a >
< / li >
< li class = "chapter " data-level = "8.4" data-path = "../cloud-native/cncf-sandbox-criteria.html" >
< a href = "../cloud-native/cncf-sandbox-criteria.html" >
< b > 8.4.< / b >
开源项目加入 CNCF Sandbox 的要求
< / a >
< / li >
< li class = "chapter " data-level = "8.5" data-path = "../cloud-native/cncf-project-governing.html" >
< a href = "../cloud-native/cncf-project-governing.html" >
< b > 8.5.< / b >
CNCF 中的项目治理
< / a >
< / li >
< li class = "chapter " data-level = "8.6" data-path = "../cloud-native/cncf-ambassador.html" >
< a href = "../cloud-native/cncf-ambassador.html" >
< b > 8.6.< / b >
CNCF Ambassador
< / a >
< / li >
< li class = "header" > 附录< / li >
< li class = "chapter " data-level = "9.1" data-path = "../appendix/" >
< a href = "../appendix/" >
< b > 9.1.< / b >
附录说明
< / a >
< / li >
< li class = "chapter " data-level = "9.2" data-path = "../appendix/debug-kubernetes-services.html" >
< a href = "../appendix/debug-kubernetes-services.html" >
< b > 9.2.< / b >
Kubernetes 中的应用故障排查
< / a >
< / li >
< li class = "chapter " data-level = "9.3" data-path = "../appendix/material-share.html" >
< a href = "../appendix/material-share.html" >
< b > 9.3.< / b >
Kubernetes 相关资讯和情报链接
< / a >
< / li >
< li class = "chapter " data-level = "9.4" data-path = "../appendix/docker-best-practice.html" >
< a href = "../appendix/docker-best-practice.html" >
< b > 9.4.< / b >
Docker 最佳实践
< / a >
< / li >
< li class = "chapter " data-level = "9.5" data-path = "../appendix/tricks.html" >
< a href = "../appendix/tricks.html" >
< b > 9.5.< / b >
使用技巧
< / a >
< / li >
< li class = "chapter " data-level = "9.6" data-path = "../appendix/issues.html" >
< a href = "../appendix/issues.html" >
< b > 9.6.< / b >
问题记录
< / a >
< / li >
< li class = "chapter " data-level = "9.7" data-path = "../appendix/kubernetes-changelog.html" >
< a href = "../appendix/kubernetes-changelog.html" >
< b > 9.7.< / b >
Kubernetes 版本更新日志
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "9.7.1" data-path = "../appendix/kubernetes-1.7-changelog.html" >
< a href = "../appendix/kubernetes-1.7-changelog.html" >
< b > 9.7.1.< / b >
Kubernetes1.7 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.2" data-path = "../appendix/kubernetes-1.8-changelog.html" >
< a href = "../appendix/kubernetes-1.8-changelog.html" >
< b > 9.7.2.< / b >
Kubernetes1.8 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.3" data-path = "../appendix/kubernetes-1.9-changelog.html" >
< a href = "../appendix/kubernetes-1.9-changelog.html" >
< b > 9.7.3.< / b >
Kubernetes1.9 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.4" data-path = "../appendix/kubernetes-1.10-changelog.html" >
< a href = "../appendix/kubernetes-1.10-changelog.html" >
< b > 9.7.4.< / b >
Kubernetes1.10 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.5" data-path = "../appendix/kubernetes-1.11-changelog.html" >
< a href = "../appendix/kubernetes-1.11-changelog.html" >
< b > 9.7.5.< / b >
Kubernetes1.11 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.6" data-path = "../appendix/kubernetes-1.12-changelog.html" >
< a href = "../appendix/kubernetes-1.12-changelog.html" >
< b > 9.7.6.< / b >
Kubernetes1.12 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.7" data-path = "../appendix/kubernetes-1.13-changelog.html" >
< a href = "../appendix/kubernetes-1.13-changelog.html" >
< b > 9.7.7.< / b >
Kubernetes1.13 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.8" data-path = "../appendix/kubernetes-1.14-changelog.html" >
< a href = "../appendix/kubernetes-1.14-changelog.html" >
< b > 9.7.8.< / b >
Kubernetes1.14 更新日志
< / a >
< / li >
< li class = "chapter " data-level = "9.7.9" data-path = "../appendix/kubernetes-1.15-changelog.html" >
< a href = "../appendix/kubernetes-1.15-changelog.html" >
< b > 9.7.9.< / b >
Kubernetes1.15 更新日志
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "9.8" data-path = "../appendix/summary-and-outlook.html" >
< a href = "../appendix/summary-and-outlook.html" >
< b > 9.8.< / b >
Kubernetes 及云原生年度总结及展望
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "9.8.1" data-path = "../appendix/kubernetes-and-cloud-native-summary-in-2017-and-outlook-for-2018.html" >
< a href = "../appendix/kubernetes-and-cloud-native-summary-in-2017-and-outlook-for-2018.html" >
< b > 9.8.1.< / b >
Kubernetes 与云原生 2017 年年终总结及 2018 年展望
< / a >
< / li >
< li class = "chapter " data-level = "9.8.2" data-path = "../appendix/kubernetes-and-cloud-native-summary-in-2018-and-outlook-for-2019.html" >
< a href = "../appendix/kubernetes-and-cloud-native-summary-in-2018-and-outlook-for-2019.html" >
< b > 9.8.2.< / b >
Kubernetes 与云原生 2018 年年终总结及 2019 年展望
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "9.9" data-path = "../appendix/cncf-annual-report.html" >
< a href = "../appendix/cncf-annual-report.html" >
< b > 9.9.< / b >
CNCF 年度报告解读
< / a >
< ul class = "articles" >
< li class = "chapter " data-level = "9.9.1" data-path = "../appendix/cncf-annual-report-2018.html" >
< a href = "../appendix/cncf-annual-report-2018.html" >
< b > 9.9.1.< / b >
CNCF 2018 年年度报告解读
< / a >
< / li >
< / ul >
< / li >
< li class = "chapter " data-level = "9.10" data-path = "../appendix/about-kcsp.html" >
< a href = "../appendix/about-kcsp.html" >
< b > 9.10.< / b >
Kubernetes 认证服务提供商( KCSP) 说明
< / a >
< / li >
< li class = "chapter " data-level = "9.11" data-path = "../appendix/about-cka-candidate.html" >
< a href = "../appendix/about-cka-candidate.html" >
< b > 9.11.< / b >
认证 Kubernetes 管理员( CKA) 说明
< / a >
< / li >
< li class = "divider" > < / li >
< li >
< a href = "https://www.gitbook.com" target = "blank" class = "gitbook-link" >
本书使用 GitBook 发布
< / a >
< / li >
< / ul >
< / nav >
< / div >
< div class = "book-body" >
< div class = "body-inner" >
< div class = "book-header" role = "navigation" >
<!-- Title -->
< h1 >
< i class = "fa fa-circle-o-notch fa-spin" > < / i >
< a href = ".." > Deployment< / a >
< / h1 >
< / div >
< div class = "page-wrapper" tabindex = "-1" role = "main" >
< div class = "page-inner" >
< div class = "search-plus" id = "book-search-results" >
< div class = "search-noresults" >
< section class = "normal markdown-section" >
< h1 id = "deployment" > Deployment< / h1 >
< p > Deployment 为 Pod 和 ReplicaSet 提 供 了 一 个 声 明 式 定 义 ( declarative) 方 法 , 用 来 替 代 以 前 的 ReplicationController 来 方 便 的 管 理 应 用 。 典 型 的 应 用 场 景 包 括 : < / p >
< ul >
< li > 定 义 Deployment 来 创 建 Pod 和 ReplicaSet< / li >
< li > 滚 动 升 级 和 回 滚 应 用 < / li >
< li > 扩 容 和 缩 容 < / li >
< li > 暂 停 和 继 续 Deployment< / li >
< / ul >
< p > 比 如 一 个 简 单 的 nginx 应 用 可 以 定 义 为 : < / p >
< pre class = "language-" > < code class = "lang-yaml" > < span class = "token key atrule" > apiVersion< / span > < span class = "token punctuation" > :< / span > extensions/v1beta1
< span class = "token key atrule" > kind< / span > < span class = "token punctuation" > :< / span > Deployment
< span class = "token key atrule" > metadata< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > name< / span > < span class = "token punctuation" > :< / span > nginx< span class = "token punctuation" > -< / span > deployment
< span class = "token key atrule" > spec< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > replicas< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 3< / span >
< span class = "token key atrule" > template< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > metadata< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > labels< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > app< / span > < span class = "token punctuation" > :< / span > nginx
< span class = "token key atrule" > spec< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > containers< / span > < span class = "token punctuation" > :< / span >
< span class = "token punctuation" > -< / span > < span class = "token key atrule" > name< / span > < span class = "token punctuation" > :< / span > nginx
< span class = "token key atrule" > image< / span > < span class = "token punctuation" > :< / span > nginx< span class = "token punctuation" > :< / span > 1.7.9
< span class = "token key atrule" > ports< / span > < span class = "token punctuation" > :< / span >
< span class = "token punctuation" > -< / span > < span class = "token key atrule" > containerPort< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 80< / span >
< / code > < / pre >
2020-06-21 15:23:27 +08:00
< p > 扩 容 : < / p >
< pre class = "language-" > < code class = "lang-bash" > kubectl scale deployment nginx-deployment --replicas < span class = "token number" > 10< / span >
< / code > < / pre >
< p > 如 果 集 群 支 持 horizontal pod autoscaling 的 话 , 还 可 以 为 Deployment 设 置 自 动 扩 展 : < / p >
< pre class = "language-" > < code class = "lang-bash" > kubectl autoscale deployment nginx-deployment --min< span class = "token operator" > =< / span > < span class = "token number" > 10< / span > --max< span class = "token operator" > =< / span > < span class = "token number" > 15< / span > --cpu-percent< span class = "token operator" > =< / span > < span class = "token number" > 80< / span >
< / code > < / pre >
< p > 更 新 镜 像 也 比 较 简 单 : < / p >
< pre class = "language-" > < code class = "lang-bash" > kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.9.1
< / code > < / pre >
< p > 回 滚 : < / p >
< pre class = "language-" > < code class = "lang-bash" > kubectl rollout undo deployment/nginx-deployment
< / code > < / pre >
< h2 id = "deployment-结构示意图" > Deployment 结 构 示 意 图 < / h2 >
2020-06-24 16:47:22 +08:00
< figure id = "fig3.6.1.1" > < a href = "../images/deployment-cheatsheet.png" data-lightbox = "379deb4d-57fc-465f-9a2a-9d6818f69f5d" data-title = "kubernetes deployment cheatsheet" > < img src = "../images/deployment-cheatsheet.png" alt = "kubernetes deployment cheatsheet" > < / a > < figcaption > 图 3.6.1.1: kubernetes deployment cheatsheet< / figcaption > < / figure >
2020-06-21 15:23:27 +08:00
< h2 id = "deployment-概念详细解析" > Deployment 概 念 详 细 解 析 < / h2 >
< p > 本 文 翻 译 自 kubernetes 官 方 文 档 : < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment" target = "_blank" > https://kubernetes.io/docs/concepts/workloads/controllers/deployment< / a > < / p >
< p > 根 据 2017 年 5 月 10 日 的 Commit 8481c02 翻 译 。 < / p >
< h2 id = "deployment-是什么?" > Deployment 是 什 么 ? < / h2 >
< p > Deployment 为 Pod 和 Replica Set( 下 一 代 Replication Controller) 提 供 声 明 式 更 新 。 < / p >
< p > 您 只 需 要 在 Deployment 中 描 述 您 想 要 的 目 标 状 态 是 什 么 , Deployment controller 就 会 帮 您 将 Pod 和 ReplicaSet 的 实 际 状 态 改 变 到 您 的 目 标 状 态 。 您 可 以 定 义 一 个 全 新 的 Deployment 来 创 建 ReplicaSet 或 者 删 除 已 有 的 Deployment 并 创 建 一 个 新 的 来 替 换 。 < / p >
< p > < strong > 注 意 < / strong > : 您 不 该 手 动 管 理 由 Deployment 创 建 的 ReplicaSet, 否 则 您 就 篡 越 了 Deployment controller 的 职 责 ! 下 文 罗 列 了 Deployment 对 象 中 已 经 覆 盖 了 所 有 的 用 例 。 如 果 未 有 覆 盖 您 所 有 需 要 的 用 例 , 请 直 接 在 Kubernetes 的 代 码 库 中 提 issue。 < / p >
< p > 典 型 的 用 例 如 下 : < / p >
< ul >
< li > 使 用 Deployment 来 创 建 ReplicaSet。 ReplicaSet 在 后 台 创 建 pod。 检 查 启 动 状 态 , 看 它 是 成 功 还 是 失 败 。 < / li >
< li > 然 后 , 通 过 更 新 Deployment 的 PodTemplateSpec 字 段 来 声 明 Pod 的 新 状 态 。 这 会 创 建 一 个 新 的 ReplicaSet, Deployment 会 按 照 控 制 的 速 率 将 pod 从 旧 的 ReplicaSet 移 动 到 新 的 ReplicaSet 中 。 < / li >
< li > 如 果 当 前 状 态 不 稳 定 , 回 滚 到 之 前 的 Deployment revision。 每 次 回 滚 都 会 更 新 Deployment 的 revision。 < / li >
< li > 扩 容 Deployment 以 满 足 更 高 的 负 载 。 < / li >
< li > 暂 停 Deployment 来 应 用 PodTemplateSpec 的 多 个 修 复 , 然 后 恢 复 上 线 。 < / li >
< li > 根 据 Deployment 的 状 态 判 断 上 线 是 否 hang 住 了 。 < / li >
< li > 清 除 旧 的 不 必 要 的 ReplicaSet。 < / li >
< / ul >
< h2 id = "创建-deployment" > 创 建 Deployment< / h2 >
< p > 下 面 是 一 个 Deployment 示 例 , 它 创 建 了 一 个 ReplicaSet 来 启 动 3 个 nginx pod。 < / p >
< p > 下 载 示 例 文 件 并 执 行 命 令 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl create -f https://kubernetes.io/docs/user-guide/nginx-deployment.yaml --record
deployment < span class = "token string" > " nginx-deployment" < / span > created
< / code > < / pre >
< p > 将 kubectl 的 < code > --record< / code > 的 flag 设 置 为 < code > true< / code > 可 以 在 annotation 中 记 录 当 前 命 令 创 建 或 者 升 级 了 该 资 源 。 这 在 未 来 会 很 有 用 , 例 如 , 查 看 在 每 个 Deployment revision 中 执 行 了 哪 些 命 令 。 < / p >
2020-06-19 14:52:56 +08:00
< p > 然 后 立 即 执 行 < code > get< / code > 将 获 得 如 下 结 果 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 3< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > 1s
< / code > < / pre >
< p > 输 出 结 果 表 明 我 们 希 望 的 repalica 数 是 3( 根 据 deployment 中 的 < code > .spec.replicas< / code > 配 置 ) 当 前 replica 数 ( < code > .status.replicas< / code > ) 是 0, 最 新 的 replica 数 ( < code > .status.updatedReplicas< / code > ) 是 0, 可 用 的 replica 数 ( < code > .status.availableReplicas< / code > ) 是 0。 < / p >
< p > 过 几 秒 后 再 执 行 < code > get< / code > 命 令 , 将 获 得 如 下 输 出 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 18s
< / code > < / pre >
< p > 我 们 可 以 看 到 Deployment 已 经 创 建 了 3 个 replica, 所 有 的 replica 都 已 经 是 最 新 的 了 ( 包 含 最 新 的 pod template) , 可 用 的 ( 根 据 Deployment 中 的 < code > .spec.minReadySeconds< / code > 声 明 , 处 于 已 就 绪 状 态 的 pod 的 最 少 个 数 ) 。 执 行 < code > kubectl get rs< / code > 和 < code > kubectl get pods< / code > 会 显 示 Replica Set( RS) 和 Pod 已 创 建 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-2035384211 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 0< / span > 18s
< / code > < / pre >
< p > 您 可 能 会 注 意 到 ReplicaSet 的 名 字 总 是 < code > < span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > Deployment< / span > < span class = "token attr-name" > 的 名 字 < / span > < span class = "token punctuation" > > < / span > < / span > -< span class = "token tag" > < span class = "token tag" > < span class = "token punctuation" > < < / span > pod< / span > < span class = "token attr-name" > template< / span > < span class = "token attr-name" > 的 < / span > < span class = "token attr-name" > hash< / span > < span class = "token attr-name" > 值 < / span > < span class = "token punctuation" > > < / span > < / span > < / code > 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx-deployment-2035384211-7ci7o < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 18s < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx,pod-template-hash< span class = "token operator" > =< / span > < span class = "token number" > 2035384211< / span >
nginx-deployment-2035384211-kzszj < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 18s < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx,pod-template-hash< span class = "token operator" > =< / span > < span class = "token number" > 2035384211< / span >
nginx-deployment-2035384211-qqcnn < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 18s < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx,pod-template-hash< span class = "token operator" > =< / span > < span class = "token number" > 2035384211< / span >
< / code > < / pre >
< p > 刚 创 建 的 Replica Set 将 保 证 总 是 有 3 个 nginx 的 pod 存 在 。 < / p >
< p > < strong > 注 意 : < / strong > 您 必 须 在 Deployment 中 的 selector 指 定 正 确 的 pod template label( 在 该 示 例 中 是 < code > app = nginx< / code > ) , 不 要 跟 其 他 的 controller 的 selector 中 指 定 的 pod template label 搞 混 了 ( 包 括 Deployment、 Replica Set、 Replication Controller 等 ) 。 < strong > Kubernetes 本 身 并 不 会 阻 止 您 任 意 指 定 pod template label< / strong > , 但 是 如 果 您 真 的 这 么 做 了 , 这 些 controller 之 间 会 相 互 打 架 , 并 可 能 导 致 不 正 确 的 行 为 。 < / p >
< h3 id = "pod-template-hash-label" > Pod-template-hash label< / h3 >
< p > < strong > 注 意 < / strong > : 这 个 label 不 是 用 户 指 定 的 ! < / p >
< p > 注 意 上 面 示 例 输 出 中 的 pod label 里 的 pod-template-hash label。 当 Deployment 创 建 或 者 接 管 ReplicaSet 时 , Deployment controller 会 自 动 为 Pod 添 加 pod-template-hash label。 这 样 做 的 目 的 是 防 止 Deployment 的 子 ReplicaSet 的 pod 名 字 重 复 。 通 过 将 ReplicaSet 的 PodTemplate 进 行 哈 希 散 列 , 使 用 生 成 的 哈 希 值 作 为 label 的 值 , 并 添 加 到 ReplicaSet selector 里 、 pod template label 和 ReplicaSet 管 理 中 的 Pod 上 。 < / p >
< h2 id = "更新-deployment" > 更 新 Deployment< / h2 >
< p > < strong > 注 意 : < / strong > Deployment 的 rollout 当 且 仅 当 Deployment 的 pod template( 例 如 < code > .spec.template< / code > ) 中 的 label 更 新 或 者 镜 像 更 改 时 被 触 发 。 其 他 更 新 , 例 如 扩 容 Deployment 不 会 触 发 rollout。 < / p >
< p > 假 如 我 们 现 在 想 要 让 nginx pod 使 用 < code > nginx:1.9.1< / code > 的 镜 像 来 代 替 原 来 的 < code > nginx:1.7.9< / code > 的 镜 像 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.9.1
deployment < span class = "token string" > " nginx-deployment" < / span > image updated
< / code > < / pre >
< p > 我 们 可 以 使 用 < code > edit< / code > 命 令 来 编 辑 Deployment, 修 改 < code > .spec.template.spec.containers [0].image< / code > , 将 < code > nginx:1.7.9< / code > 改 写 成 < code > nginx:1.9.1< / code > 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl edit deployment/nginx-deployment
deployment < span class = "token string" > " nginx-deployment" < / span > edited
< / code > < / pre >
< p > 查 看 rollout 的 状 态 , 只 要 执 行 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout status deployment/nginx-deployment
Waiting < span class = "token keyword" > for< / span > rollout to finish: < span class = "token number" > 2< / span > out of < span class = "token number" > 3< / span > new replicas have been updated< span class = "token punctuation" > ..< / span > .
deployment < span class = "token string" > " nginx-deployment" < / span > successfully rolled out
< / code > < / pre >
< p > Rollout 成 功 后 , < code > get< / code > Deployment: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deployments
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 36s
< / code > < / pre >
< p > UP-TO-DATE 的 replica 的 数 目 已 经 达 到 了 配 置 中 要 求 的 数 目 。 < / p >
< p > CURRENT 的 replica 数 表 示 Deployment 管 理 的 replica 数 量 , AVAILABLE 的 replica 数 是 当 前 可 用 的 replica 数 量 。 < / p >
< p > 我 们 通 过 执 行 < code > kubectl get rs< / code > 可 以 看 到 Deployment 更 新 了 Pod, 通 过 创 建 一 个 新 的 ReplicaSet 并 扩 容 了 3 个 replica, 同 时 将 原 来 的 ReplicaSet 缩 容 到 了 0 个 replica。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-1564180365 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 0< / span > 6s
nginx-deployment-2035384211 < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > 36s
< / code > < / pre >
< p > 执 行 < code > get pods< / code > 只 会 看 到 当 前 的 新 的 pod: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-1564180365-khku8 < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 14s
nginx-deployment-1564180365-nacti < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 14s
nginx-deployment-1564180365-z9gth < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 14s
< / code > < / pre >
< p > 下 次 更 新 这 些 pod 的 时 候 , 只 需 要 更 新 Deployment 中 的 pod 的 template 即 可 。 < / p >
< p > Deployment 可 以 保 证 在 升 级 时 只 有 一 定 数 量 的 Pod 是 down 的 。 默 认 的 , 它 会 确 保 至 少 有 比 期 望 的 Pod 数 量 少 一 个 是 up 状 态 ( 最 多 一 个 不 可 用 ) 。 < / p >
< p > Deployment 同 时 也 可 以 确 保 只 创 建 出 超 过 期 望 数 量 的 一 定 数 量 的 Pod。 默 认 的 , 它 会 确 保 最 多 比 期 望 的 Pod 数 量 多 一 个 的 Pod 是 up 的 ( 最 多 1 个 surge ) 。 < / p >
< p > < strong > 在 未 来 的 Kuberentes 版 本 中 , 将 从 1-1 变 成 25%-25%。 < / strong > < / p >
< p > 例 如 , 如 果 您 自 己 看 下 上 面 的 Deployment, 您 会 发 现 , 开 始 创 建 一 个 新 的 Pod, 然 后 删 除 一 些 旧 的 Pod 再 创 建 一 个 新 的 。 当 新 的 Pod 创 建 出 来 之 前 不 会 杀 掉 旧 的 Pod。 这 样 能 够 确 保 可 用 的 Pod 数 量 至 少 有 2 个 , Pod 的 总 数 最 多 4 个 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl describe deployments
Name: nginx-deployment
Namespace: default
CreationTimestamp: Tue, < span class = "token number" > 15< / span > Mar < span class = "token number" > 2016< / span > < span class = "token number" > 12< / span > :01:06 -0700
Labels: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Selector: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Replicas: < span class = "token number" > 3< / span > updated < span class = "token operator" > |< / span > < span class = "token number" > 3< / span > total < span class = "token operator" > |< / span > < span class = "token number" > 3< / span > available < span class = "token operator" > |< / span > < span class = "token number" > 0< / span > unavailable
StrategyType: RollingUpdate
MinReadySeconds: < span class = "token number" > 0< / span >
RollingUpdateStrategy: < span class = "token number" > 1< / span > max unavailable, < span class = "token number" > 1< / span > max surge
OldReplicaSets: < span class = "token operator" > < < / span > none< span class = "token operator" > > < / span >
NewReplicaSet: nginx-deployment-1564180365 < span class = "token punctuation" > (< / span > < span class = "token number" > 3< / span > /3 replicas created< span class = "token punctuation" > )< / span >
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
36s 36s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 3< / span >
23s 23s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 1< / span >
23s 23s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 2< / span >
23s 23s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 2< / span >
21s 21s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 0< / span >
21s 21s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 3< / span >
< / code > < / pre >
< p > 我 们 可 以 看 到 当 我 们 刚 开 始 创 建 这 个 Deployment 的 时 候 , 创 建 了 一 个 ReplicaSet( nginx-deployment-2035384211) , 并 直 接 扩 容 到 了 3 个 replica。 < / p >
< p > 当 我 们 更 新 这 个 Deployment 的 时 候 , 它 会 创 建 一 个 新 的 ReplicaSet( nginx-deployment-1564180365) , 将 它 扩 容 到 1 个 replica, 然 后 缩 容 原 先 的 ReplicaSet 到 2 个 replica, 此 时 满 足 至 少 2 个 Pod 是 可 用 状 态 , 同 一 时 刻 最 多 有 4 个 Pod 处 于 创 建 的 状 态 。 < / p >
< p > 接 着 继 续 使 用 相 同 的 rolling update 策 略 扩 容 新 的 ReplicaSet 和 缩 容 旧 的 ReplicaSet。 最 终 , 将 会 在 新 的 ReplicaSet 中 有 3 个 可 用 的 replica, 旧 的 ReplicaSet 的 replica 数 目 变 成 0。 < / p >
< h3 id = "rollover(多个-rollout-并行)" > Rollover( 多 个 rollout 并 行 ) < / h3 >
< p > 每 当 Deployment controller 观 测 到 有 新 的 deployment 被 创 建 时 , 如 果 没 有 已 存 在 的 ReplicaSet 来 创 建 期 望 个 数 的 Pod 的 话 , 就 会 创 建 出 一 个 新 的 ReplicaSet 来 做 这 件 事 。 已 存 在 的 ReplicaSet 控 制 label 与 < code > .spec.selector< / code > 匹 配 但 是 template 跟 < code > .spec.template< / code > 不 匹 配 的 Pod 缩 容 。 最 终 , 新 的 ReplicaSet 将 会 扩 容 出 < code > .spec.replicas< / code > 指 定 数 目 的 Pod, 旧 的 ReplicaSet 会 缩 容 到 0。 < / p >
< p > 如 果 您 更 新 了 一 个 的 已 存 在 并 正 在 进 行 中 的 Deployment, 每 次 更 新 Deployment 都 会 创 建 一 个 新 的 ReplicaSet 并 扩 容 它 , 同 时 回 滚 之 前 扩 容 的 ReplicaSet — — 将 它 添 加 到 旧 的 ReplicaSet 列 表 中 , 开 始 缩 容 。 < / p >
< p > 例 如 , 假 如 您 创 建 了 一 个 有 5 个 < code > niginx:1.7.9< / code > replica 的 Deployment, 但 是 当 还 只 有 3 个 < code > nginx:1.7.9< / code > 的 replica 创 建 出 来 的 时 候 您 就 开 始 更 新 含 有 5 个 < code > nginx:1.9.1< / code > replica 的 Deployment。 在 这 种 情 况 下 , Deployment 会 立 即 杀 掉 已 创 建 的 3 个 < code > nginx:1.7.9< / code > 的 Pod, 并 开 始 创 建 < code > nginx:1.9.1< / code > 的 Pod。 它 不 会 等 到 所 有 的 5 个 < code > nginx:1.7.9< / code > 的 Pod 都 创 建 完 成 后 才 开 始 改 变 航 道 。 < / p >
< h3 id = "label-selector-更新" > Label selector 更 新 < / h3 >
< p > 我 们 通 常 不 鼓 励 更 新 label selector, 我 们 建 议 事 先 规 划 好 您 的 selector。 < / p >
< p > 任 何 情 况 下 , 只 要 您 想 要 执 行 label selector 的 更 新 , 请 一 定 要 谨 慎 并 确 认 您 已 经 预 料 到 所 有 可 能 因 此 导 致 的 后 果 。 < / p >
< ul >
< li > 增 添 selector 需 要 同 时 在 Deployment 的 spec 中 更 新 新 的 label, 否 则 将 返 回 校 验 错 误 。 此 更 改 是 不 可 覆 盖 的 , 这 意 味 着 新 的 selector 不 会 选 择 使 用 旧 selector 创 建 的 ReplicaSet 和 Pod, 从 而 导 致 所 有 旧 版 本 的 ReplicaSet 都 被 丢 弃 , 并 创 建 新 的 ReplicaSet。 < / li >
< li > 更 新 selector, 即 更 改 selector key 的 当 前 值 , 将 导 致 跟 增 添 selector 同 样 的 后 果 。 < / li >
< li > 删 除 selector, 即 删 除 Deployment selector 中 的 已 有 的 key, 不 需 要 对 Pod template label 做 任 何 更 改 , 现 有 的 ReplicaSet 也 不 会 成 为 孤 儿 , 但 是 请 注 意 , 删 除 的 label 仍 然 存 在 于 现 有 的 Pod 和 ReplicaSet 中 。 < / li >
< / ul >
< h2 id = "回退-deployment" > 回 退 Deployment< / h2 >
< p > 有 时 候 您 可 能 想 回 退 一 个 Deployment, 例 如 , 当 Deployment 不 稳 定 时 , 比 如 一 直 crash looping。 < / p >
< p > 默 认 情 况 下 , kubernetes 会 在 系 统 中 保 存 前 两 次 的 Deployment 的 rollout 历 史 记 录 , 以 便 您 可 以 随 时 回 退 ( 您 可 以 修 改 < code > revision history limit< / code > 来 更 改 保 存 的 revision 数 ) 。 < / p >
< p > < strong > 注 意 : < / strong > 只 要 Deployment 的 rollout 被 触 发 就 会 创 建 一 个 revision。 也 就 是 说 当 且 仅 当 Deployment 的 Pod template( 如 < code > .spec.template< / code > ) 被 更 改 , 例 如 更 新 template 中 的 label 和 容 器 镜 像 时 , 就 会 创 建 出 一 个 新 的 revision。 < / p >
< p > 其 他 的 更 新 , 比 如 扩 容 Deployment 不 会 创 建 revision— — 因 此 我 们 可 以 很 方 便 的 手 动 或 者 自 动 扩 容 。 这 意 味 着 当 您 回 退 到 历 史 revision 时 , 只 有 Deployment 中 的 Pod template 部 分 才 会 回 退 。 < / p >
< p > 假 设 我 们 在 更 新 Deployment 的 时 候 犯 了 一 个 拼 写 错 误 , 将 镜 像 的 名 字 写 成 了 < code > nginx:1.91< / code > , 而 正 确 的 名 字 应 该 是 < code > nginx:1.9.1< / code > : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.91
deployment < span class = "token string" > " nginx-deployment" < / span > image updated
< / code > < / pre >
< p > Rollout 将 会 卡 住 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout status deployments nginx-deployment
Waiting < span class = "token keyword" > for< / span > rollout to finish: < span class = "token number" > 2< / span > out of < span class = "token number" > 3< / span > new replicas have been updated< span class = "token punctuation" > ..< / span > .
< / code > < / pre >
< p > 按 住 Ctrl-C 停 止 上 面 的 rollout 状 态 监 控 。 < / p >
< p > 您 会 看 到 旧 的 replica( nginx-deployment-1564180365 和 nginx-deployment-2035384211) 和 新 的 replica ( nginx-deployment-3066724191) 数 目 都 是 2 个 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-1564180365 < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > < span class = "token number" > 0< / span > 25s
nginx-deployment-2035384211 < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > 36s
nginx-deployment-3066724191 < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > 6s
< / code > < / pre >
< p > 看 下 创 建 Pod, 您 会 看 到 有 两 个 新 的 ReplicaSet 创 建 的 Pod 处 于 ImagePullBackOff 状 态 , 循 环 拉 取 镜 像 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-1564180365-70iae < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 25s
nginx-deployment-1564180365-jbqqo < span class = "token number" > 1< / span > /1 Running < span class = "token number" > 0< / span > 25s
nginx-deployment-3066724191-08mng < span class = "token number" > 0< / span > /1 ImagePullBackOff < span class = "token number" > 0< / span > 6s
nginx-deployment-3066724191-eocby < span class = "token number" > 0< / span > /1 ImagePullBackOff < span class = "token number" > 0< / span > 6s
< / code > < / pre >
< p > 注 意 , Deployment controller 会 自 动 停 止 坏 的 rollout, 并 停 止 扩 容 新 的 ReplicaSet。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl describe deployment
Name: nginx-deployment
Namespace: default
CreationTimestamp: Tue, < span class = "token number" > 15< / span > Mar < span class = "token number" > 2016< / span > < span class = "token number" > 14< / span > :48:04 -0700
Labels: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Selector: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Replicas: < span class = "token number" > 2< / span > updated < span class = "token operator" > |< / span > < span class = "token number" > 3< / span > total < span class = "token operator" > |< / span > < span class = "token number" > 2< / span > available < span class = "token operator" > |< / span > < span class = "token number" > 2< / span > unavailable
StrategyType: RollingUpdate
MinReadySeconds: < span class = "token number" > 0< / span >
RollingUpdateStrategy: < span class = "token number" > 1< / span > max unavailable, < span class = "token number" > 1< / span > max surge
OldReplicaSets: nginx-deployment-1564180365 < span class = "token punctuation" > (< / span > < span class = "token number" > 2< / span > /2 replicas created< span class = "token punctuation" > )< / span >
NewReplicaSet: nginx-deployment-3066724191 < span class = "token punctuation" > (< / span > < span class = "token number" > 2< / span > /2 replicas created< span class = "token punctuation" > )< / span >
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
1m 1m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 3< / span >
22s 22s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 1< / span >
22s 22s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 2< / span >
22s 22s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 2< / span >
21s 21s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 0< / span >
21s 21s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 3< / span >
13s 13s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-3066724191 to < span class = "token number" > 1< / span >
13s 13s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 2< / span >
13s 13s < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-3066724191 to < span class = "token number" > 2< / span >
< / code > < / pre >
< p > 为 了 修 复 这 个 问 题 , 我 们 需 要 回 退 到 稳 定 的 Deployment revision。 < / p >
< h3 id = "检查-deployment-升级的历史记录" > 检 查 Deployment 升 级 的 历 史 记 录 < / h3 >
< p > 首 先 , 检 查 下 Deployment 的 revision: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout < span class = "token function" > history< / span > deployment/nginx-deployment
deployments < span class = "token string" > " nginx-deployment" < / span > < span class = "token builtin class-name" > :< / span >
REVISION CHANGE-CAUSE
< span class = "token number" > 1< / span > kubectl create -f https://kubernetes.io/docs/user-guide/nginx-deployment.yaml--record
< span class = "token number" > 2< / span > kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.9.1
< span class = "token number" > 3< / span > kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.91
< / code > < / pre >
< p > 因 为 我 们 创 建 Deployment 的 时 候 使 用 了 < code > --record< / code > 参 数 可 以 记 录 命 令 , 我 们 可 以 很 方 便 的 查 看 每 次 revision 的 变 化 。 < / p >
< p > 查 看 单 个 revision 的 详 细 信 息 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout < span class = "token function" > history< / span > deployment/nginx-deployment --revision< span class = "token operator" > =< / span > < span class = "token number" > 2< / span >
deployments < span class = "token string" > " nginx-deployment" < / span > revision < span class = "token number" > 2< / span >
Labels: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
pod-template-hash< span class = "token operator" > =< / span > < span class = "token number" > 1159050644< / span >
Annotations: kubernetes.io/change-cause< span class = "token operator" > =< / span > kubectl < span class = "token builtin class-name" > set< / span > image deployment/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.9.1
Containers:
nginx:
Image: nginx:1.9.1
Port: < span class = "token number" > 80< / span > /TCP
QoS Tier:
cpu: BestEffort
memory: BestEffort
Environment Variables: < span class = "token operator" > < < / span > none< span class = "token operator" > > < / span >
No volumes.
< / code > < / pre >
< h3 id = "回退到历史版本" > 回 退 到 历 史 版 本 < / h3 >
< p > 现 在 , 我 们 可 以 决 定 回 退 当 前 的 rollout 到 之 前 的 版 本 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout undo deployment/nginx-deployment
deployment < span class = "token string" > " nginx-deployment" < / span > rolled back
< / code > < / pre >
< p > 也 可 以 使 用 < code > --revision< / code > 参 数 指 定 某 个 历 史 版 本 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout undo deployment/nginx-deployment --to-revision< span class = "token operator" > =< / span > < span class = "token number" > 2< / span >
deployment < span class = "token string" > " nginx-deployment" < / span > rolled back
< / code > < / pre >
< p > 该 Deployment 现 在 已 经 回 退 到 了 先 前 的 稳 定 版 本 。 如 您 所 见 , Deployment controller 产 生 了 一 个 回 退 到 revison 2 的 < code > DeploymentRollback< / code > 的 event。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 30m
$ kubectl describe deployment
Name: nginx-deployment
Namespace: default
CreationTimestamp: Tue, < span class = "token number" > 15< / span > Mar < span class = "token number" > 2016< / span > < span class = "token number" > 14< / span > :48:04 -0700
Labels: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Selector: < span class = "token assign-left variable" > app< / span > < span class = "token operator" > =< / span > nginx
Replicas: < span class = "token number" > 3< / span > updated < span class = "token operator" > |< / span > < span class = "token number" > 3< / span > total < span class = "token operator" > |< / span > < span class = "token number" > 3< / span > available < span class = "token operator" > |< / span > < span class = "token number" > 0< / span > unavailable
StrategyType: RollingUpdate
MinReadySeconds: < span class = "token number" > 0< / span >
RollingUpdateStrategy: < span class = "token number" > 1< / span > max unavailable, < span class = "token number" > 1< / span > max surge
OldReplicaSets: < span class = "token operator" > < < / span > none< span class = "token operator" > > < / span >
NewReplicaSet: nginx-deployment-1564180365 < span class = "token punctuation" > (< / span > < span class = "token number" > 3< / span > /3 replicas created< span class = "token punctuation" > )< / span >
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
30m 30m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 3< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 1< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 2< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 2< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-2035384211 to < span class = "token number" > 0< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-3066724191 to < span class = "token number" > 2< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-3066724191 to < span class = "token number" > 1< / span >
29m 29m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 2< / span >
2m 2m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled down replica < span class = "token builtin class-name" > set< / span > nginx-deployment-3066724191 to < span class = "token number" > 0< / span >
2m 2m < span class = "token number" > 1< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal DeploymentRollback Rolled back deployment < span class = "token string" > " nginx-deployment" < / span > to revision < span class = "token number" > 2< / span >
29m 2m < span class = "token number" > 2< / span > < span class = "token punctuation" > {< / span > deployment-controller< span class = "token punctuation" > }< / span > Normal ScalingReplicaSet Scaled up replica < span class = "token builtin class-name" > set< / span > nginx-deployment-1564180365 to < span class = "token number" > 3< / span >
< / code > < / pre >
< h3 id = "清理-policy" > 清 理 Policy< / h3 >
< p > 您 可 以 通 过 设 置 < code > .spec.revisonHistoryLimit< / code > 项 来 指 定 deployment 最 多 保 留 多 少 revision 历 史 记 录 。 默 认 的 会 保 留 所 有 的 revision; 如 果 将 该 项 设 置 为 0, Deployment 就 不 允 许 回 退 了 。 < / p >
< h2 id = "deployment-扩容" > Deployment 扩 容 < / h2 >
< p > 您 可 以 使 用 以 下 命 令 扩 容 Deployment: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl scale deployment nginx-deployment --replicas < span class = "token number" > 10< / span >
deployment < span class = "token string" > " nginx-deployment" < / span > scaled
< / code > < / pre >
< p > 假 设 您 的 集 群 中 启 用 了 < a href = "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough" target = "_blank" > horizontal pod autoscaling< / a > , 您 可 以 给 Deployment 设 置 一 个 autoscaler, 基 于 当 前 Pod 的 CPU 利 用 率 选 择 最 少 和 最 多 的 Pod 数 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl autoscale deployment nginx-deployment --min< span class = "token operator" > =< / span > < span class = "token number" > 10< / span > --max< span class = "token operator" > =< / span > < span class = "token number" > 15< / span > --cpu-percent< span class = "token operator" > =< / span > < span class = "token number" > 80< / span >
deployment < span class = "token string" > " nginx-deployment" < / span > autoscaled
< / code > < / pre >
< h3 id = "比例扩容" > 比 例 扩 容 < / h3 >
< p > RollingUpdate Deployment 支 持 同 时 运 行 一 个 应 用 的 多 个 版 本 。 或 者 autoscaler 扩 容 RollingUpdate Deployment 的 时 候 , 正 在 中 途 的 rollout( 进 行 中 或 者 已 经 暂 停 的 ) , 为 了 降 低 风 险 , Deployment controller 将 会 平 衡 已 存 在 的 活 动 中 的 ReplicaSet( 有 Pod 的 ReplicaSet) 和 新 加 入 的 replica。 这 被 称 为 比 例 扩 容 。 < / p >
< p > 例 如 , 您 正 在 运 行 中 含 有 10 个 replica 的 Deployment。 maxSurge=3, maxUnavailable=2。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 10< / span > < span class = "token number" > 10< / span > < span class = "token number" > 10< / span > < span class = "token number" > 10< / span > 50s
< / code > < / pre >
< p > 您 更 新 了 一 个 镜 像 , 而 在 集 群 内 部 无 法 解 析 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl < span class = "token builtin class-name" > set< / span > image deploy/nginx-deployment < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:sometag
deployment < span class = "token string" > " nginx-deployment" < / span > image updated
< / code > < / pre >
< p > 镜 像 更 新 启 动 了 一 个 包 含 ReplicaSet nginx-deployment-1989198191 的 新 的 rollout, 但 是 它 被 阻 塞 了 , 因 为 我 们 上 面 提 到 的 maxUnavailable。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-1989198191 < span class = "token number" > 5< / span > < span class = "token number" > 5< / span > < span class = "token number" > 0< / span > 9s
nginx-deployment-618515232 < span class = "token number" > 8< / span > < span class = "token number" > 8< / span > < span class = "token number" > 8< / span > 1m
< / code > < / pre >
< p > 然 后 发 起 了 一 个 新 的 Deployment 扩 容 请 求 。 autoscaler 将 Deployment 的 repllica 数 目 增 加 到 了 15 个 。 Deployment controller 需 要 判 断 在 哪 里 增 加 这 5 个 新 的 replica。 如 果 我 们 没 有 谁 用 比 例 扩 容 , 所 有 的 5 个 replica 都 会 加 到 一 个 新 的 ReplicaSet 中 。 如 果 使 用 比 例 扩 容 , 新 添 加 的 replica 将 传 播 到 所 有 的 ReplicaSet 中 。 大 的 部 分 加 入 replica 数 最 多 的 ReplicaSet 中 , 小 的 部 分 加 入 到 replica 数 少 的 ReplciaSet 中 。 0 个 replica 的 ReplicaSet 不 会 被 扩 容 。 < / p >
< p > 在 我 们 上 面 的 例 子 中 , 3 个 replica 将 添 加 到 旧 的 ReplicaSet 中 , 2 个 replica 将 添 加 到 新 的 ReplicaSet 中 。 rollout 进 程 最 终 会 将 所 有 的 replica 移 动 到 新 的 ReplicaSet 中 , 假 设 新 的 replica 成 为 健 康 状 态 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx-deployment < span class = "token number" > 15< / span > < span class = "token number" > 18< / span > < span class = "token number" > 7< / span > < span class = "token number" > 8< / span > 7m
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-1989198191 < span class = "token number" > 7< / span > < span class = "token number" > 7< / span > < span class = "token number" > 0< / span > 7m
nginx-deployment-618515232 < span class = "token number" > 11< / span > < span class = "token number" > 11< / span > < span class = "token number" > 11< / span > 7m
< / code > < / pre >
< h2 id = "删除-autoscale" > 删 除 autoscale< / h2 >
< pre class = "language-" > < code class = "lang-bash" > kubectl get hpa
kubectl delete hpa < span class = "token variable" > ${name of hpa}< / span >
< / code > < / pre >
< h2 id = "暂停和恢复-deployment" > 暂 停 和 恢 复 Deployment< / h2 >
< p > 您 可 以 在 发 出 一 次 或 多 次 更 新 前 暂 停 一 个 Deployment, 然 后 再 恢 复 它 。 这 样 您 就 能 在 Deployment 暂 停 期 间 进 行 多 次 修 复 工 作 , 而 不 会 发 出 不 必 要 的 rollout。 < / p >
< p > 例 如 使 用 刚 刚 创 建 Deployment: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl get deploy
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
nginx < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 1m
< span class = "token punctuation" > [< / span > mkargaki@dhcp129-211 kubernetes< span class = "token punctuation" > ]< / span > $ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-2142116321 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 1m
< / code > < / pre >
< p > 使 用 以 下 命 令 暂 停 Deployment: < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout pause deployment/nginx-deployment
deployment < span class = "token string" > " nginx-deployment" < / span > paused
< / code > < / pre >
< p > 然 后 更 新 Deplyment 中 的 镜 像 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl < span class = "token builtin class-name" > set< / span > image deploy/nginx < span class = "token assign-left variable" > nginx< / span > < span class = "token operator" > =< / span > nginx:1.9.1
deployment < span class = "token string" > " nginx-deployment" < / span > image updated
< / code > < / pre >
< p > 注 意 新 的 rollout 启 动 了 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout < span class = "token function" > history< / span > deploy/nginx
deployments < span class = "token string" > " nginx" < / span >
REVISION CHANGE-CAUSE
< span class = "token number" > 1< / span > < span class = "token operator" > < < / span > none< span class = "token operator" > > < / span >
$ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-2142116321 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 2m
< / code > < / pre >
< p > 您 可 以 进 行 任 意 多 次 更 新 , 例 如 更 新 使 用 的 资 源 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl < span class = "token builtin class-name" > set< / span > resources deployment nginx -c< span class = "token operator" > =< / span > nginx --limits< span class = "token operator" > =< / span > cpu< span class = "token operator" > =< / span > 200m,memory< span class = "token operator" > =< / span > 512Mi
deployment < span class = "token string" > " nginx" < / span > resource requirements updated
< / code > < / pre >
< p > Deployment 暂 停 前 的 初 始 状 态 将 继 续 它 的 功 能 , 而 不 会 对 Deployment 的 更 新 产 生 任 何 影 响 , 只 要 Deployment 是 暂 停 的 。 < / p >
< p > 最 后 , 恢 复 这 个 Deployment, 观 察 完 成 更 新 的 ReplicaSet 已 经 创 建 出 来 了 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout resume deploy nginx
deployment < span class = "token string" > " nginx" < / span > resumed
$ KUBECTL get rs -w
NAME DESIRED CURRENT READY AGE
nginx-2142116321 < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > 2m
nginx-3926361531 < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > < span class = "token number" > 0< / span > 6s
nginx-3926361531 < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > < span class = "token number" > 1< / span > 18s
nginx-2142116321 < span class = "token number" > 1< / span > < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > 2m
nginx-2142116321 < span class = "token number" > 1< / span > < span class = "token number" > 2< / span > < span class = "token number" > 2< / span > 2m
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 2< / span > < span class = "token number" > 1< / span > 18s
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 2< / span > < span class = "token number" > 1< / span > 18s
nginx-2142116321 < span class = "token number" > 1< / span > < span class = "token number" > 1< / span > < span class = "token number" > 1< / span > 2m
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 1< / span > 18s
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 2< / span > 19s
nginx-2142116321 < span class = "token number" > 0< / span > < span class = "token number" > 1< / span > < span class = "token number" > 1< / span > 2m
nginx-2142116321 < span class = "token number" > 0< / span > < span class = "token number" > 1< / span > < span class = "token number" > 1< / span > 2m
nginx-2142116321 < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > 2m
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 20s
^C
$ KUBECTL get rs
NAME DESIRED CURRENT READY AGE
nginx-2142116321 < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > < span class = "token number" > 0< / span > 2m
nginx-3926361531 < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > < span class = "token number" > 3< / span > 28s
< / code > < / pre >
< p > < strong > 注 意 : < / strong > 在 恢 复 Deployment 之 前 您 无 法 回 退 一 个 已 经 暂 停 的 Deployment。 < / p >
< h2 id = "deployment-状态" > Deployment 状 态 < / h2 >
< p > Deployment 在 生 命 周 期 中 有 多 种 状 态 。 在 创 建 一 个 新 的 ReplicaSet 的 时 候 它 可 以 是 < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#progressing-deployment" target = "_blank" > progressing< / a > 状 态 , < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#complete-deployment" target = "_blank" > complete< / a > 状 态 , 或 者 < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#failed-deployment" target = "_blank" > fail to progress< / a > 状 态 。 < / p >
< h3 id = "进行中的-deployment" > 进 行 中 的 Deployment< / h3 >
< p > Kubernetes 将 执 行 过 下 列 任 务 之 一 的 Deployment 标 记 为 < em > progressing< / em > 状 态 : < / p >
< ul >
< li > Deployment 正 在 创 建 新 的 ReplicaSet 过 程 中 。 < / li >
< li > Deployment 正 在 扩 容 一 个 已 有 的 ReplicaSet。 < / li >
< li > Deployment 正 在 缩 容 一 个 已 有 的 ReplicaSet。 < / li >
< li > 有 新 的 可 用 的 pod 出 现 。 < / li >
< / ul >
< p > 您 可 以 使 用 < code > kubectl rollout status< / code > 命 令 监 控 Deployment 的 进 度 。 < / p >
< h3 id = "完成的-deployment" > 完 成 的 Deployment< / h3 >
< p > Kubernetes 将 包 括 以 下 特 性 的 Deployment 标 记 为 < em > complete< / em > 状 态 : < / p >
< ul >
< li > Deployment 最 小 可 用 。 最 小 可 用 意 味 着 Deployment 的 可 用 replica 个 数 等 于 或 者 超 过 Deployment 策 略 中 的 期 望 个 数 。 < / li >
< li > 所 有 与 该 Deployment 相 关 的 replica 都 被 更 新 到 了 您 指 定 版 本 , 也 就 说 更 新 完 成 。 < / li >
< li > 该 Deployment 中 没 有 旧 的 Pod 存 在 。 < / li >
< / ul >
< p > 您 可 以 用 < code > kubectl rollout status< / code > 命 令 查 看 Deployment 是 否 完 成 。 如 果 rollout 成 功 完 成 , < code > kubectl rollout status< / code > 将 返 回 一 个 0 值 的 Exit Code。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout status deploy/nginx
Waiting < span class = "token keyword" > for< / span > rollout to finish: < span class = "token number" > 2< / span > of < span class = "token number" > 3< / span > updated replicas are available< span class = "token punctuation" > ..< / span > .
deployment < span class = "token string" > " nginx" < / span > successfully rolled out
$ < span class = "token builtin class-name" > echo< / span > < span class = "token variable" > $?< / span >
< span class = "token number" > 0< / span >
< / code > < / pre >
< h3 id = "失败的-deployment" > 失 败 的 Deployment< / h3 >
< p > 您 的 Deployment 在 尝 试 部 署 新 的 ReplicaSet 的 时 候 可 能 卡 住 , 永 远 也 不 会 完 成 。 这 可 能 是 因 为 以 下 几 个 因 素 引 起 的 : < / p >
< ul >
< li > 无 效 的 引 用 < / li >
< li > 不 可 读 的 probe failure< / li >
< li > 镜 像 拉 取 错 误 < / li >
< li > 权 限 不 够 < / li >
< li > 范 围 限 制 < / li >
< li > 程 序 运 行 时 配 置 错 误 < / li >
< / ul >
< p > 探 测 这 种 情 况 的 一 种 方 式 是 , 在 您 的 Deployment spec 中 指 定 < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#progress-deadline-seconds" target = "_blank" > < code > spec.progressDeadlineSeconds< / code > < / a > 。 < code > spec.progressDeadlineSeconds< / code > 表 示 Deployment controller 等 待 多 少 秒 才 能 确 定 ( 通 过 Deployment status) Deployment 进 程 是 卡 住 的 。 < / p >
< p > 下 面 的 < code > kubectl< / code > 命 令 设 置 < code > progressDeadlineSeconds< / code > 使 controller 在 Deployment 在 进 度 卡 住 10 分 钟 后 报 告 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl patch deployment/nginx-deployment -p < span class = "token string" > ' {" spec" :{" progressDeadlineSeconds" :600}}' < / span >
< span class = "token string" > " nginx-deployment" < / span > patched
< / code > < / pre >
< p > 当 超 过 截 止 时 间 后 , Deployment controller 会 在 Deployment 的 < code > status.conditions< / code > 中 增 加 一 条 DeploymentCondition, 它 包 括 如 下 属 性 : < / p >
< ul >
< li > Type=Progressing< / li >
< li > Status=False< / li >
< li > Reason=ProgressDeadlineExceeded< / li >
< / ul >
< p > < strong > 注 意 : < / strong > kubernetes 除 了 报 告 < code > Reason=ProgressDeadlineExceeded< / code > 状 态 信 息 外 不 会 对 卡 住 的 Deployment 做 任 何 操 作 。 更 高 层 次 的 协 调 器 可 以 利 用 它 并 采 取 相 应 行 动 , 例 如 , 回 滚 Deployment 到 之 前 的 版 本 。 < / p >
< p > < strong > 注 意 : < / strong > 如 果 您 暂 停 了 一 个 Deployment, 在 暂 停 的 这 段 时 间 内 kubernetnes 不 会 检 查 您 指 定 的 deadline。 您 可 以 在 Deployment 的 rollout 途 中 安 全 的 暂 停 它 , 然 后 再 恢 复 它 , 这 不 会 触 发 超 过 deadline 的 状 态 。 < / p >
< p > 您 可 能 在 使 用 Deployment 的 时 候 遇 到 一 些 短 暂 的 错 误 , 这 些 可 能 是 由 于 您 设 置 了 太 短 的 timeout, 也 有 可 能 是 因 为 各 种 其 他 错 误 导 致 的 短 暂 错 误 。 例 如 , 假 设 您 使 用 了 无 效 的 引 用 。 当 您 Describe Deployment 的 时 候 可 能 会 注 意 到 如 下 信 息 : < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl describe deployment nginx-deployment
< span class = "token operator" > < < / span > < span class = "token punctuation" > ..< / span > .< span class = "token operator" > > < / span >
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True ReplicaSetUpdated
ReplicaFailure True FailedCreate
< span class = "token operator" > < < / span > < span class = "token punctuation" > ..< / span > .< span class = "token operator" > > < / span >
< / code > < / pre >
< p > 执 行 < code > kubectl get deployment nginx-deployment -o yaml< / code > , Deployement 的 状 态 可 能 看 起 来 像 这 个 样 子 : < / p >
< pre class = "language-" > < code class = "lang-yaml" > < span class = "token key atrule" > status< / span > < span class = "token punctuation" > :< / span >
< span class = "token key atrule" > availableReplicas< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 2< / span >
< span class = "token key atrule" > conditions< / span > < span class = "token punctuation" > :< / span >
< span class = "token punctuation" > -< / span > < span class = "token key atrule" > lastTransitionTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:39Z< / span >
< span class = "token key atrule" > lastUpdateTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:39Z< / span >
< span class = "token key atrule" > message< / span > < span class = "token punctuation" > :< / span > Replica set " nginx< span class = "token punctuation" > -< / span > deployment< span class = "token punctuation" > -< / span > 4262182780" is progressing.
< span class = "token key atrule" > reason< / span > < span class = "token punctuation" > :< / span > ReplicaSetUpdated
< span class = "token key atrule" > status< / span > < span class = "token punctuation" > :< / span > < span class = "token string" > " True" < / span >
< span class = "token key atrule" > type< / span > < span class = "token punctuation" > :< / span > Progressing
< span class = "token punctuation" > -< / span > < span class = "token key atrule" > lastTransitionTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:42Z< / span >
< span class = "token key atrule" > lastUpdateTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:42Z< / span >
< span class = "token key atrule" > message< / span > < span class = "token punctuation" > :< / span > Deployment has minimum availability.
< span class = "token key atrule" > reason< / span > < span class = "token punctuation" > :< / span > MinimumReplicasAvailable
< span class = "token key atrule" > status< / span > < span class = "token punctuation" > :< / span > < span class = "token string" > " True" < / span >
< span class = "token key atrule" > type< / span > < span class = "token punctuation" > :< / span > Available
< span class = "token punctuation" > -< / span > < span class = "token key atrule" > lastTransitionTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:39Z< / span >
< span class = "token key atrule" > lastUpdateTime< / span > < span class = "token punctuation" > :< / span > < span class = "token datetime number" > 2016-10-04T12:25:39Z< / span >
< span class = "token key atrule" > message< / span > < span class = "token punctuation" > :< / span > ' Error creating< span class = "token punctuation" > :< / span > pods " nginx< span class = "token punctuation" > -< / span > deployment< span class = "token punctuation" > -< / span > 4262182780< span class = "token punctuation" > -< / span > " is forbidden< span class = "token punctuation" > :< / span > exceeded quota< span class = "token punctuation" > :< / span >
object< span class = "token punctuation" > -< / span > counts< span class = "token punctuation" > ,< / span > < span class = "token key atrule" > requested< / span > < span class = "token punctuation" > :< / span > pods=1< span class = "token punctuation" > ,< / span > < span class = "token key atrule" > used< / span > < span class = "token punctuation" > :< / span > pods=3< span class = "token punctuation" > ,< / span > < span class = "token key atrule" > limited< / span > < span class = "token punctuation" > :< / span > pods=2'
< span class = "token key atrule" > reason< / span > < span class = "token punctuation" > :< / span > FailedCreate
< span class = "token key atrule" > status< / span > < span class = "token punctuation" > :< / span > < span class = "token string" > " True" < / span >
< span class = "token key atrule" > type< / span > < span class = "token punctuation" > :< / span > ReplicaFailure
< span class = "token key atrule" > observedGeneration< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 3< / span >
< span class = "token key atrule" > replicas< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 2< / span >
< span class = "token key atrule" > unavailableReplicas< / span > < span class = "token punctuation" > :< / span > < span class = "token number" > 2< / span >
< / code > < / pre >
< p > 最 终 , 一 旦 超 过 Deployment 进 程 的 deadline, kubernetes 会 更 新 状 态 和 导 致 Progressing 状 态 的 原 因 : < / p >
< pre class = "language-" > < code class = "lang-bash" > Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing False ProgressDeadlineExceeded
ReplicaFailure True FailedCreate
< / code > < / pre >
< p > 您 可 以 通 过 缩 容 Deployment 的 方 式 解 决 配 额 不 足 的 问 题 , 或 者 增 加 您 的 namespace 的 配 额 。 如 果 您 满 足 了 配 额 条 件 后 , Deployment controller 就 会 完 成 您 的 Deployment rollout, 您 将 看 到 Deployment 的 状 态 更 新 为 成 功 状 态 ( < code > Status=True< / code > 并 且 < code > Reason=NewReplicaSetAvailable< / code > ) 。 < / p >
< pre class = "language-" > < code class = "lang-bash" > Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
< / code > < / pre >
< p > < code > Type=Available< / code > 、 < code > Status=True< / code > 意 味 着 您 的 Deployment 有 最 小 可 用 性 。 最 小 可 用 性 是 在 Deployment 策 略 中 指 定 的 参 数 。 < code > Type=Progressing< / code > 、 < code > Status=True< / code > 意 味 着 您 的 Deployment 或 者 在 部 署 过 程 中 , 或 者 已 经 成 功 部 署 , 达 到 了 期 望 的 最 少 的 可 用 replica 数 量 ( 查 看 特 定 状 态 的 Reason— — 在 我 们 的 例 子 中 < code > Reason=NewReplicaSetAvailable< / code > 意 味 着 Deployment 已 经 完 成 ) 。 < / p >
< p > 您 可 以 使 用 < code > kubectl rollout status< / code > 命 令 查 看 Deployment 进 程 是 否 失 败 。 当 Deployment 过 程 超 过 了 deadline, < code > kubectl rollout status< / code > 将 返 回 非 0 的 exit code。 < / p >
< pre class = "language-" > < code class = "lang-bash" > $ kubectl rollout status deploy/nginx
Waiting < span class = "token keyword" > for< / span > rollout to finish: < span class = "token number" > 2< / span > out of < span class = "token number" > 3< / span > new replicas have been updated< span class = "token punctuation" > ..< / span > .
error: deployment < span class = "token string" > " nginx" < / span > exceeded its progress deadline
$ < span class = "token builtin class-name" > echo< / span > < span class = "token variable" > $?< / span >
< span class = "token number" > 1< / span >
< / code > < / pre >
< h3 id = "操作失败的-deployment" > 操 作 失 败 的 Deployment< / h3 >
< p > 所 有 对 完 成 的 Deployment 的 操 作 都 适 用 于 失 败 的 Deployment。 您 可 以 对 它 扩 / 缩 容 , 回 退 到 历 史 版 本 , 您 甚 至 可 以 多 次 暂 停 它 来 应 用 Deployment pod template。 < / p >
< h2 id = "清理-policy" > 清 理 Policy< / h2 >
< p > 您 可 以 设 置 Deployment 中 的 < code > .spec.revisionHistoryLimit< / code > 项 来 指 定 保 留 多 少 旧 的 ReplicaSet。 余 下 的 将 在 后 台 被 当 作 垃 圾 收 集 。 默 认 的 , 所 有 的 revision 历 史 就 都 会 被 保 留 。 在 未 来 的 版 本 中 , 将 会 更 改 为 2。 < / p >
< p > < strong > 注 意 : < / strong > 将 该 值 设 置 为 0, 将 导 致 所 有 的 Deployment 历 史 记 录 都 会 被 清 除 , 该 Deployment 就 无 法 再 回 退 了 。 < / p >
< h2 id = "用例" > 用 例 < / h2 >
< h3 id = "金丝雀-deployment" > 金 丝 雀 Deployment< / h3 >
< p > 如 果 您 想 要 使 用 Deployment 对 部 分 用 户 或 服 务 器 发 布 release, 您 可 以 创 建 多 个 Deployment, 每 个 Deployment 对 应 一 个 release, 参 照 < a href = "https://kubernetes.io/docs/concepts/cluster-administration/manage-deployment/#canary-deployments" target = "_blank" > managing resources< / a > 中 对 金 丝 雀 模 式 的 描 述 。 < / p >
< h2 id = "编写-deployment-spec" > 编 写 Deployment Spec< / h2 >
< p > 在 所 有 的 Kubernetes 配 置 中 , Deployment 也 需 要 < code > apiVersion< / code > , < code > kind< / code > 和 < code > metadata< / code > 这 些 配 置 项 。 配 置 文 件 的 通 用 使 用 说 明 查 看 < a href = "https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/" target = "_blank" > 部 署 应 用 < / a > , 配 置 容 器 , 和 使 用 kubectl 管 理 资 源 文 档 。 < / p >
< h3 id = "pod-template" > Pod Template< / h3 >
< p > < code > .spec.template< / code > 是 < code > .spec< / code > 中 唯 一 要 求 的 字 段 。 < / p >
< p > < code > .spec.template< / code > 是 < a href = "https://kubernetes.io/docs/user-guide/replication-controller/#pod-template" target = "_blank" > pod template< / a > . 它 跟 < a href = "https://kubernetes.io/docs/user-guide/pods" target = "_blank" > Pod< / a > 有 一 模 一 样 的 schema, 除 了 它 是 嵌 套 的 并 且 不 需 要 < code > apiVersion< / code > 和 < code > kind< / code > 字 段 。 < / p >
< p > 另 外 为 了 划 分 Pod 的 范 围 , Deployment 中 的 pod template 必 须 指 定 适 当 的 label( 不 要 跟 其 他 controller 重 复 了 , 参 考 < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#selector" target = "_blank" > selector< / a > ) 和 适 当 的 重 启 策 略 。 < / p >
< p > < a href = "https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle" target = "_blank" > < code > .spec.template.spec.restartPolicy< / code > < / a > 可 以 设 置 为 < code > Always< / code > , 如 果 不 指 定 的 话 这 就 是 默 认 配 置 。 < / p >
< h3 id = "replicas" > Replicas< / h3 >
< p > < code > .spec.replicas< / code > 是 可 以 选 字 段 , 指 定 期 望 的 pod 数 量 , 默 认 是 1。 < / p >
< h3 id = "selector" > Selector< / h3 >
< p > < code > .spec.selector< / code > 是 可 选 字 段 , 用 来 指 定 < a href = "https://kubernetes.io/docs/concepts/overview/working-with-objects/labels" target = "_blank" > label selector< / a > , 圈 定 Deployment 管 理 的 pod 范 围 。 < / p >
< p > 如 果 被 指 定 , < code > .spec.selector< / code > 必 须 匹 配 < code > .spec.template.metadata.labels< / code > , 否 则 它 将 被 API 拒 绝 。 如 果 < code > .spec.selector< / code > 没 有 被 指 定 , < code > .spec.selector.matchLabels< / code > 默 认 是 < code > .spec.template.metadata.labels< / code > 。 < / p >
< p > 在 Pod 的 template 跟 < code > .spec.template< / code > 不 同 或 者 数 量 超 过 了 < code > .spec.replicas< / code > 规 定 的 数 量 的 情 况 下 , Deployment 会 杀 掉 label 跟 selector 不 同 的 Pod。 < / p >
< p > < strong > 注 意 : < / strong > 您 不 应 该 再 创 建 其 他 label 跟 这 个 selector 匹 配 的 pod, 或 者 通 过 其 他 Deployment, 或 者 通 过 其 他 Controller, 例 如 ReplicaSet 和 ReplicationController。 否 则 该 Deployment 会 被 把 它 们 当 成 都 是 自 己 创 建 的 。 Kubernetes 不 会 阻 止 您 这 么 做 。 < / p >
< p > 如 果 您 有 多 个 controller 使 用 了 重 复 的 selector, controller 们 就 会 互 相 打 架 并 导 致 不 正 确 的 行 为 。 < / p >
< h3 id = "策略" > 策 略 < / h3 >
< p > < code > .spec.strategy< / code > 指 定 新 的 Pod 替 换 旧 的 Pod 的 策 略 。 < code > .spec.strategy.type< / code > 可 以 是 " Recreate" 或 者 是 " RollingUpdate" 。 " RollingUpdate" 是 默 认 值 。 < / p >
< h4 id = "recreate-deployment" > Recreate Deployment< / h4 >
< p > < code > .spec.strategy.type==Recreate< / code > 时 , 在 创 建 出 新 的 Pod 之 前 会 先 杀 掉 所 有 已 存 在 的 Pod。 < / p >
< h4 id = "rolling-update-deployment" > Rolling Update Deployment< / h4 >
< p > < code > .spec.strategy.type==RollingUpdate< / code > 时 , Deployment 使 用 < a href = "https://kubernetes.io/docs/tasks/run-application/rolling-update-replication-controller" target = "_blank" > rolling update< / a > 的 方 式 更 新 Pod 。 您 可 以 指 定 < code > maxUnavailable< / code > 和 < code > maxSurge< / code > 来 控 制 rolling update 进 程 。 < / p >
< h5 id = "max-unavailable" > Max Unavailable< / h5 >
< p > < code > .spec.strategy.rollingUpdate.maxUnavailable< / code > 是 可 选 配 置 项 , 用 来 指 定 在 升 级 过 程 中 不 可 用 Pod 的 最 大 数 量 。 该 值 可 以 是 一 个 绝 对 值 ( 例 如 5) , 也 可 以 是 期 望 Pod 数 量 的 百 分 比 ( 例 如 10%) 。 通 过 计 算 百 分 比 的 绝 对 值 向 下 取 整 。 如 果 < code > .spec.strategy.rollingUpdate.maxSurge< / code > 为 0 时 , 这 个 值 不 可 以 为 0。 默 认 值 是 1。 < / p >
< p > 例 如 , 该 值 设 置 成 30%, 启 动 rolling update 后 旧 的 ReplicatSet 将 会 立 即 缩 容 到 期 望 的 Pod 数 量 的 70%。 新 的 Pod ready 后 , 随 着 新 的 ReplicaSet 的 扩 容 , 旧 的 ReplicaSet 会 进 一 步 缩 容 , 确 保 在 升 级 的 所 有 时 刻 可 以 用 的 Pod 数 量 至 少 是 期 望 Pod 数 量 的 70%。 < / p >
< h5 id = "max-surge" > Max Surge< / h5 >
< p > < code > .spec.strategy.rollingUpdate.maxSurge< / code > 是 可 选 配 置 项 , 用 来 指 定 可 以 超 过 期 望 的 Pod 数 量 的 最 大 个 数 。 该 值 可 以 是 一 个 绝 对 值 ( 例 如 5) 或 者 是 期 望 的 Pod 数 量 的 百 分 比 ( 例 如 10%) 。 当 < code > MaxUnavailable< / code > 为 0 时 该 值 不 可 以 为 0。 通 过 百 分 比 计 算 的 绝 对 值 向 上 取 整 。 默 认 值 是 1。 < / p >
< p > 例 如 , 该 值 设 置 成 30%, 启 动 rolling update 后 新 的 ReplicatSet 将 会 立 即 扩 容 , 新 老 Pod 的 总 数 不 能 超 过 期 望 的 Pod 数 量 的 130%。 旧 的 Pod 被 杀 掉 后 , 新 的 ReplicaSet 将 继 续 扩 容 , 旧 的 ReplicaSet 会 进 一 步 缩 容 , 确 保 在 升 级 的 所 有 时 刻 所 有 的 Pod 数 量 和 不 会 超 过 期 望 Pod 数 量 的 130%。 < / p >
< h3 id = "progress-deadline-seconds" > Progress Deadline Seconds< / h3 >
< p > < code > .spec.progressDeadlineSeconds< / code > 是 可 选 配 置 项 , 用 来 指 定 在 系 统 报 告 Deployment 的 < a href = "https://kubernetes.io/docs/concepts/workloads/controllers/deployment#failed-deployment" target = "_blank" > failed progressing< / a > — — 表 现 为 resource 的 状 态 中 < code > type=Progressing< / code > 、 < code > Status=False< / code > 、 < code > Reason=ProgressDeadlineExceeded< / code > 前 可 以 等 待 的 Deployment 进 行 的 秒 数 。 Deployment controller 会 继 续 重 试 该 Deployment。 未 来 , 在 实 现 了 自 动 回 滚 后 , deployment controller 在 观 察 到 这 种 状 态 时 就 会 自 动 回 滚 。 < / p >
< p > 如 果 设 置 该 参 数 , 该 值 必 须 大 于 < code > .spec.minReadySeconds< / code > 。 < / p >
< h3 id = "min-ready-seconds" > Min Ready Seconds< / h3 >
< p > < code > .spec.minReadySeconds< / code > 是 一 个 可 选 配 置 项 , 用 来 指 定 没 有 任 何 容 器 crash 的 Pod 并 被 认 为 是 可 用 状 态 的 最 小 秒 数 。 默 认 是 0( Pod 在 ready 后 就 会 被 认 为 是 可 用 状 态 ) 。 进 一 步 了 解 什 么 什 么 后 Pod 会 被 认 为 是 ready 状 态 , 参 阅 < a href = "https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes" target = "_blank" > Container Probes< / a > 。 < / p >
< h3 id = "rollback-to" > Rollback To< / h3 >
< p > < code > .spec.rollbackTo< / code > 是 一 个 可 以 选 配 置 项 , 用 来 配 置 Deployment 回 退 的 配 置 。 设 置 该 参 数 将 触 发 回 退 操 作 , 每 次 回 退 完 成 后 , 该 值 就 会 被 清 除 。 < / p >
< h4 id = "revision" > Revision< / h4 >
< p > < code > .spec.rollbackTo.revision< / code > 是 一 个 可 选 配 置 项 , 用 来 指 定 回 退 到 的 revision。 默 认 是 0, 意 味 着 回 退 到 上 一 个 revision。 < / p >
< h3 id = "revision-history-limit" > Revision History Limit< / h3 >
< p > Deployment revision history 存 储 在 它 控 制 的 ReplicaSets 中 。 < / p >
< p > < code > .spec.revisionHistoryLimit< / code > 是 一 个 可 选 配 置 项 , 用 来 指 定 可 以 保 留 的 旧 的 ReplicaSet 数 量 。 该 理 想 值 取 决 于 心 Deployment 的 频 率 和 稳 定 性 。 如 果 该 值 没 有 设 置 的 话 , 默 认 所 有 旧 的 Replicaset 或 会 被 保 留 , 将 资 源 存 储 在 etcd 中 , 是 用 < code > kubectl get rs< / code > 查 看 输 出 。 每 个 Deployment 的 该 配 置 都 保 存 在 ReplicaSet 中 , 然 而 , 一 旦 您 删 除 的 旧 的 RepelicaSet, 您 的 Deployment 就 无 法 再 回 退 到 那 个 revison 了 。 < / p >
< p > 如 果 您 将 该 值 设 置 为 0, 所 有 具 有 0 个 replica 的 ReplicaSet 都 会 被 删 除 。 在 这 种 情 况 下 , 新 的 Deployment rollout 无 法 撤 销 , 因 为 revision history 都 被 清 理 掉 了 。 < / p >
< h3 id = "paused" > Paused< / h3 >
< p > < code > .spec.paused< / code > 是 可 以 可 选 配 置 项 , boolean 值 。 用 来 指 定 暂 停 和 恢 复 Deployment。 Paused 和 没 有 paused 的 Deployment 之 间 的 唯 一 区 别 就 是 , 所 有 对 paused deployment 中 的 PodTemplateSpec 的 修 改 都 不 会 触 发 新 的 rollout。 Deployment 被 创 建 之 后 默 认 是 非 paused。 < / p >
< footer class = "page-footer" > < span class = "copyright" > < a href = "https://cloudnative.to/contact/" target = "_blank" > 加 入 云 原 生 社 区 · 共 谱 云 原 生 新 篇 章 < / a > < p > < / p > Copyright © 2017-2020 | Distributed under < a href = "https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" target = "_blank" > CC BY 4.0< / a > | < a href = "https://jimmysong.io" target = "_blank" > jimmysong.io< / a > all right reserved, powered by Gitbook< / span > < span class = "footer-modification" > Updated at
2020-06-24 16:47:22 +08:00
2020-06-24 08:41:43
2020-06-19 14:52:56 +08:00
< / span > < / footer >
< / section >
< / div >
< div class = "search-results" >
< div class = "has-results" >
< h1 class = "search-results-title" > < span class = 'search-results-count' > < / span > results matching "< span class = 'search-query' > < / span > "< / h1 >
< ul class = "search-results-list" > < / ul >
< / div >
< div class = "no-results" >
< h1 class = "search-results-title" > No results matching "< span class = 'search-query' > < / span > "< / h1 >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< a href = "controllers.html" class = "navigation navigation-prev " aria-label = "Previous page: 控制器" >
< i class = "fa fa-angle-left" > < / i >
< / a >
< a href = "statefulset.html" class = "navigation navigation-next " aria-label = "Next page: StatefulSet" >
< i class = "fa fa-angle-right" > < / i >
< / a >
< / div >
< script >
var gitbook = gitbook || [];
gitbook.push(function() {
2020-06-24 16:47:22 +08:00
gitbook.page.hasChanged({"page":{"title":"Deployment","level":"3.6.1","depth":2,"next":{"title":"StatefulSet","level":"3.6.2","depth":2,"path":"concepts/statefulset.md","ref":"concepts/statefulset.md","articles":[]},"previous":{"title":"控制器","level":"3.6","depth":1,"path":"concepts/controllers.md","ref":"concepts/controllers.md","articles":[{"title":"Deployment","level":"3.6.1","depth":2,"path":"concepts/deployment.md","ref":"concepts/deployment.md","articles":[]},{"title":"StatefulSet","level":"3.6.2","depth":2,"path":"concepts/statefulset.md","ref":"concepts/statefulset.md","articles":[]},{"title":"DaemonSet","level":"3.6.3","depth":2,"path":"concepts/daemonset.md","ref":"concepts/daemonset.md","articles":[]},{"title":"ReplicationController 和 ReplicaSet","level":"3.6.4","depth":2,"path":"concepts/replicaset.md","ref":"concepts/replicaset.md","articles":[]},{"title":"Job","level":"3.6.5","depth":2,"path":"concepts/job.md","ref":"concepts/job.md","articles":[]},{"title":"CronJob","level":"3.6.6","depth":2,"path":"concepts/cronjob.md","ref":"concepts/cronjob.md","articles":[]},{"title":"Horizontal Pod Autoscaling","level":"3.6.7","depth":2,"path":"concepts/horizontal-pod-autoscaling.md","ref":"concepts/horizontal-pod-autoscaling.md","articles":[{"title":"自定义指标 HPA","level":"3.6.7.1","depth":3,"path":"concepts/custom-metrics-hpa.md","ref":"concepts/custom-metrics-hpa.md","articles":[]}]},{"title":"准入控制器( Admission Controller) ","level":"3.6.8","depth":2,"path":"concepts/admission-controller.md","ref":"concepts/admission-controller.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["github","codesnippet","splitter","page-toc-button","image-captions","editlink","back-to-top-button","-lunr","-search","search-plus","github-buttons@2.1.0","favicon@^0.0.2","tbfed-pagefooter@^0.0.1","3-ba","theme-default","-highlight","prism","prism-themes","sitemap-general","lightbox","ga","copy-code-button","alerts"],"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"< a href = https://cloudnative.to/contact/ > 加入云原生社区·共谱云原生新篇章< / a > < / p > Copyright © 2017-2020 | Distributed under < a href = https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh > CC BY 4.0< / a > | < a href = https://jimmysong.io > jimmysong.io< / a > ","modify_label":" Updated at ","modify_format":"YYYY-MM-DD HH:mm:ss"},"prism":{"css":["prism-themes/themes/prism-ghcolors.css"]},"github":{"url":"https://github.com/rootsongjc/kubernetes-handbook"},"editlink":{"label":"编辑本页","multilingual":false,"base":"https://github.com/rootsongjc/kubernetes-handbook/blob/master/"},"splitter":{},"codesnippet":{},"sitemap-general":{"prefix":"https://jimmysong.io/kubernetes-handbook/"},"fontsettings":{"theme":"white","family":"sans","size":2},"favicon":{"shortcut":"favicon.ico","bookmark":"favicon.ico"},"lightbox":{"jquery":true,"sameUuid":false},"page-toc-button":{},"back-to-top-button":{},"prism-themes":{},"alerts":{},"github-buttons":{"repo":"rootsongjc/kubernetes-handbook","types":["star"],"size":"small"},"3-ba":{"configuration":"auto","token":"11f7d254cfa4e0ca44b175c66d379ecc"},"copy-code-button":{},"ga":{"configuration":"auto","token":"UA-93485976-1"},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"showLevel":true,"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}},"search-plus":{},"image-captions":{"caption":"图 _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_: _CAPTION_","variable_name":"_pictures"}},"theme":"default","author":"Jimmy Song( 宋净超) ","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}
2020-06-19 14:52:56 +08:00
});
< / script >
< / div >
< script src = "../gitbook/gitbook.js" > < / script >
< script src = "../gitbook/theme.js" > < / script >
< script src = "../gitbook/gitbook-plugin-github/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-splitter/splitter.js" > < / script >
< script src = "../gitbook/gitbook-plugin-page-toc-button/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-editlink/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-back-to-top-button/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js" > < / script >
< script src = "../gitbook/gitbook-plugin-search-plus/search.js" > < / script >
< script src = "../gitbook/gitbook-plugin-github-buttons/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-3-ba/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-lightbox/js/lightbox.min.js" > < / script >
< script src = "../gitbook/gitbook-plugin-ga/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-copy-code-button/toggle.js" > < / script >
< script src = "../gitbook/gitbook-plugin-alerts/plugin.js" > < / script >
< script src = "../gitbook/gitbook-plugin-sharing/buttons.js" > < / script >
< script src = "../gitbook/gitbook-plugin-fontsettings/fontsettings.js" > < / script >
< / body >
< / html >