update video
由于部署和使用对时间有需求,需要提前在各个节点拉取镜像
docker pull enmotech/opengauss:2.1.0 docker pull gcr.io/distroless/static:nonroot (需要能访问google服务) docker pull gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0 (需要能访问google服务) docker pull zenghaocq/opengauss-controller:0.2.0 docker pull larryyang97/opengauss-webhook
在项目路径下运行如下命令进行部署:
make install #如需卸载 make uninstall
make deploy #如需卸载 make undeploy
webhook部署需要获取caBundle和生成证书,相关源代码和部署文件在./webhooks 首先切换到源码的webhooks/deploy目录下
./webhooks
echo $(kubectl get configmap -n kube-system extension-apiserver-authentication -o=jsonpath='{.data.client-ca-file}' | base64 | tr -d '\n')
apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: name: "pod-migration-webhook.opengauss.org" webhooks: <...> clientConfig: caBundle: <substitute with your caBundle here> <...>
bash webhook-cert.sh --service opengauss-pod-migration-webhook-service --secret webhook-tls-secret
kubectl apply -f ./
这里描述yaml文件,用如下命令即可。
kubectl apply -f <file-name>.yaml #如 kubectl apply -f config/samples/db_v1_opengausscluster.yaml
使用OpenGaussCluster这一CRD部署,将primary设置为1,standby节点个数设置为0即可
apiVersion: db.opengauss.org/v1 kind: OpenGaussCluster metadata: name: opengausscluster-sample #名字不要过长 spec: image: enmotech/opengauss:2.1.0 #镜像名 primary: replicas: 1 #单机部署 standby: replicas: 0
本operator使用无需提前为pod指定ip,目前支持一主多从,已经测试过一主八从。1-2分钟左右,所有pod处于running ready状态
running ready状态
apiVersion: db.opengauss.org/v1 kind: OpenGaussCluster metadata: name: opengausscluster-sample spec: image: enmotech/opengauss:2.1.0 #镜像名 password: "Test@12345" #初始密码,可以进入数据库更改 primary: replicas: 1 #primary副本数 storage: 512Mi storageClass: nfs-client #注意当storageClass为空的时候,使用系统默认storageClass #应该指定nfs storageClass的名字 standby: replicas: 2 #standby副本数 storage: 512Mi storageClass: nfs-client
修改OpenGaussCluster.spec.standby.replicas字段即可完成缩扩容,用kubectel edit修改,或者重新kubectl apply -f <file-name>.yaml均可
OpenGaussCluster.spec.standby.replicas
kubectel edit
kubectl apply -f <file-name>.yaml
注意,当前不支持从0扩容或者缩容到0
apiVersion: db.opengauss.org/v1 kind: OpenGaussCluster metadata: name: opengausscluster-sample spec: image: enmotech/opengauss:2.1.0 #镜像名 password: "Test@12345" primary: replicas: 1 #primary副本数 storage: 512Mi storageClass: nfs-client standby: replicas: 3 #standby副本数,更改为期望的副本数, storage: 512Mi storageClass: nfs-client
修改OpenGaussCluster.spec.image字段即可完成,注意目前只保证enmotech/opengauss:2.1.0及更高版本兼容,这里演示enmotech/opengauss:2.1.0到enmotech/opengauss:latest的升级测试
OpenGaussCluster.spec.image
升级镜像版本,用```kubectel edit```修改,或者重新```kubectl apply -f <file-name>.yaml```均可 ```yaml apiVersion: db.opengauss.org/v1 kind: OpenGaussCluster metadata: name: opengausscluster-sample spec: image: enmotech/opengauss:latest #要升级的镜像名 primary: replicas: 1 standby: replicas: 3
使用OpenGaussPodMigration这一CRD实现迁移,迁移需要部署webhook
apiVersion: db.opengauss.org/v1 kind: OpenGaussPodMigration metadata: name: opengausspodmigration-sample labels: clusterName: opengausscluster-sample #必要!迁移的pod对应的OpenGaussCluster名字 spec: podName: opengausscluster-sample-s-1 #要迁移的pod名字 targetNodeName: node1 #要迁移到的节点名字
openGauss-operator
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
总体设计
OpengaussCluster资源关系示意图
Pod迁移示意图
opengauss-operator部署及使用
一、部署流程
1.环境准备
2.拉取镜像
由于部署和使用对时间有需求,需要提前在各个节点拉取镜像
3.部署CRD
在项目路径下运行如下命令进行部署:
4.部署controller
在项目路径下运行如下命令进行部署:
5.部署webhook
webhook部署需要获取caBundle和生成证书,相关源代码和部署文件在
./webhooks
首先切换到源码的webhooks/deploy目录下1. 获取caBundle
2.使用1中获取的caBundle替换hook.yaml中的caBundle字段
3.使用webhook-cert.sh脚本生成证书和秘钥
4.部署
二、使用operator
这里描述yaml文件,用如下命令即可。
1.部署单节点opengauss集群
使用OpenGaussCluster这一CRD部署,将primary设置为1,standby节点个数设置为0即可
2.部署主备模式
本operator使用无需提前为pod指定ip,目前支持一主多从,已经测试过一主八从。1-2分钟左右,所有pod处于
running ready状态
3.缩扩容
修改
OpenGaussCluster.spec.standby.replicas
字段即可完成缩扩容,用kubectel edit
修改,或者重新kubectl apply -f <file-name>.yaml
均可注意,当前不支持从0扩容或者缩容到0
4.升级
修改
OpenGaussCluster.spec.image
字段即可完成,注意目前只保证enmotech/opengauss:2.1.0及更高版本兼容,这里演示enmotech/opengauss:2.1.0到enmotech/opengauss:latest的升级测试5.pod迁移
使用OpenGaussPodMigration这一CRD实现迁移,迁移需要部署webhook