antony@notes:~/kubernetes$ cat "在-Kubernetes-建置-bobo-企業網站應用系統.md"
在 Kubernetes 建置 bobo 企業網站應用系統
在 Kubernetes 建置 bobo 企業網站應用系統
Preface
本篇文章會主要介紹,如何在 Kubernetes 搭建與設定 bobo 企業網站應用系統
可以透過點擊以下目錄,選擇想看的內容,跳轉至特定章節
:::warning
:::spoiler {state=“open”} 目錄
[TOC]
:::
系統架構圖

系統環境準備
## 安裝 Helm3
$ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
## 安裝 NFS
$ sudo apk -U add nfs-utils
## 設定 NFS Server
$ sudo rc-update add nfs
$ sudo mkdir /opt/www; sudo chown -R nobody:nogroup /opt/www
$ echo "/opt/www *(rw,sync,no_subtree_check,no_root_squash,no_all_squash,insecure)" | sudo tee /etc/exports
## 啟動 NFS Server
$ sudo rc-service rpcbind start
$ sudo rc-service nfs start
## Kind M109 設定
$ echo 'fs.inotify.max_user_instances=512
fs.inotify.max_user_watches=262144' | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
$ sudo podman exec c30-worker bash -c "systemctl restart rpcbind.service && \
rm -f /lib/systemd/system/nfs-common.service && \
systemctl daemon-reload && \
systemctl restart nfs-common.service"
$ sudo podman exec c30-worker2 bash -c "systemctl restart rpcbind.service && \
rm -f /lib/systemd/system/nfs-common.service && \
systemctl daemon-reload && \
systemctl restart nfs-common.service"
# 建立 Namespace
$ kubectl create ns nfs-provisioner
## 安裝與建立 NFS Provisioner
$ helm repo add nfs-subdir-external-provisioner https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner/
$ helm repo update
$ helm -n nfs-provisioner install mynfs nfs-subdir-external-provisioner/nfs-subdir-external-provisioner \
--set storageClass.defaultClass=true \
--set storageClass.name=mynfs \
--set nfs.server=192.168.61.128 \
--set nfs.path=/opt/www
$ kubectl -n nfs-provisioner get pods
NAME READY STATUS RESTARTS AGE
mynfs-nfs-subdir-external-provisioner-768545df76-7xzxc 1/1 Running 0 10s
## 設定 Node Label
$ kubectl label node c30-worker run=bobo
## 建立 MySQL NDB Operator
$ helm repo add ndb-operator-repo https://mysql.github.io/mysql-ndb-operator/
$ helm repo update
$ helm install ndb-operator ndb-operator-repo/ndb-operator --namespace=mysql-operator --create-namespace
$ kubectl -n mysql-operator get pods
NAME READY STATUS RESTARTS AGE
ndb-operator-app-5b9c84c4bc-6nfhz 1/1 Running 0 106s
ndb-operator-webhook-server-6c4d66d95d-twvzp 1/1 Running 0 106s開始安裝 bobo 系統
$ git clone https://github.com/braveantony/bobo.git
## 檢視 bobo 目錄中的檔案
$ tree bobo/
bobo/
├── cgi
│ ├── mydata.sh
│ ├── mydb.sh
│ └── mysetup.sh
├── deployment-bobo.yaml
├── ing.yaml
├── mysql-ndb.yaml
├── namespace.yaml
├── pod-fbs.yaml
├── pvc-bobo.yaml
├── svc-bobo.yaml
└── svc-fbs.yaml
$ ka -f ./bobo/namespace.yaml
$ ka -f ./bobo
$ kubectl -n bobo get pods
$ kubectl -n mysql get pods建立 MySQL NDB Cluster 管理者帳號
$ base64 -d <<< $(kubectl get secret mysql-ndb-mysqld-root-password -n mysql -o jsonpath={.data.password}); echo
JlabTb1jdqUcWY1d
$ kubectl exec -it -n mysql mysql-ndb-mysqld-0 -- bash
Defaulted container "mysqld-container" out of: mysqld-container, ndb-pod-init-container (init), mysqld-init-container (init)
bash-4.4# mysql -u root -pJlabTb1jdqUcWY1d
........
Server version: 8.0.31-cluster MySQL Cluster Community Server - GPL
.......
mysql> CREATE USER 'bobo'@'%' IDENTIFIED WITH caching_sha2_password BY 'bobo';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'bobo'@'%' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit
bash-4.4# exit