mirror of
https://github.com/cheetahlou/CategoryResourceRepost.git
synced 2025-10-20 17:03:47 +08:00
231 lines
15 KiB
Markdown
231 lines
15 KiB
Markdown
<audio id="audio" title="85 | 程序员练级攻略:容器化和自动化运维" controls="" preload="none"><source id="mp3" src="https://static001.geekbang.org/resource/audio/a9/f2/a915e847909a38033be1a3251713cef2.mp3"></audio>
|
||
|
||
这篇文章我们来重点学习 Docker 和 Kubernetes,它们已经是分布式架构和自动化运维的必备工具了。对于这两个东西,你千万不要害怕,因为技术方面都不算复杂,只是它们的玩法和传统运维不一样,所以你不用担心,只要你花上一点时间,一定可以学好的。
|
||
|
||
# Docker
|
||
|
||
<li>
|
||
你可以先看一下Docker的官方介绍 [Docker Overview](https://docs.docker.com/engine/docker-overview/) 。
|
||
</li>
|
||
<li>
|
||
然后再去一个Web在线的Playground上体验一下, [Katacoda Docker Playground](https://www.katacoda.com/courses/docker/playground) 或者是 [Play With Docker](https://training.play-with-docker.com/) 。
|
||
</li>
|
||
<li>
|
||
接下来,跟着 [Learn Docker](https://github.com/dwyl/learn-docker) 这个文档中的教程自己安装一个Docker的环境,实操一把。
|
||
</li>
|
||
<li>
|
||
然后跟着 [Docker Curriculum](https://docker-curriculum.com/) 这个超详细的教程玩一下Docker。
|
||
</li>
|
||
|
||
有了上述的一些感性体会之后,你就可以阅读Docker官方文档 [Docker Documentation](https://docs.docker.com/) 了,这是学习Docker最好的方式。
|
||
|
||
如果你想了解一下Docker的底层技术细节,你可以参看我的文章。
|
||
|
||
- [Docker 基础技术:Linux Namespace(上)](https://coolshell.cn/articles/17010.html)
|
||
- [Docker 基础技术:Linux Namespace(下)](https://coolshell.cn/articles/17029.html)
|
||
- [Docker 基础技术:Cgroup](https://coolshell.cn/articles/17049.html)
|
||
- [Docker 基础技术:AUFS](https://coolshell.cn/articles/17061.html)
|
||
- [Docker 基础技术:DeviceMapper](https://coolshell.cn/articles/17200.html)
|
||
|
||
还有一些不错的与Docker网络有关的文章你需要阅读及实践一下。
|
||
|
||
- [A container networking overview](https://jvns.ca/blog/2016/12/22/container-networking/)
|
||
- [Docker networking 101 - User defined networks](http://www.dasblinkenlichten.com/docker-networking-101-user-defined-networks/)
|
||
- [Understanding CNI (Container Networking Interface)](http://www.dasblinkenlichten.com/understanding-cni-container-networking-interface/)
|
||
- [Using CNI with Docker](http://www.dasblinkenlichten.com/using-cni-docker/)
|
||
|
||
Docker有下面几种网络解决方案:[Calico](https://www.projectcalico.org/getting-started/docker/) 、[Flannel](https://github.com/coreos/flannel/) 和 [Weave](https://github.com/weaveworks/weave) ,你需要学习一下。另外,还需要学习一下 [netshoot](https://github.com/nicolaka/netshoot) ,这是一个很不错的用来诊断Docker网络问题的工具集。
|
||
|
||
关于这几个容器网络解决方案的性能对比,你可以看一下下面这几篇文章或报告。
|
||
|
||
<li>
|
||
[Battlefield: Calico, Flannel, Weave and Docker Overlay Network](http://chunqi.li/2015/11/15/Battlefield-Calico-Flannel-Weave-and-Docker-Overlay-Network/)
|
||
</li>
|
||
<li>
|
||
[Comparison of Networking Solutions for Kubernetes](http://machinezone.github.io/research/networking-solutions-for-kubernetes/)
|
||
</li>
|
||
<li>
|
||
[Docker Overlay Networks: Performance analysis in high-latency enviroments](http://www.delaat.net/rp/2015-2016/p50/report.pdf)
|
||
</li>
|
||
|
||
如果你对Docker的性能有什么问题的话,你可以看一下下面这些文章。
|
||
|
||
<li>
|
||
[IBM Research Report: An Updated Performance Comparison of Virtual Machines and Linux Containers](https://domino.research.ibm.com/library/cyberdig.nsf/papers/0929052195DD819C85257D2300681E7B/$File/rc25482.pdf)
|
||
</li>
|
||
<li>
|
||
[An Introduction to Docker and Analysis of its Performance](http://paper.ijcsns.org/07_book/201703/20170327.pdf)
|
||
</li>
|
||
|
||
下面是一些和存储相关的文章。
|
||
|
||
<li>
|
||
[Storage Concepts in Docker: Network and Cloud Storage](http://cloud-mechanic.blogspot.de/2014/10/storage-concepts-in-docker-network-and.html)
|
||
</li>
|
||
<li>
|
||
[Storage Concepts in Docker: Persistent Storage](http://cloud-mechanic.blogspot.de/2014/10/storage-concepts-in-docker-persistent.html)
|
||
</li>
|
||
<li>
|
||
[Storage Concepts in Docker: Shared Storage and the VOLUME directive](http://cloud-mechanic.blogspot.de/2014/10/storage-concepts-in-docker.html)
|
||
</li>
|
||
|
||
然后是跟运维相关的文章。
|
||
|
||
- [Docker Monitoring with the ELK Stack: A Step-by-Step Guide](https://logz.io/learn/docker-monitoring-elk-stack/)
|
||
|
||
最后,推荐看看 [Valuable Docker Links](http://www.nkode.io/2014/08/24/valuable-docker-links.html) ,其中收集并罗列了一系列非常不错的 Docker 文章。
|
||
|
||
**最佳实践**
|
||
|
||
下面分享一些与Docker相关的最佳实践。
|
||
|
||
<li>
|
||
[Best Practices for Dockerfile](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) ,Docker官方文档里的Dockerfile的最佳实践。
|
||
</li>
|
||
<li>
|
||
[Docker Best Practices](https://github.com/FuriKuri/docker-best-practices) ,这里收集汇总了存在于各个地方的使用Docker的建议和实践。
|
||
</li>
|
||
<li>
|
||
[Container Best Practices](http://docs.projectatomic.io/container-best-practices/) ,来自Atomic项目,是一个介绍容器化应用程序的架构、创建和管理的协作型文档项目。
|
||
</li>
|
||
<li>
|
||
[Eight Docker Development Patterns](http://hokstad.com/docker/patterns) ,八个Docker的开发模式:共享基础容器、共享同一个卷的多个开发容器、开发工具专用容器、测试环境容器、编译构建容器、防手误的安装容器、默认服务容器、胶黏容器(如英文链接不能访问,可阅读[中文版本](https://www.infoq.cn/article/2014/10/seven-docker-develop-pattern))。
|
||
</li>
|
||
|
||
# Kubernetes
|
||
|
||
Kubernetes 是Google开源的容器集群管理系统,是Google多年大规模容器管理技术Borg的开源版本,也是CNCF最重要的项目之一,主要功能包括:
|
||
|
||
- 基于容器的应用部署、维护和滚动升级;
|
||
- 负载均衡和服务发现;
|
||
- 跨机器和跨地区的集群调度;
|
||
- 自动伸缩;
|
||
- 无状态服务和有状态服务;
|
||
- 广泛的Volume支持;
|
||
- 插件机制保证扩展性。
|
||
|
||
Kubernetes发展非常迅速,已经成为容器编排领域的领导者。
|
||
|
||
首先,我推荐你阅读Kubernetes前世今生的一篇论文。
|
||
|
||
- [Borg, Omega, and Kubernetes](https://static.googleusercontent.com/media/research.google.com/zh-CN//pubs/archive/44843.pdf) ,看看Google这十几年来从这三个容器管理系统中得到的经验教训。
|
||
|
||
学习Kubernetes,有两个免费的开源电子书。
|
||
|
||
<li>
|
||
《[Kubernetes Handbook](https://jimmysong.io/kubernetes-handbook/)》,这本书记录了作者从零开始学习和使用Kubernetes的心路历程,着重于经验分享和总结,同时也会有相关的概念解析。希望能够帮助你少踩坑,少走弯路,还会指引你关注kubernetes生态周边,如微服务构建、DevOps、大数据应用、Service Mesh、Cloud Native等领域。
|
||
</li>
|
||
<li>
|
||
《[Kubernetes指南](https://kubernetes.feisky.xyz/zh/)》,这本书旨在整理平时在开发和使用Kubernetes时的参考指南和实践总结,形成一个系统化的参考指南以方便查阅。
|
||
</li>
|
||
|
||
这两本电子书都不错,前者更像是一本学习教程,而且面明显广一些,还包括Cloud Natvie、Service Mesh以及微服务相关的东西。而后者聚焦于Kubernetes本身,更像一本参考书。
|
||
|
||
**另外,我这两天也读完了《Kubernetes in Action》一书,感觉写的非常好,一本很完美的教科书,抽丝剥茧,图文并茂。如果你只想读一本有关Kubernetes的书来学习Kubernetes,那么我推荐你就选这本。**
|
||
|
||
但是也别忘了Kubernetes的官方网站:[Kubernetes.io](https://kubernetes.io/),上面不但有[全面的文档](https://kubernetes.io/docs/home/) ,也包括一个很不错的 [官方教程](https://kubernetes.io/docs/tutorials/kubernetes-basics/) 。
|
||
|
||
此外,还有一些交互式教程,帮助你理解掌握,以及一些很不错的文章推荐你阅读。
|
||
|
||
**一些交互式教程**
|
||
|
||
- [Katacoda](https://www.katacoda.com/courses/kubernetes)
|
||
- [Kubernetes Bootcamp](https://kubernetesbootcamp.github.io/kubernetes-bootcamp/)
|
||
|
||
**一些文章**
|
||
|
||
这里还有一些不错的文档,你应该去读一下。
|
||
|
||
- [Kubernetes tips & tricks](https://opsnotice.xyz/kubernetes-tips-tricks/)
|
||
- [Achieving CI/CD with Kubernetes](http://theremotelab.com/blog/achieving-ci-cd-with-k8s/)
|
||
- [How to Set Up Scalable Jenkins on Top of a Kubernetes Cluster](https://dzone.com/articles/how-to-setup-scalable-jenkins-on-top-of-a-kubernet)
|
||
- 10 Most Common Reasons Kubernetes Deployments Fail [Part I](https://kukulinski.com/10-most-common-reasons-kubernetes-deployments-fail-part-1/) 和 [Part II](https://kukulinski.com/10-most-common-reasons-kubernetes-deployments-fail-part-2/)
|
||
- [How to Monitor Kubernetes](http://sysdig.com/blog/monitoring-kubernetes-with-sysdig-cloud/) ,一共有4个篇章
|
||
- [Logging in Kubernetes with Fluentd and Elasticsearch](http://www.dasblinkenlichten.com/logging-in-kubernetes-with-fluentd-and-elasticsearch/)
|
||
- [Kubernetes Monitoring: Best Practices, Methods, and Existing Solutions](https://dzone.com/articles/kubernetes-monitoring-best-practices-methods-and-e)
|
||
|
||
**网络相关的文章**
|
||
|
||
要学习Kubernetes,你只需要读一下,下面这个Kubernetes 101系列的文章。
|
||
|
||
- [Kubernetes 101 - Networking](http://www.dasblinkenlichten.com/kubernetes-101-networking/)
|
||
- [Kubernetes networking 101 - Pods](http://www.dasblinkenlichten.com/kubernetes-networking-101-pods/)
|
||
- [Kubernetes networking 101 - Services](http://www.dasblinkenlichten.com/kubernetes-networking-101-services/)
|
||
- [Kubernetes networking 101 - (Basic) External access into the cluster](http://www.dasblinkenlichten.com/kubernetes-networking-101-basic-external-access-into-the-cluster/)
|
||
- [Kubernetes Networking 101 - Ingress resources](http://www.dasblinkenlichten.com/kubernetes-networking-101-ingress-resources/)
|
||
- [Getting started with Calico on Kubernetes](http://www.dasblinkenlichten.com/getting-started-with-calico-on-kubernetes/)
|
||
|
||
**CI/CD相关的文章**
|
||
|
||
- [Automated Image Builds with Jenkins, Packer, and Kubernetes](https://cloud.google.com/solutions/automated-build-images-with-jenkins-kubernetes#kubernetes_architecture)
|
||
- [Jenkins setups for Kubernetes and Docker Workflow](http://iocanel.blogspot.in/2015/09/jenkins-setups-for-kubernetes-and.html)
|
||
- [Lab: Build a Continuous Deployment Pipeline with Jenkins and Kubernetes](https://github.com/GoogleCloudPlatform/continuous-deployment-on-kubernetes)
|
||
|
||
**最佳实践**
|
||
|
||
- [Kubernetes Best Practices](https://medium.com/@sachin.arote1/kubernetes-best-practices-9b1435a4cb53) by [Sachin Arote](https://medium.com/@sachin.arote1?source=post_header_lockup) ,AWS工程师总结的最佳实践。
|
||
- [Kubernetes Best Practices](https://speakerdeck.com/thesandlord/kubernetes-best-practices) by [Sandeep Dinesh](https://github.com/thesandlord) ,Google云平台工程师总结的最佳实践。
|
||
|
||
**Docker和Kubernetes资源汇总**
|
||
|
||
下面是 GitHub 上和 Docker & Kubernetes相关的Awesome系列。
|
||
|
||
- [Awesome Docker](https://github.com/veggiemonk/awesome-docker)。
|
||
- [Awesome Kubernetes](https://github.com/ramitsurana/awesome-kubernetes)。
|
||
|
||
虽然上面的这些系列非常全的罗列了很多资源,但是我觉得很不系统。对于系统的说明Docker和Kubernetes生态圈,我非常推荐大家看一下 The New Stack 为Kubernetes出的一系列的电子书或报告。
|
||
|
||
<li>
|
||
[The New Stack eBook Series](http://thenewstack.io/ebookseries/) ,非常完整和详实的 Docker 和 Kubernetes 生态圈的所有东西。
|
||
<ul>
|
||
- Book 01: [The Docker Container Ecosystem](https://thenewstack.io/ebooks/docker-and-containers/the-docker-container-ecosystem/)
|
||
- Book 02: [Applications & Microservices with Docker & Containers](https://thenewstack.io/ebooks/docker-and-containers/applications-microservices-docker-containers/)
|
||
- Book 03: [Automation & Orchestration with Docker & Containers](https://thenewstack.io/ebooks/docker-and-containers/automation-orchestration-docker-containers/)
|
||
- Book 04: [Network, Security & Storage with Docker & Containers](https://thenewstack.io/ebooks/docker-and-containers/networking-security-storage-docker-containers/)
|
||
- Book 05: [Monitoring & Management with Docker & Containers](https://thenewstack.io/ebooks/docker-and-containers/monitoring-management-docker-containers/)
|
||
- Book 06: [Use Cases for Kubernetes](https://thenewstack.io/ebooks/use-cases/use-cases-for-kubernetes/)
|
||
- Book 07: [State of the Kubernetes Ecosystem](https://thenewstack.io/ebooks/kubernetes/state-of-kubernetes-ecosystem/)
|
||
- Book 08: [Kubernetes Deployment & Security Patterns](https://thenewstack.io/ebooks/kubernetes/kubernetes-deployment-and-security-patterns/)
|
||
- Book 09: [CI/CD with Kubernetes](https://thenewstack.io/ebooks/kubernetes/ci-cd-with-kubernetes/)
|
||
- Book 10: [Kubernetes solutions Directory](https://thenewstack.io/ebooks/kubernetes/kubernetes-solutions-directory/)
|
||
- Book 11: [Guid to Cloud-Native Microservices](https://thenewstack.io/ebooks/microservices/cloud-native-microservices-2018/)
|
||
|
||
# 小结
|
||
|
||
总结一下今天的内容。Docker 和 Kubernetes已经成为分布式架构和自动化运维方面的不可或缺的两大基本构成,是你必需要学习的。虽然它们的玩法跟传统运维不一样,但技术方面并不算复杂,只要你花上一点时间,一定会学好的。
|
||
|
||
在这篇文章中,我推荐了Docker和Kubernetes基础技术方面的学习资料,并给出了存储、运维、网络、CI/CD等多方面的资料,同时列出了与之相关的最佳实践。相信认真学习和消化这些知识,你一定可以掌握Docker和Kubernetes两大利器。
|
||
|
||
下篇文章,我们将学习机器学习和人工智能方面的内容。敬请期待。
|
||
|
||
下面是《程序员练级攻略》系列文章的目录。
|
||
|
||
- [开篇词](https://time.geekbang.org/column/article/8136)
|
||
<li>入门篇
|
||
<ul>
|
||
- [零基础启蒙](https://time.geekbang.org/column/article/8216)
|
||
- [正式入门](https://time.geekbang.org/column/article/8217)
|
||
|
||
- [程序员修养](https://time.geekbang.org/column/article/8700)
|
||
|
||
- [编程语言](https://time.geekbang.org/column/article/8701)
|
||
- [理论学科](https://time.geekbang.org/column/article/8887)
|
||
- [系统知识](https://time.geekbang.org/column/article/8888)
|
||
|
||
- [软件设计](https://time.geekbang.org/column/article/9369)
|
||
|
||
- [Linux系统、内存和网络(系统底层知识)](https://time.geekbang.org/column/article/9759)
|
||
- [异步I/O模型和Lock-Free编程(系统底层知识)](https://time.geekbang.org/column/article/9851)
|
||
- [Java底层知识](https://time.geekbang.org/column/article/10216)
|
||
- [数据库](https://time.geekbang.org/column/article/10301)
|
||
- [分布式架构入门(分布式架构)](https://time.geekbang.org/column/article/10603)
|
||
- [分布式架构经典图书和论文(分布式架构)](https://time.geekbang.org/column/article/10604)
|
||
- [分布式架构工程设计(分布式架构)](https://time.geekbang.org/column/article/11232)
|
||
- [微服务](https://time.geekbang.org/column/article/11116)
|
||
- [容器化和自动化运维](https://time.geekbang.org/column/article/11665)
|
||
- [机器学习和人工智能](https://time.geekbang.org/column/article/11669)
|
||
- [前端基础和底层原理(前端方向)](https://time.geekbang.org/column/article/12271)
|
||
- [前端性能优化和框架(前端方向)](https://time.geekbang.org/column/article/12389)
|
||
- [UI/UX设计(前端方向)](https://time.geekbang.org/column/article/12486)
|
||
- [技术资源集散地](https://time.geekbang.org/column/article/12561)
|