Skip to content

Commit

Permalink
添加 helm 和 kubectl
Browse files Browse the repository at this point in the history
  • Loading branch information
rectcircle committed May 21, 2022
1 parent 3ec4ddc commit e714552
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
9 changes: 9 additions & 0 deletions content/posts/k8s-kubectl.md
@@ -0,0 +1,9 @@
---
title: "Kubernetes 命令行工具 kubectl"
date: 2022-05-20T22:07:31+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---
55 changes: 55 additions & 0 deletions content/posts/k8s-package-manager-helm.md
@@ -0,0 +1,55 @@
---
title: "Kubernetes 包管理器 Helm"
date: 2022-05-20T22:07:33+08:00
draft: true
toc: true
comments: true
tags:
- untagged
---

## 简述

Helm 是 Kubernetes 的包管理器,是 [CNCF](https://www.cncf.io/projects/) 的毕业项目之一。

和 传统的包管理器类似(apt / npm / maven),Helm 提供了一个 CLI 客户端,定义并提供了 Helm Chart [包管理仓库](https://artifacthub.io/) (Chart 指的是包)。

Helm 在 Kubernetes 看来和 Kubectl 类似,仅仅是一个 Client。因此 Helm 不需要 Kubernetes 做任何特殊了配置,即可在任何 Kubernetes 集群中使用。

Helm 的核心,定义了一套渲染 Kubernetes 声明式配置文件模板的规范,并通过模板引擎实现了该规范。

作为一个运行在 Kubernetes 的应用开发者,只需要为该应用编写一个 Chart:Kubernetes 声明式配置文件模板、模板参数和默认值 和 外部依赖(如 MySQL、Redis),即可一键在 Kubernetes 集群中将该应用和依赖启动起来,并可以根据通过 Chart 参数灵活的配置应用。

```
+------------------------+
| Chart Repository |
+------------------------+
+-->| Dependency A |---+
+-->| Dependency B |---+
| +------------------------+ |
(dependency) |
| +------------------------+ |
| | Chart: App |---+
| +------------------------+ |
| | /templates | |
| | Values.yaml | |
+---| Chart.yaml | |
+------------------------+ |
|
Deploy +---(Go template engine)---> Kubernetes Configurations ------> Kubernetes Clusters
(helm install) |
|
+------------------------+ |
| Release Values |---+
+------------------------+
| --set-file Values.yaml |
| --set foo=bar |
+------------------------+
```

上图所示的是,对一个 Chart 进行部署的流程。

* Chart App 定义了一个 Chart,其依赖两个在 Chart Repository 中的两个 Chart。
* 用户通过 `helm install` 命令进行一次部署,并通过 `--set-file``--set` 覆盖 Chart App 中的参数。
* Helm CLI 通过 Go 模板引擎将 Values 和 Templates 进行渲染,得到 Kubernetes 配置。
* 最后通过 Kubernetes API (类似于 kubectl apply) 将配置应用到 Kubernetes 集群中。
17 changes: 17 additions & 0 deletions content/posts/kubernetes.md
Expand Up @@ -9,6 +9,23 @@ tags:
- 后端
---

<!--
TODO 本文件保留目录索引,内容迁移到一个新的系列文章中:
使用者 / 维护者 两种角色
* 系列概述
* 单节点集群安装
* 组件和集群管理工具 kubeadm
* 抽象和标准对象(使用者)
* https://kubernetes.io/zh/docs/concepts/overview/working-with-objects/
* 对象管理工具 kubectl(使用者)
* Helm 包管理器(使用者)
* API 和 SDK
* 扩展接口
-->

> [官方文档](https://kubernetes.io/zh/docs/home/)
## 快速开始
Expand Down

0 comments on commit e714552

Please sign in to comment.