helm
- CNCF: Cloud Native Computing Foundation (云原生计算基金会)
- YAML: Yet Another Markup Language (仍是一种标记语言)
- RPM: Red-Hat Package Manager (红帽软件包管理器)
- DPKG: Debian Packager (Debian包管理器)
- Yum: Yellow dog Updater, Modified (Shell前端软件包管理器)
- DEB: Debian(Debian软件包格式的文件扩展名)
- APT: Advanced Packaging Tool (Linux下的一款安装包管理工具)
- VPC: Virtual Private Cloud (私有云)
- VPN: Virtual Private Network (专有网络)
introduction
Helm 是Kubernetes的包管理器,Helm帮助您管理Kubernetes应用程序-Helm图表帮助您定义、安装和升级最复杂的Kubernetes应用程序。Chart 的创建、版本、共享和发布都很容易,所以请开始使用Helm并停止复制和粘贴。
特点:
- 复杂性管理
- 易于升级
- 分发简单
- 轻松回滚
对于Helm,有三个重要的概念:
- chart 创建Kubernetes应用程序所必需的一组信息。
- config 包含了可以合并到打包的chart中的配置信息,用于创建一个可发布的对象。
- release 是一个与特定配置相结合的chart的运行实例。
architecture
安装
- macos
brew install helm
- windows
使用
1. helm search
从 Artifact Hub 中搜索所有的mysql.
$ helm search hub mysql
URL CHART VERSION APP VERSION DESCRIPTION
https://artifacthub.io/packages/helm/bitnami-ak... 8.8.18 8.0.27 Chart to create a Highly available MySQL cluster
https://artifacthub.io/packages/helm/bitnami/mysql 8.8.19 8.0.27 Chart to create a Highly available MySQL cluster
https://artifacthub.io/packages/helm/cloudnativ... 5.0.1 8.0.16 Chart to create a Highly available MySQL cluster
https://artifacthub.io/packages/helm/choerodon/... 8.5.1 8.5.1 Chart to create a Highly available MySQL cluster
https://artifacthub.io/packages/helm/stakater/m... 1.0.6 mysql chart that runs on kubernetes
https://artifacthub.io/packages/helm/t3n/mysql 1.0.0 5.7.32 Fast, reliable, scalable, and easy to use open-...
https://artifacthub.io/packages/helm/kubesphere... 1.6.8 5.7.31 Fast, reliable, scalable, and easy to use open-...
https://artifacthub.io/packages/helm/homeenterp... 0.1.0 8.0.26 MySQL Database Server
https://artifacthub.io/packages/helm/someblackm... 1.7.1 5.7.33 Fast, reliable, scalable, and easy to use open-...
https://artifacthub.io/packages/helm/wso2/mysql 1.6.9 5.7.30 Fast, reliable, scalable, and easy to use open-...
https://artifacthub.io/packages/helm/devopspilo... 1.0.0 1.0.0 Helm chart for running mysql database
https://artifacthub.io/packages/helm/anvibo/mysql 0.1.0 1.16.0 A Helm chart for Kubernetes
https://artifacthub.io/packages/helm/mysql-oper... 8.0.26-2.0.2 8.0.26 MySQL InnoDB Cluster Helm Chart for deploying M...
https://artifacthub.io/packages/helm/mysql-oper... 8.0.26-2.0.2 8.0.26-2.0.2 MySQL Operator Helm Chart for deploying MySQL I...
https://artifacthub.io/packages/helm/softonic/m... 2.2.0 0.3.0 Take mysql backups from any mysql instance to A...
https://artifacthub.io/packages/helm/kfirfer/my... 0.0.3 8.0.20 A Helm chart for MySQL Cluster
https://artifacthub.io/packages/helm/kanister/k... 0.32.0 5.7.14 MySQL w/ Kanister support based on stable/mysql
https://artifacthub.io/packages/helm/bitpoke/my... 0.6.2 v0.6.2 A Helm chart for easy deployment of a MySQL clu...
https://artifacthub.io/packages/helm/presslabs/... 0.3.1 1.0 A Helm chart for easy deployment of a MySQL clu...
https://artifacthub.io/packages/helm/bitpoke/my... 0.6.2 v0.6.2 A helm chart for Bitpoke Operator for MySQL
https://artifacthub.io/packages/helm/presslabs/... 0.5.0-rc.3 v0.5.0-rc.3 A Helm chart for mysql operator
可以从已添加的仓库中查找chart的名字。
$ helm search repo mysql
NAME CHART VERSION APP VERSION DESCRIPTION
aliyuncs/mysql 6.8.0 8.0.19 Chart to create a Highly available MySQL cluster
aliyuncs/mysqldump 2.6.0 2.4.1 A Helm chart to help backup MySQL databases usi...
aliyuncs/mysqlha 1.0.0 5.7.13 MySQL cluster with a single master and zero or ...
aliyuncs/prometheus-mysql-exporter 0.5.2 v0.11.0 A Helm chart for prometheus mysql exporter with...
bitnami/mysql 8.8.19 8.0.27 Chart to create a Highly available MySQL cluster
aliyuncs/percona 1.2.0 5.7.17 free, fully compatible, enhanced, open source d...
aliyuncs/percona-xtradb-cluster 1.0.3 5.7.19 free, fully compatible, enhanced, open source d...
aliyuncs/phpmyadmin 4.2.12 5.0.1 phpMyAdmin is an mysql administration frontend
bitnami/phpmyadmin 8.3.2 5.1.1 phpMyAdmin is an mysql administration frontend
aliyuncs/mariadb 7.3.9 10.3.22 Fast, reliable, scalable, and easy to use open-...
aliyuncs/mariadb-galera 0.8.1 10.4.12 MariaDB Galera is a multi-master database clust...
bitnami/mariadb 10.2.0 10.5.13 Fast, reliable, scalable, and easy to use open-...
bitnami/mariadb-cluster 1.0.2 10.2.14 DEPRECATED Chart to create a Highly available M...
bitnami/mariadb-galera 6.1.1 10.6.5 MariaDB Galera is a multi-master database clust...
## 添加常用的chart源
$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm repo add aliyuncs https://apphub.aliyuncs.com
## 查看chart列表
$ helm repo list
NAME URL
bitnami https://charts.bitnami.com/bitnami
aliyuncs https://apphub.aliyuncs.com
我们选择aliyuncs/mysql 的chart包 先下载看看包有什么内容
## 拉取包
$ helm pull aliyuncs/mysql --untar
## 查看包内容
$ tree mysql/
mysql
├── Chart.yaml
├── README.md
├── ci
│ └── values-production.yaml
├── files
│ └── docker-entrypoint-initdb.d
│ └── README.md
├── templates
│ ├── NOTES.txt
│ ├── _helpers.tpl
│ ├── initialization-configmap.yaml
│ ├── master-configmap.yaml
│ ├── master-statefulset.yaml
│ ├── master-svc.yaml
│ ├── secrets.yaml
│ ├── servicemonitor.yaml
│ ├── slave-configmap.yaml
│ ├── slave-statefulset.yaml
│ └── slave-svc.yaml
├── values-production.yaml
└── values.yaml
4 directories, 17 files
2. helm install
Helm按照以下顺序安装资源:
- Namespace
- NetworkPolicy
- ResourceQuota
- LimitRange
- PodSecurityPolicy
- PodDisruptionBudget
- ServiceAccount
- Secret
- SecretList
- ConfigMap
- StorageClass
- PersistentVolume
- PersistentVolumeClaim
- CustomResourceDefinition
- ClusterRole
- ClusterRoleList
- ClusterRoleBinding
- ClusterRoleBindingList
- Role
- RoleList
- RoleBinding
- RoleBindingList
- Service
- DaemonSet
- Pod
- ReplicationController
- ReplicaSet
- Deployment
- HorizontalPodAutoscaler
- StatefulSet
- Job
- CronJob
- Ingress
- APIService
helm install my-nginx aliyuncs/nginx --set service.type=NodePort --set persistence.enabled=false
NAME: my-nginx
LAST DEPLOYED: Wed Jan 5 09:00:22 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Get the NGINX URL:
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services my-nginx)
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
echo "NGINX URL: http://$NODE_IP:$NODE_PORT/"
查看是否安装成功
% kubectl get all
NAME READY STATUS RESTARTS AGE
pod/my-nginx-5c4ccb468f-j5g77 1/1 Running 0 89s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 70d
service/my-nginx NodePort 10.104.115.235 <none> 80:31631/TCP,443:32392/TCP 89s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/my-nginx 1/1 1 1 89s
NAME DESIRED CURRENT READY AGE
replicaset.apps/my-nginx-5c4ccb468f 1 1 1 89s
访问Nginx
http://localhost:31631/
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
安装成功!
3. helm status
查看chart的状体啊
% helm status my-nginx
NAME: my-nginx
LAST DEPLOYED: Wed Jan 5 09:00:22 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Get the NGINX URL:
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services my-nginx)
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
echo "NGINX URL: http://$NODE_IP:$NODE_PORT/"
4. 安装前自定义图表
使用helm show values
查看chart的配置选项
% helm show values aliyuncs/nginx
## Global Docker image parameters
## Please, note that this will override the image parameters, including dependencies, configured to use the global value
## Current available global Docker image parameters: imageRegistry and imagePullSecrets
##
# global:
# imageRegistry: myRegistryName
# imagePullSecrets:
# - myRegistryKeySecretName
## Bitnami NGINX image version
## ref: https://hub.docker.com/r/bitnami/nginx/tags/
##
image:
registry: docker.io
repository: bitnami/nginx
tag: 1.16.1-debian-10-r0
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
##
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# pullSecrets:
# - myRegistryKeySecretName
## String to partially override nginx.fullname template (will maintain the release name)
##
# nameOverride:
您可以任何覆盖设置,用一个YAML格式文件,然后在安装过程中传递该文件。
$ echo '{metrics.enabled: false}' > values.yaml
$ helm install -f values.yaml aliyuncs/nginx --generate-name
安装过程中有两种方式传递配置数据:
- –values (或 -f):使用 YAML 文件覆盖配置。可以指定多次,优先使用最右边的文件。
- –set:通过命令行的方式对指定项进行覆盖。