Skip to Content
《使用 Kubernetes 实现云原生 DevOps(第二版)》
book

《使用 Kubernetes 实现云原生 DevOps(第二版)》

by Justin Domingus, John Arundel
May 2025
Intermediate to advanced
356 pages
3h 47m
Chinese
O'Reilly Media, Inc.
Content preview from 《使用 Kubernetes 实现云原生 DevOps(第二版)》

第 13 章 开发工作流程 开发工作流程

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

冲浪是一个令人惊叹的概念。你拿着一根小棍子,对大自然说:我要驾驭你!很多时候,大自然会说,不,你不行!然后把你摔到谷底。

乔琳娜-布洛克

在本章中,我们将扩展第 12 章中的讨论,将注意力转向整个应用生命周期,从本地开发到将更新部署到 Kubernetes 集群,包括数据库迁移这个棘手的话题。我们将介绍一些帮助你开发、测试和部署应用程序的工具,包括 Skaffold 和 Telepresence。我们还将介绍 Knative 和 OpenFaaS,它们是在集群上运行 "无服务器 "架构的两种选择。我们还将了解更复杂的部署,以及使用 Helm 钩子订购应用程序的推出。

开发工具

第 12 章中,我们介绍了一些帮助你编写、构建和部署 Kubernetes 资源清单的工具。就目前而言,这样做很好,但当你开发在 Kubernetes 中运行的应用程序时,你往往希望能够立即尝试并看到变化,而无需经历完整的构建-推送-部署-更新循环。

斯卡福德

Skaffold是谷歌推出的一款开源工具,旨在提供快速的本地开发工作流程。它能在本地开发过程中自动重建容器,并将这些变更部署到本地或远程集群。

您可以在存储库中的skaffold.yaml文件中定义所需的工作流程,然后运行skaffold 命令行工具启动管道。当您对本地目录中的文件进行更改时,Skaffold 会自动唤醒,根据更改内容构建一个新容器,然后自动为您部署,从而节省您往返容器的时间。

我们在demo repo中提供了一个 Skaffold 示例,展示它是如何工作的。按照操作系统的 Skaffold安装说明,将kubectl 指向本地开发 Kubernetes 集群,然后切换到hello-skaffold目录,看看它是如何工作的:

cd hello-skaffold
skaffold dev
Listing files to watch...
 - skaffold-demo
Generating tags...
 - skaffold-demo -> skaffold-demo:e50c9e7-dirty
Checking cache...
 - skaffold-demo: Found Locally
Tags used in deployment:
 - skaffold-demo -> skaffold-demo:39f0eb63b0ced173...
Starting deploy...
Helm release demo not installed. Installing...
NAME: demo
NAMESPACE: demo
STATUS: deployed
REVISION: 1
TEST SUITE: None
Waiting for deployments to stabilize...
 - demo:deployment/demo is ready.
Deployments stabilized in 1.097 second
Press Ctrl+C to exit
Watching for changes...
...

Skaffold 使用 Helm 自动构建并部署了演示应用程序,现在正密切关注代码或图表的变化。在您进行开发时,它会使用随机生成的 SHA 作为临时占位符容器标签。如果您访问curl localhost:8888 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

在 Kubernetes 上管理云原生数据

在 Kubernetes 上管理云原生数据

Jeff Carpenter, Patrick McFadin
《Kubernetes 最佳实践》第二版

《Kubernetes 最佳实践》第二版

Brendan Burns, Eddie Villalba, Dave Strebel, Lachlan Evenson
生产 Kubernetes

生产 Kubernetes

Josh Rosso, Rich Lander, Alex Brand, John Harris
Cloud Native DevOps mit Kubernetes

Cloud Native DevOps mit Kubernetes

John Arundel, Justin Domingus

Publisher Resources

ISBN: 9798341659179