测试
install crd
cd ~/k8s/greatdb-operator/manifests/ && kubectl create -f greatdbcluster_crd.yaml
cd ~/k8s/greatdb-operator/manifests/ && kubectl create -f greatdbmonitor_crd.yaml
安装greatdb-operator
cd ~/k8s/greatdb-operator && docker build -t greateopensource/greatdb-operator:v0.1.1 .
cd ~/k8s/greatdb-operator/helm/charts && helm install --namespace greatdb-admin greatdb-operator
kubectl get po -n greatdb-admin
cd ~/k8s/greatdb-operator/helm/charts && helm uninstall --namespace greatdb-admin greatdb-operator
部署测试集群
cd ~/k8s/greatdb-operator/examples && kubectl apply -n greatdb -f greatdb.yaml
cd ~/k8s/greatdb-operator/examples && kubectl delete -n greatdb -f greatdb.yaml
kubectl delete pvc sqlnode-cluster-sqlnode-0 sqlnode-cluster-sqlnode-1 sqlnode-cluster-sqlnode-2 -n greatdb
kubectl delete pvc datanode-cluster-datanode-0 datanode-cluster-datanode-1 datanode-cluster-datanode-2 datanode-cluster-datanode-3 datanode-cluster-datanode-4 datanode-cluster-datanode-5 -n greatdb
部署监控 monitor
cd ~/k8s/greatdb-operator/docker/greatdb-monitor && docker build -t greatdb/greatdb-monior-init:v0.0.1 .
cd ~/k8s/greatdb-operator/examples && kubectl apply -n greatdb -f monitor.yaml
cd ~/k8s/greatdb-operator/examples && kubectl delete -n greatdb -f monitor.yaml
kubectl port-forward -n greatdb svc/monitor-grafana 3000 > pf3000.out &
greatdb 镜像
cd ~/k8s/greatdb-operator/docker/greatdb && docker build -t greatopensource/greatdb:lasted .
docker run --name greatdb-test --network kind --hostname greatdb-host -d greatopensource/greatdb:latest
docker cp ~/k8s/greatdb-operator/docker/create_config.sh greatdb-test:/
docker exec -it greatdb-test /bin/bash
chmod +x /create_config.sh && /create_config.sh sqlnode 3306 > /var/lib/greatdb-cluster/sqlnode.cnf
cd /usr/local/greatdb-cluster
bin/greatdb_init --defaults-file=/var/lib/greatdb-cluster/sqlnode.cnf --cluster-host=% --cluster-password=greatdb --node-type=sqlnode
使用简介
需要预先准备k8s环境
1.安装greatdb-operator
clone本项目到本地,本示例clone到`~/k8s/`目录
构建greatdb镜像(注意当前greatdb版本为greatdb-cluster-5.0.4-3d46f2558e2-Linux-glibc2.12-x86_64)
cd ~/k8s/great-operator/docker
docker build -t greatopensource/greatdb:latest .
构建operator镜像
cd ~/k8s/greatdb-operator && docker build -t greatopensource/greatdb-operator:v0.1.1
安装GreatDBCluster CRD
cd ~/k8s/greatdb-operator/manifests/ && kubectl apply -f greatcluster_crd.yaml
创建namespace
kubectl create ns greatdb-admin
kubectl create ns greatdb
部署operator
cd ~/k8s/greatdb-operator/helm/charts && helm install --namespace greatdb-admin greatdb-operator greatdb-operator
查看
kubectl get po -n greatdb-admin
NAME READY STATUS RESTARTS AGE
greatdb-controller-manager-59f7597df-5jh24 1/1 Running 0 47h
编写GreatDBCluster yaml文件,部署集群,比如examples/目录下的默认示例
```yaml
# IT IS NOT SUITABLAE FOR PRODUCTION USE.
# This YAML describe a basic GreatDB cluster with minimum resource requirements,
# which should be able to run in any Kubernetes cluster with storage support.
apiVsersion: greatopensource.com/v1alpha1
kind: GreatDBCluster
metadata:
name: cluster
spec:
version: v5.0.4
timezone: UTC
pvReclaimPolicy: Retain
enableDynamicConfiguration: true
configUpdateStrategy: RollingUpdate
sqlNode:
baseImage: greatopsource/greatdb
version: lastest
replicas: 3
service:
type: NodePort
storageClassName: local-path
requests:
storage: "5Gi"
config: {}
enableMetrics: false
dataNode:
baseImage: greatopensource/greatdb
version: lastest
replicas: 6
storageClassName: local-path
requests:
storage: "5Gi"
config: {}
```
注意使用了存储类local-path,该资源的安装参见prepare.md
部署集群
cd ~/k8s/greatdb-operator/examples && kubectl apply -n greatdb -f greatdb.yaml
查看
kubectl get pod -n greatdb
NAME READY STATUS RESTARTS AGE
cluster-datanode-0 2/2 Running 0 47s
cluster-datanode-1 2/2 Running 0 47s
cluster-datanode-2 2/2 Running 0 47s
cluster-datanode-3 2/2 Running 0 47s
cluster-datanode-4 2/2 Running 0 47s
cluster-datanode-5 2/2 Running 0 47s
cluster-sqlnode-0 2/2 Running 0 47s
cluster-sqlnode-1 2/2 Running 0 47s
cluster-sqlnode-2 2/2 Running 0 47s
查看service
kubectl get svc -n greatdb
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
cluster-datanode-peer ClusterIP None <none> 3306/TCP 98s
cluster-sqlnode NodePort 10.100.96.156 <none> 3306:32721/TCP,10080:32055/TCP 98s
cluster-sqlnode-peer ClusterIP None <none> 10080/TCP 98s
登录sqlnode
mysql -uroot -pgreatdb -h 172.16.70.246 -P32721
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 38
Server version: 8.0.21-12-greatdbcluster5.0.4-rc GreatDB Cluster (GPL), Release rc, Revision 3d46f2558e2
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>