Skip to content

Helm安装部署mysql

helm安装部署mysql

  • what: helm安装部署mysql
  • where: k8s、linux、helm
  • when: 2022.6.1
  • who: JRT
  • why: 记录
  • how:

helm安装

helm概念

Helm这个东西其实早有耳闻,但是一直没有用在生产环境,而且现在对这货的评价也是褒贬不一。
正好最近需要再次部署一套测试环境,对于单体服务,部署一套测试环境我相信还是非常快的,但是对于微服务架构的应用,要部署一套新的环境,就有点折磨人了,微服务越多、你就会越绝望的。虽然我们线上和测试环境已经都迁移到了kubernetes环境,但是每个微服务也得维护一套yaml文件,而且每个环境下的配置文件也不太一样,部署一套新的环境成本是真的很高。如果我们能使用类似于yum的工具来安装我们的应用的话是不是就很爽歪歪了啊?Helm就相当于kubernetes环境下的yum包管理工具。

helm安装

安装wget

yum -y install wget

下载helm二进制包 官方下载地址https://github.com/helm/helm/releases

wget https://get.helm.sh/helm-v3.7.1-linux-amd64.tar.gz

解压二进制包

tar -xzvf helm-v3.7.1-linux-amd64.tar.gz

移动二进制文件到bin下

mv linux-amd64/helm /usr/local/bin/helm

清理
删除二进制包及解压文件

rm -rf helm-v3.7.1-linux-amd64.tar.gz linux-amd64

配置自动补全
安装bash-completion

yum install -y bash-completion

配置bash-completion

source /usr/share/bash-completion/bash_completion

设置helm自动补全

source /usr/share/bash-completion/bash_completion

添加helm到bash-completion配置文件中去

helm completion bash > /etc/bash_completion.d/helm

验证,输入helm i,然后tab自动补全

[root@jrt data]# helm version
version.BuildInfo{Version:"v3.6.1", GitCommit:"61d8e8c4a6f95540c15c6a65f36a6dd0a45e7a2f", GitTreeState:"clean", GoVersion:"go1.16.5"}
[root@jrt data]# helm repo add aliyun https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"aliyun" has been added to your repositories
[root@jrt data]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "aliyun" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@jrt data]# helm repo list
NAME    URL                                                   
aliyun  https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
[root@jrt data]# helm search repo mysql
NAME                            CHART VERSION   APP VERSION DESCRIPTION                                       
aliyun/mysql                    0.3.5                       Fast, reliable, scalable, and easy to use open-...
aliyun/percona                  0.3.0                       free, fully compatible, enhanced, open source d...
aliyun/percona-xtradb-cluster   0.0.2           5.7.19      free, fully compatible, enhanced, open source d...
aliyun/gcloud-sqlproxy          0.2.3                       Google Cloud SQL Proxy                            
aliyun/mariadb                  2.1.6           10.1.31     Fast, reliable, scalable, and easy to use open-...
[root@jrt data]#  helm install test-mysql aliyun/mysql
Error: unable to build kubernetes objects from release manifest: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"
[root@jrt data]#