Helm 部署配置mysql+glusterfs分佈式存儲應用

1、

使用的 Helm repo如下

最開始沒添加這個,下載的 stable/mysql ,不是很合適,後面加了這個源

helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator

helm repo update

helm search mysqlha

新建一個文件夾mysql

helm fetch incubator/mysqlha

解壓

cd mysqlha

2、

依據具體情況,調整values.yaml 中的值

我調整的項有

2.1

因爲 gcr.io/google-samples/xtrabackup:1.0 沒有pull 下來

看網上教程改爲 pull 這個 twoeo/gcr.io-google-samples-xtrabackup:latest.

2.2

增加了這兩個項

設置root用戶密碼

設置同步數據的密碼

2.3

增加了我本地集羣已有的 storageClass

size: 10Gi 可根據需要進行調整,我沒有調整

3、在這個路徑下進行部署

helm install mysql-ha . -f values.yaml

kubectl  describe po mysql-ha-mysqlha-0

會報下面這個錯,不管它,等待10多分鐘可以自行創建好。

創建成功後

kubectl get all -n *** 進行查看

4、部署NodePort Service 提供對外訪問

apiVersion: v1
kind: Service
metadata:
  name: mysql-ha-wirteandread-service
  labels:
    app: mysql-ha-mysqlha
spec:
  ports:
  - name: mysql-ha-master
    protocol: "TCP"
    port: 3306
    targetPort: 3306
    nodePort: 30336		#此爲外部連接k8s mysql-ha 服務的端口
  selector:
    statefulset.kubernetes.io/pod-name: mysql-ha-mysqlha-0
  type: NodePort

kubectl apply -f mysql-ha-wirteandread-service.yaml (部署讀寫服務)

apiVersion: v1
kind: Service
metadata:
  name: mysql-ha-readonly-service
  labels:
    app: mysql-ha-mysqlha
spec:
  ports:
  - name: mysql-ha-master
    protocol: "TCP"
    port: 3306
    targetPort: 3306
    nodePort: 30337		#此爲外部連接k8s mysql-ha 服務的端口
  selector:
    statefulset.kubernetes.io/pod-name: mysql-ha-mysqlha-1
  type: NodePort

kubectl apply -f mysql-ha-readonly-service.yaml(部署只讀服務)

部署成功後

任意一個master ip+30336 連接讀寫服務 賬號 root/values.yaml中定義的mysqlRootPassword密碼

任意一個master ip+30337 連接只讀服務 賬號 root/values.yaml中定義的用戶mysqlReplicationUser,密碼mysqlReplicationPassword

 

5、其他配置項設置

加了這兩句,增加了時區設置,否則少8個小時。增加了最大連接數的設置。

然後重新 helm uninstall /  helm install 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章