image.png
前言
本文使用helm啟動(dòng)單節(jié)點(diǎn)mysql复亏。
*我的其他相關(guān)文章:
《docker-compose啟動(dòng)mysql》
《k8s啟動(dòng)單點(diǎn)mysql》
《helm啟動(dòng)mysql-ha》
《k8s啟動(dòng)phpmyadmin》
1. 準(zhǔn)備
chart包
從 https://github.com/helm/charts 已下載 charts-master拼苍, 其中stable目錄里包含mysql目錄鸭轮,該目錄即為單機(jī)版mysql的chart包安裝文檔
進(jìn)入上邊github地址逮诲,找到msyql目錄制恍,下邊有安裝文檔和所有可以換變量沪羔。
2. 修改變量
mysql/values.yaml 文件包含需要修改的變量
- 修改root密碼
如果這里不設(shè)置赁酝,也可以啟動(dòng)Release的時(shí)候用命令覆蓋韧掩。
mysqlRootPassword: YunWeiDao888
- 修改為 service
修改service 代理方式為nodeport
service:
annotations: {}
## Specify a service type
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services---service-types
type: NodePort
#type: ClusterIP
port: 13306
nodePort: 30102
# nodePort: 32000
# loadBalancerIP:
- 其他根據(jù)需要修改
1.3 啟動(dòng)Release
# cd charts-master/stable/mysql
# helm install mysql -n mysql --set mysqlRootPassword=YunWeiDao888 ./
說(shuō)明:如果前邊在values.yaml文件中修改了紊浩,上邊命令可以不加 --set mysqlRootPassword
FAQ
有些鏡像版本默認(rèn)root只能本地用戶登錄,且不使用密碼疗锐。
因此需要進(jìn)入容器不使用密碼登錄
# kubectl exec -it -n mysql mysql-7f4776db6f-hft2r bash
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5677
Server version: 5.7.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
創(chuàng)建遠(yuǎn)程登錄賬號(hào)
mysql> grant all on *.* to root@'%' identified by ' YunWeiDao888';
mysql> flush privilege;