helm3安装mysql8

helm3安装mysql8

      • 1. 下载chart 包
      • 2. 创建StorageClass
      • 3. 自定义value配置文件
      • 4. 安装
      • 5. 查看
      • 6. 连接

1. 下载chart 包

[root@master helm]# helm search repo mysql
NAME                            	CHART VERSION	APP VERSION	DESCRIPTION                                       
apphub/mysql                    	6.7.1        	8.0.18     	Chart to create a Highly available MySQL cluster  
[root@master helm]# helm pull apphub/mysql
[root@master helm]# ls
mysql-6.7.1.tgz
[root@master helm]# tar -xvf mysql-6.7.1.tgz
[root@master mysql]# ls
Chart.yaml  ci  files  README.md  templates  values-production.yaml  values.yaml

2. 创建StorageClass

[root@master mysql]# cat < mysql-data-sc.yaml 
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: mysql-data
provisioner: fuseim.pri/ifs
EOF

[root@master mysql]# kubectl create -f mysql-data-sc.yaml 

3. 自定义value配置文件

[root@master mysql]# cat < my-values.yaml
root:
  password: root
  forcePassword: true
replication:
  enabled: false
master:
  persistence:
    storageClass: "mysql-data"
    size: 2Gi
service:
  type: NodePort
  port: 3306
  nodePort: 33060
EOF

nodePort端口好像没起作用,现在是随机的

4. 安装

[root@master mysql]# helm install --name-template mysql -f my-values.yaml . --namespace course

5. 查看

[root@master mysql]# kubectl get pods -n course | grep mysql
mysql-master-0                              1/1     Running   0          24m

[root@master mysql]# kubectl get svc -n course | grep mysql
mysql                NodePort    10.100.171.198           3306:30145/TCP   24m

6. 连接

使用公网ip + 30145连接

你可能感兴趣的:(K8S)