当前位置: 首页 > 文档资料 > Kubernetes 指南 >

6. 服务治理 - Helm

优质
小牛编辑
125浏览
2023-12-01

Helm是一个类似于 yum/apt/homebrew的 Kubernetes 应用管理工具。Helm 使用 Chart 来管理 Kubernetes manifest 文件。

Helm 基本使用

安装 helm 客户端

  1. brew install kubernetes-helm

初始化 Helm 并安装 Tiller 服务(需要事先配置好 kubectl)

  1. helm init

更新 charts 列表

  1. helm repo update

部署服务,比如 mysql

  1. ➜ ~ helm install stable/mysql
  2. NAME: quieting-warthog
  3. LAST DEPLOYED: Tue Feb 21 16:13:02 2017
  4. NAMESPACE: default
  5. STATUS: DEPLOYED
  6. RESOURCES:
  7. ==> v1/Secret
  8. NAME TYPE DATA AGE
  9. quieting-warthog-mysql Opaque 2 1s
  10. ==> v1/PersistentVolumeClaim
  11. NAME STATUS VOLUME CAPACITY ACCESSMODES AGE
  12. quieting-warthog-mysql Pending 1s
  13. ==> v1/Service
  14. NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  15. quieting-warthog-mysql 10.3.253.105 <none> 3306/TCP 1s
  16. ==> extensions/v1beta1/Deployment
  17. NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
  18. quieting-warthog-mysql 1 1 1 0 1s
  19. NOTES:
  20. MySQL can be accessed via port 3306 on the following DNS name from within your cluster:
  21. quieting-warthog-mysql.default.svc.cluster.local
  22. To get your root password run:
  23. kubectl get secret --namespace default quieting-warthog-mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode; echo
  24. To connect to your database:
  25. 1. Run an Ubuntu pod that you can use as a client:
  26. kubectl run -i --tty ubuntu --image=ubuntu:16.04 --restart=Never -- bash -il
  27. 2. Install the mysql client:
  28. $ apt-get update && apt-get install mysql-client -y
  29. 3. Connect using the mysql cli, then provide your password:
  30. $ mysql -h quieting-warthog-mysql -p

更多命令的使用方法可以参考Helm 命令参考。

Helm 工作原理

见 Helm 工作原理。

Helm Repository

官方 repository:

第三方 repository:

常用 Helm 插件

  1. helm-tiller - Additional commands to work with Tiller
  2. Technosophos’s Helm Plugins - Plugins for GitHub, Keybase, and GPG
  3. helm-template - Debug/render templates client-side
  4. Helm Value Store - Plugin for working with Helm deployment values
  5. Drone.io Helm Plugin - Run Helm inside of the Drone CI/CD system