背景说明

Helm可以结合远程仓库对应用进行一键部署

解决方案

应用搜索

  1. [root@cka-master helm]# helm search repo mysql
  2. NAME CHART VERSION APP VERSION DESCRIPTION
  3. apphub/mysql 6.8.0 8.0.19 Chart to create a Highly available MySQL cluster
  4. apphub/mysqldump 2.6.0 2.4.1 A Helm chart to help backup MySQL databases usi...
  5. apphub/mysqlha 1.0.0 5.7.13 MySQL cluster with a single master and zero or ...
  6. apphub/prometheus-mysql-exporter 0.5.2 v0.11.0 A Helm chart for prometheus mysql exporter with...
  7. github/mysql 1.6.8 5.7.30 Fast, reliable, scalable, and easy to use open-...
  8. github/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL...
  9. github/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql ex...
  10. apphub/percona 1.2.0 5.7.17 free, fully compatible, enhanced, open source d...
  11. apphub/percona-xtradb-cluster 1.0.3 5.7.19 free, fully compatible, enhanced, open source d...
  12. apphub/phpmyadmin 4.2.12 5.0.1 phpMyAdmin is an mysql administration frontend
  13. github/percona 1.2.2 5.7.26 free, fully compatible, enhanced, open source d...
  14. github/percona-xtradb-cluster 1.0.7 5.7.19 free, fully compatible, enhanced, open source d...
  15. github/phpmyadmin 4.3.5 5.0.1 DEPRECATED phpMyAdmin is an mysql administratio...
  16. apphub/mariadb 7.3.9 10.3.22 Fast, reliable, scalable, and easy to use open-...
  17. apphub/mariadb-galera 0.8.1 10.4.12 MariaDB Galera is a multi-master database clust...
  18. github/gcloud-sqlproxy 0.6.1 1.11 DEPRECATED Google Cloud SQL Proxy
  19. github/mariadb 7.3.14 10.3.22 DEPRECATED Fast, reliable, scalable, and easy t...

应用安装

  1. [root@cka-master helm]# helm install mysql apphub/mysql
  2. NAME: mysql
  3. LAST DEPLOYED: Tue Mar 15 15:17:18 2022
  4. NAMESPACE: default
  5. STATUS: deployed
  6. REVISION: 1
  7. TEST SUITE: None
  8. NOTES:
  9. Please be patient while the chart is being deployed
  10. Tip:
  11. Watch the deployment status using the command: kubectl get pods -w --namespace default
  12. Services:
  13. echo Master: mysql.default.svc.cluster.local:3306
  14. echo Slave: mysql-slave.default.svc.cluster.local:3306
  15. Administrator credentials:
  16. echo Username: root
  17. echo Password : $(kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode)
  18. To connect to your database:
  19. 1. Run a pod that you can use as a client:
  20. kubectl run mysql-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mysql:8.0.19-debian-10-r0 --namespace default --command -- bash
  21. 2. To connect to master service (read/write):
  22. mysql -h mysql.default.svc.cluster.local -uroot -p my_database
  23. 3. To connect to slave service (read-only):
  24. mysql -h mysql-slave.default.svc.cluster.local -uroot -p my_database
  25. To upgrade this helm chart:
  26. 1. Obtain the password as described on the 'Administrator credentials' section and set the 'root.password' parameter as shown below:
  27. ROOT_PASSWORD=$(kubectl get secret --namespace default mysql -o jsonpath="{.data.mysql-root-password}" | base64 --decode)
  28. helm upgrade mysql bitnami/mysql --set root.password=$ROOT_PASSWORD

应用列表

  1. [root@cka-master helm]# helm list
  2. NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
  3. mysql default 1 2022-03-15 15:17:18.165166396 +0800 CST deployed mysql-6.8.0 8.0.19
  4. [root@cka-master helm]#
  5. [root@cka-master helm]# helm ls
  6. NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
  7. mysql default 1 2022-03-15 15:17:18.165166396 +0800 CST deployed mysql-6.8.0 8.0.19
  8. [root@cka-master helm]#

应用状态

  1. [root@cka-master helm]# helm status mysql
  2. [root@cka-master helm]# kubectl get pod
  3. NAME READY STATUS RESTARTS AGE
  4. myapp 1/1 Running 0 34h
  5. mysql-master-0 0/1 Pending 0 6m10s
  6. mysql-slave-0 0/1 Pending 0 6m10s
  7. [root@cka-master helm]#