前言 .........................................................................................................................................1
第1章 概述 ...............................................................................................................................7
速度 ...........................................................................................................................................8
不變性的價值 ..................................................................................................................9
聲明式配置 .....................................................................................................................10
自我修復(fù)系統(tǒng) .................................................................................................................11
擴展服務(wù)和團隊 .....................................................................................................................12
解耦 ..................................................................................................................................12
更易于擴展的應(yīng)用程序和集群 ..................................................................................12
利用微服務(wù)擴展開發(fā)團隊 ...........................................................................................13
一致性和可擴展性的隔離 ...........................................................................................14
抽象基礎(chǔ)設(shè)施 ..........................................................................................................................16
效率 ..........................................................................................................................................17
小結(jié) ..........................................................................................................................................18
第2章 創(chuàng)建和運行容器 ......................................................19
容器鏡像 ..................................................................................................................................20
Docker鏡像格式 ............................................................................................................21
使用Docker構(gòu)建應(yīng)用程序鏡像...........................................................................................23
Dockerfile........................................................................................................................23
鏡像的安全性 .................................................................................................................24
優(yōu)化鏡像大小 .................................................................................................................24
將鏡像存儲到遠程倉儲 ........................................................................................................25
Docker容器運行時 .................................................................................................................26
通過Docker運行容器 ....................................................................................................27
探索kuard應(yīng)用程序 ......................................................................................................27
限制資源使用 .................................................................................................................27
刪除鏡像 ..................................................................................................................................28
小結(jié) ..........................................................................................................................................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
檢查群集狀態(tài) .................................................................................................................34
查看KubernetesWorker節(jié)點 ......................................................................................35
群集組件 ..................................................................................................................................38
Kubernetes代理 .............................................................................................................38
KubernetesDNS.............................................................................................................38
KubernetesUI .................................................................................................................39
小結(jié) .........................................................................................................................................40
第4章 常用kubectl命令 ....................................................41
命名空間 ..................................................................................................................................41
上下文 ......................................................................................................................................41
查看KubernetesAPI對象.....................................................................................................42
創(chuàng)建、更新和銷毀Kubernetes對象...................................................................................43
標記和注釋對象 ....................................................................................................................44
調(diào)試命令 ..................................................................................................................................44
小結(jié) ..........................................................................................................................................45
第5章 pod ........................................................................46
Kubernetes中的pod..............................................................................................................47
用pod思考 ...............................................................................................................................48
podManifest...........................................................................................................................48
創(chuàng)建pod...........................................................................................................................49
創(chuàng)建podManifest..........................................................................................................50
運行pod...................................................................................................................................51
列出pod ...........................................................................................................................51
pod的詳細信息 .............................................................................................................52
刪除pod ...........................................................................................................................53
訪問pod..................................................................................................................................54
使用端口轉(zhuǎn)發(fā) .................................................................................................................54
使用日志獲取更多信息 ...............................................................................................55
利用exec執(zhí)行容器中的命令.......................................................................................55
在容器間復(fù)制文件 ........................................................................................................56
健康檢查 ..................................................................................................................................56
活性探針 .........................................................................................................................57
就緒探針 ..........................................................................................................................58
健康檢查的類型 .............................................................................................................59
資源管理 ..................................................................................................................................59
資源請求:所需資源下限 ...........................................................................................60
通過限額控制資源用量 ...............................................................................................62
利用卷實現(xiàn)數(shù)據(jù)持久化 ........................................................................................................63
通過pod使用存儲卷 .....................................................................................................63
pod使用卷的不同方式.................................................................................................64
使用遠程磁盤實現(xiàn)數(shù)據(jù)的持久性 ..............................................................................65
綜合討論 ..................................................................................................................................66
小結(jié) ..........................................................................................................................................67
第6章 標簽和注釋 ............................................................68
標簽 ..........................................................................................................................................68
應(yīng)用標簽 ..........................................................................................................................70
修改標簽 .........................................................................................................................71
標簽選擇器 .....................................................................................................................72
API對象中的標簽選擇器..............................................................................................74
注釋 ..........................................................................................................................................75
定義注釋 ..........................................................................................................................76
清理 ..........................................................................................................................................76
小結(jié) ..........................................................................................................................................77
第7章 服務(wù)發(fā)現(xiàn) ...............................................................78
什么是服務(wù)發(fā)現(xiàn)? .................................................................................................................78
Service對象 .............................................................................................................................79
提供DNS服務(wù) ..................................................................................................................80
就緒檢查 ..........................................................................................................................82
集群之外 ..................................................................................................................................83
云集成 ......................................................................................................................................85
高級細節(jié) .................................................................................................................................86
端點 ..................................................................................................................................86
手動服務(wù)發(fā)現(xiàn) .................................................................................................................88
kube-proxy與集群IP.....................................................................................................89
群集IP環(huán)境變量..............................................................................................................90
清除對象 ..................................................................................................................................91
小結(jié) ..........................................................................................................................................91
第8章 ReplicaSet.............................................................92
調(diào)和循環(huán) ..................................................................................................................................93
將pod和ReplicaSet關(guān)聯(lián)起來 ..............................................................................................94
采用現(xiàn)有容器 .................................................................................................................94
隔離容器 ..........................................................................................................................94
使用ReplicaSet進行設(shè)計 ......................................................................................................95
ReplicaSet的規(guī)范 ...................................................................................................................95
pod模板 ..........................................................................................................................96
標簽 ..................................................................................................................................96
創(chuàng)建ReplicaSet........................................................................................................................97
監(jiān)查ReplicaSet........................................................................................................................97
從pod中查找ReplicaSet...............................................................................................98
查找ReplicaSet的pod集...............................................................................................98
擴展ReplicaSet........................................................................................................................99
使用kubectlScale進行命令式縮放 ...........................................................................99
使用kubectlapply進行聲明式縮放 .......................................................................100
自動調(diào)整ReplicaSet...................................................................................................101
刪除ReplicaSet.....................................................................................................................102
小結(jié) .......................................................................................................................................103
第9章 DaemonSet ..........................................................104
DaemonSet調(diào)度器 .............................................................................................................105
創(chuàng)建DaemonSet..................................................................................................................105
將DaemonSet限制為特定節(jié)點 ........................................................................................108
為節(jié)點添加標簽 ..........................................................................................................108
節(jié)點選擇器 ..................................................................................................................109
更新DaemonSet..................................................................................................................110
通過刪除單個pod來更新DaemonSet................................................................... 110
滾動更新DaemonSet.................................................................................................111
刪除DaemonSet..................................................................................................................112
小結(jié) .......................................................................................................................................112
第10章 作業(yè) ...................................................................113
Job對象 .................................................................................................................................113
作業(yè)模式 ...............................................................................................................................114
一次性作業(yè) ..................................................................................................................114
并行性 ...........................................................................................................................120
工作隊列 .......................................................................................................................122
小結(jié) .......................................................................................................................................126
第11章 ConfigMap與Secret........................................... 127
ConfigMap............................................................................................................................127
創(chuàng)建ConfigMap...........................................................................................................128
ConfigMap的用法 ......................................................................................................129
Secret....................................................................................................................................132
創(chuàng)建Secret....................................................................................................................133
消費secret ....................................................................................................................134
私有Docker倉庫 .........................................................................................................136
命名約束 ...............................................................................................................................137
管理ConfigMap和Secret...................................................................................................137
顯示 ...............................................................................................................................138
創(chuàng)建 ...............................................................................................................................138
更新 ...............................................................................................................................139
小結(jié) .......................................................................................................................................141
第12章 Deployment .......................................................142
我們的第一個Deployment對象 ......................................................................................143
Deployment對象的運行機制 ..................................................................................143
創(chuàng)建Deployment對象 ........................................................................................................145
管理Deployment對象 ........................................................................................................146
更新Deployment對象 ........................................................................................................147
Deployment對象的縮放 ...........................................................................................148
更新容器鏡像 ..............................................................................................................148
更新的歷史記錄 ..........................................................................................................150
部署策略 ...............................................................................................................................153
Recreate策略 ...............................................................................................................153
RollingUpdate策略.....................................................................................................153
降低更新速度以確保服務(wù)的健康 ...........................................................................157
刪除Deployment.................................................................................................................159
小結(jié) .......................................................................................................................................159
第13章 為Kubernetes集成存儲解決方案 .........................160
導(dǎo)入外部服務(wù) .......................................................................................................................161
沒有選擇器的服務(wù) ....................................................................................................163
外部服務(wù)的局限性:健康檢查 ...............................................................................165
運行可靠的單例 ..................................................................................................................165
運行MySQL單例 ..........................................................................................................165
動態(tài)卷配置 ..................................................................................................................169
帶有StatefulSet的Kubernetes-Native存儲 ..................................................................170
StatefulSet的特性 .......................................................................................................171
使用StatefulSet手動部署備份式MongoDB .........................................................171
自動創(chuàng)建MongoDB群集 ...........................................................................................174
持久卷和有狀態(tài)集 .....................................................................................................177
最后一件事:準備就緒探針 ....................................................................................178
小結(jié) .......................................................................................................................................179
第14章 部署實際應(yīng)用程序............................................... 180
Parse ......................................................................................................................................180
先決條件 .......................................................................................................................181
構(gòu)建parse-server........................................................................................................181
部署parse-server........................................................................................................182
測試Parse......................................................................................................................183
Ghost.....................................................................................................................................183
配置Ghost.....................................................................................................................183
Redis......................................................................................................................................187
配置Redis......................................................................................................................188
創(chuàng)建Redis服務(wù) .............................................................................................................190
部署Redis......................................................................................................................190
測試Redis群集 .............................................................................................................192
小結(jié) .......................................................................................................................................193
附錄A 利用Raspberry Pi搭建Kubernetes群集 ......................................................................195
作者主要從事數(shù)據(jù)中心網(wǎng)絡(luò)解決方案的研發(fā)與部署,技術(shù)方向包括云計算、軟件定義網(wǎng)絡(luò)(SDN)、網(wǎng)絡(luò)安全等,是國內(nèi)較早從事 SDN 和網(wǎng)絡(luò)虛擬化相關(guān)技術(shù)的推廣者,同時也是 Docke開源社區(qū)的發(fā)起人之一。
本書作者一直在Google和其他公司從事Kubernetes方面的工作,為我們解釋了該系統(tǒng)如何融入分布式應(yīng)用程序的生命周期之中的。你將學(xué)習(xí)如何使用各種工具和API來實現(xiàn)可擴展分布式系統(tǒng)管理的自動化,無論該系統(tǒng)用于在線服務(wù)、機器學(xué)習(xí)應(yīng)用程序,還是Raspberry Pi計算機群集。本書的主要內(nèi)容有:探索Kubernetes所面臨的分布式系統(tǒng)挑戰(zhàn)。使用Docker等容器進行容器化應(yīng)用開發(fā)。使用docker鏡像格式和容器運行時在Kubernetes上創(chuàng)建和運行容器。探索在生產(chǎn)中運行應(yīng)用程序所必需的專門對象。在無需停機或無差錯情況下可靠地推出新的軟件版本。舉例說明如何在Kubernetes中開發(fā)和部署真實應(yīng)用程序。