Skip to Content
在 Kubernetes 上管理云原生数据
book

在 Kubernetes 上管理云原生数据

by Jeff Carpenter, Patrick McFadin
May 2025
Beginner to intermediate
332 pages
4h 22m
Chinese
O'Reilly Media, Inc.
Content preview from 在 Kubernetes 上管理云原生数据

第 4 章 使用 Helm 在 Kubernetes 上自动部署数据库 使用 Helm在 Kubernetes 上自动部署数据库

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

在上一章中,你学习了如何在 Kubernetes 上手动部署单节点和多节点数据库,一次创建一个元素。我们故意采用 "艰难的方式 "来帮助你最大限度地理解如何使用 Kubernetes 基元来设置数据库所需的计算、Network 和存储资源。当然,这并不代表在 Kubernetes 上运行数据库的经验,原因有以下几点。

首先,团队通常不会一个 YAML 文件一个 YAML 文件地手工部署数据库。这会变得非常繁琐。即使将配置合并到一个文件中也会变得相当复杂,尤其是对于更复杂的部署。考虑一下第 3 章中Cassandra 作为多节点数据库与单节点 MySQL 部署相比所需的配置量的增加。这对大型企业来说无法扩展。

其次,部署数据库固然很好,但如何保持数据库长期运行呢?您需要您的数据基础架构长期保持可靠和高性能,而数据基础架构是众所周知需要精心呵护和喂养的。换句话说,运行系统的任务通常分为 "第一天"(将应用程序部署到生产环境的喜悦之日)和 "第二天"(第一天之后的每一天,您需要在保持高可用性的同时运行和发展应用程序)。

围绕数据库部署和运行的这些考虑因素反映了 DevOps 这一更大的行业趋势,即开发团队在支持生产中的应用程序方面发挥更积极的作用。DevOps 实践包括使用自动化工具对应用程序进行 CI/CD,缩短代码从开发人员的桌面进入生产所需的时间。

在本章中,我们将介绍有助于实现数据库和其他应用程序部署标准化的工具。这些工具采用基础架构即代码(IaC)的方法,允许你以一种可以自动执行的格式来表示软件安装和配置选项,从而减少你必须编写的配置代码总量。在接下来的两章中,我们还将强调数据基础架构操作,并将这一主题贯穿本书的其余部分。

使用 Helm 图表部署应用程序

让我们先来看看一款能帮助您管理复杂配置的工具:Helm。这个用于 Kubernetes 的包管理器是开源的,也是 CNCF 的毕业项目。包管理器的概念在多种编程语言中都很常见,比如 Python 的pip 、JavaScript 的 Node 包管理器(NPM)以及 Ruby 的 Gems 功能。针对特定操作系统的软件包管理器也同样存在,例如 Linux 的 Apt 或 macOS 的 Homebrew。如图 4-1 所示,软件包管理系统的基本要素包括软件包、存储软件包的注册表以及软件包管理应用程序(或客户端),后者可帮助图表开发人员注册图表,并允许图表用户在本地系统中查找、安装和更新软件包。

Helm, a package manager for Kubernetes
图 4-1. Kubernetes 的软件包管理器 Helm

Helm 将软件包管理的概念扩展到 Kubernetes,但有一些有趣的不同之处。如果你使用过之前列出的某个软件包管理器,你就会熟悉这样一个概念:软件包由二进制文件(可执行代码)以及描述二进制文件的元数据(如功能、API 和安装说明)组成。在 Helm 中,软件包被称为图表。图表描述了如何通过使用前几章介绍的用于计算、网络和存储的 Kubernetes 资源(如 Pods、Services 和 ...

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 实现云原生 DevOps(第二版)》

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

Justin Domingus, John Arundel
生产 Kubernetes

生产 Kubernetes

Josh Rosso, Rich Lander, Alex Brand, John Harris

Publisher Resources

ISBN: 9798341659667