前言 .........................................................................................................................................1
第1章 概述 ...............................................................................................................................7
速度 ...........................................................................................................................................8
不变性的价值 ..................................................................................................................9
声明式配置 .....................................................................................................................10
自我修复系统 .................................................................................................................11
扩展服务和团队 .....................................................................................................................12
解耦 ..................................................................................................................................12
更易于扩展的应用程序和集群 ..................................................................................12
利用微服务扩展开发团队 ...........................................................................................13
一致性和可扩展性的隔离 ...........................................................................................14
抽象基础设施 ..........................................................................................................................16
效率 ..........................................................................................................................................17
小结 ..........................................................................................................................................18
第2章 创建和运行容器 ......................................................19
容器镜像 ..................................................................................................................................20
Docker镜像格式 ............................................................................................................21
使用Docker构建应用程序镜像...........................................................................................23
Dockerfile........................................................................................................................23
镜像的安全性 .................................................................................................................24
优化镜像大小 .................................................................................................................24
将镜像存储到远程仓储 ........................................................................................................25
Docker容器运行时 .................................................................................................................26
通过Docker运行容器 ....................................................................................................27
探索kuard应用程序 ......................................................................................................27
限制资源使用 .................................................................................................................27
删除镜像 ..................................................................................................................................28
小结 ..........................................................................................................................................29
第3章 部署Kubernetes群集 .............................................30
在公共云上安装Kubernetes...............................................................................................31
GoogleContainer Service ...........................................................................................31
使用AzureContainer Service安装Kubernetes......................................................31
在Amazon WebServices上安装Kubernetes...........................................................32
使用minikube在本地安装Kubernetes.............................................................................33
在Raspberry Pi上运行Kubernetes....................................................................................34
Kubernetes客户端 .................................................................................................................34
检查群集状态 .................................................................................................................34
查看KubernetesWorker节点 ......................................................................................35
群集组件 ..................................................................................................................................38
Kubernetes代理 .............................................................................................................38
KubernetesDNS.............................................................................................................38
KubernetesUI .................................................................................................................39
小结 .........................................................................................................................................40
第4章 常用kubectl命令 ....................................................41
命名空间 ..................................................................................................................................41
上下文 ......................................................................................................................................41
查看KubernetesAPI对象.....................................................................................................42
创建、更新和销毁Kubernetes对象...................................................................................43
标记和注释对象 ....................................................................................................................44
调试命令 ..................................................................................................................................44
小结 ..........................................................................................................................................45
第5章 pod ........................................................................46
Kubernetes中的pod..............................................................................................................47
用pod思考 ...............................................................................................................................48
podManifest...........................................................................................................................48
创建pod...........................................................................................................................49
创建podManifest..........................................................................................................50
运行pod...................................................................................................................................51
列出pod ...........................................................................................................................51
pod的详细信息 .............................................................................................................52
删除pod ...........................................................................................................................53
访问pod..................................................................................................................................54
使用端口转发 .................................................................................................................54
使用日志获取更多信息 ...............................................................................................55
利用exec执行容器中的命令.......................................................................................55
在容器间复制文件 ........................................................................................................56
健康检查 ..................................................................................................................................56
活性探针 .........................................................................................................................57
就绪探针 ..........................................................................................................................58
健康检查的类型 .............................................................................................................59
资源管理 ..................................................................................................................................59
资源请求:所需资源下限 ...........................................................................................60
通过限额控制资源用量 ...............................................................................................62
利用卷实现数据持久化 ........................................................................................................63
通过pod使用存储卷 .....................................................................................................63
pod使用卷的不同方式.................................................................................................64
使用远程磁盘实现数据的持久性 ..............................................................................65
综合讨论 ..................................................................................................................................66
小结 ..........................................................................................................................................67
第6章 标签和注释 ............................................................68
标签 ..........................................................................................................................................68
应用标签 ..........................................................................................................................70
修改标签 .........................................................................................................................71
标签选择器 .....................................................................................................................72
API对象中的标签选择器..............................................................................................74
注释 ..........................................................................................................................................75
定义注释 ..........................................................................................................................76
清理 ..........................................................................................................................................76
小结 ..........................................................................................................................................77
第7章 服务发现 ...............................................................78
什么是服务发现? .................................................................................................................78
Service对象 .............................................................................................................................79
提供DNS服务 ..................................................................................................................80
就绪检查 ..........................................................................................................................82
集群之外 ..................................................................................................................................83
云集成 ......................................................................................................................................85
高级细节 .................................................................................................................................86
端点 ..................................................................................................................................86
手动服务发现 .................................................................................................................88
kube-proxy与集群IP.....................................................................................................89
群集IP环境变量..............................................................................................................90
清除对象 ..................................................................................................................................91
小结 ..........................................................................................................................................91
第8章 ReplicaSet.............................................................92
调和循环 ..................................................................................................................................93
将pod和ReplicaSet关联起来 ..............................................................................................94
采用现有容器 .................................................................................................................94
隔离容器 ..........................................................................................................................94
使用ReplicaSet进行设计 ......................................................................................................95
ReplicaSet的规范 ...................................................................................................................95
pod模板 ..........................................................................................................................96
标签 ..................................................................................................................................96
创建ReplicaSet........................................................................................................................97
监查ReplicaSet........................................................................................................................97
从pod中查找ReplicaSet...............................................................................................98
查找ReplicaSet的pod集...............................................................................................98
扩展ReplicaSet........................................................................................................................99
使用kubectlScale进行命令式缩放 ...........................................................................99
使用kubectlapply进行声明式缩放 .......................................................................100
自动调整ReplicaSet...................................................................................................101
删除ReplicaSet.....................................................................................................................102
小结 .......................................................................................................................................103
第9章 DaemonSet ..........................................................104
DaemonSet调度器 .............................................................................................................105
创建DaemonSet..................................................................................................................105
将DaemonSet限制为特定节点 ........................................................................................108
为节点添加标签 ..........................................................................................................108
节点选择器 ..................................................................................................................109
更新DaemonSet..................................................................................................................110
通过删除单个pod来更新DaemonSet................................................................... 110
滚动更新DaemonSet.................................................................................................111
删除DaemonSet..................................................................................................................112
小结 .......................................................................................................................................112
第10章 作业 ...................................................................113
Job对象 .................................................................................................................................113
作业模式 ...............................................................................................................................114
一次性作业 ..................................................................................................................114
并行性 ...........................................................................................................................120
工作队列 .......................................................................................................................122
小结 .......................................................................................................................................126
第11章 ConfigMap与Secret........................................... 127
ConfigMap............................................................................................................................127
创建ConfigMap...........................................................................................................128
ConfigMap的用法 ......................................................................................................129
Secret....................................................................................................................................132
创建Secret....................................................................................................................133
消费secret ....................................................................................................................134
私有Docker仓库 .........................................................................................................136
命名约束 ...............................................................................................................................137
管理ConfigMap和Secret...................................................................................................137
显示 ...............................................................................................................................138
创建 ...............................................................................................................................138
更新 ...............................................................................................................................139
小结 .......................................................................................................................................141
第12章 Deployment .......................................................142
我们的第一个Deployment对象 ......................................................................................143
Deployment对象的运行机制 ..................................................................................143
创建Deployment对象 ........................................................................................................145
管理Deployment对象 ........................................................................................................146
更新Deployment对象 ........................................................................................................147
Deployment对象的缩放 ...........................................................................................148
更新容器镜像 ..............................................................................................................148
更新的历史记录 ..........................................................................................................150
部署策略 ...............................................................................................................................153
Recreate策略 ...............................................................................................................153
RollingUpdate策略.....................................................................................................153
降低更新速度以确保服务的健康 ...........................................................................157
删除Deployment.................................................................................................................159
小结 .......................................................................................................................................159
第13章 为Kubernetes集成存储解决方案 .........................160
导入外部服务 .......................................................................................................................161
没有选择器的服务 ....................................................................................................163
外部服务的局限性:健康检查 ...............................................................................165
运行可靠的单例 ..................................................................................................................165
运行MySQL单例 ..........................................................................................................165
动态卷配置 ..................................................................................................................169
带有StatefulSet的Kubernetes-Native存储 ..................................................................170
StatefulSet的特性 .......................................................................................................171
使用StatefulSet手动部署备份式MongoDB .........................................................171
自动创建MongoDB群集 ...........................................................................................174
持久卷和有状态集 .....................................................................................................177
最后一件事:准备就绪探针 ....................................................................................178
小结 .......................................................................................................................................179
第14章 部署实际应用程序............................................... 180
Parse ......................................................................................................................................180
先决条件 .......................................................................................................................181
构建parse-server........................................................................................................181
部署parse-server........................................................................................................182
测试Parse......................................................................................................................183
Ghost.....................................................................................................................................183
配置Ghost.....................................................................................................................183
Redis......................................................................................................................................187
配置Redis......................................................................................................................188
创建Redis服务 .............................................................................................................190
部署Redis......................................................................................................................190
测试Redis群集 .............................................................................................................192
小结 .......................................................................................................................................193
附录A 利用Raspberry Pi搭建Kubernetes群集 ......................................................................195
作者主要从事数据中心网络解决方案的研发与部署,技术方向包括云计算、软件定义网络(SDN)、网络安全等,是国内较早从事 SDN 和网络虚拟化相关技术的推广者,同时也是 Docke开源社区的发起人之一。
本书作者一直在Google和其他公司从事Kubernetes方面的工作,为我们解释了该系统如何融入分布式应用程序的生命周期之中的。你将学习如何使用各种工具和API来实现可扩展分布式系统管理的自动化,无论该系统用于在线服务、机器学习应用程序,还是Raspberry Pi计算机群集。本书的主要内容有:探索Kubernetes所面临的分布式系统挑战。使用Docker等容器进行容器化应用开发。使用docker镜像格式和容器运行时在Kubernetes上创建和运行容器。探索在生产中运行应用程序所必需的专门对象。在无需停机或无差错情况下可靠地推出新的软件版本。举例说明如何在Kubernetes中开发和部署真实应用程序。