大家好,我是吃萝卜不吐葡萄皮,可以叫我皮哥。
这几年国产数据库 OceanBase 非常火,身边好多朋友都在提,我也充满兴趣,下班抽空学习一段时间了,想通过笔记的形式分享一下学习进程,部分内容是官方资料的摘录或整合,希望方便更多朋友学习与参考,一起交流。
第6篇学习笔记。
背景信息
ob-operator 与其他 operator 一样,旨在让 OceanBase 以容器的方式,无缝运行在 Kubernetes 集群上。 ob-operator 现已支持 OceanBase 集群的创建、删除,完整的节点生命周期管理、ob-proxy 管理,后续会支持租户管理、多 Kubernetes 集群等功能。 您可按照以下步骤通过 ob-operator 来部署 OceanBase 数据库。
部署 CRD
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/master/deploy/crd.yaml
部署 ob-operator
使用默认配置部署 ob-operator
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/master/deploy/operator.yaml
自定义部署 ob-operator
您也可以根据您的配置修改 operator.yaml
。 例如在 operator.yaml 中添加启动参数 --cluster-name
,含义为 ob-operator 只处理 cluster
值与自身启动参数 --cluster-name
的值相同的 CRD。
注意
--cluster-name
的值需要与 obcluster 配置中的cluster
配置一致。 参考以下部分配置文件进行修改:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
control-plane: controller-manager
name: ob-operator-controller-manager
namespace: oceanbase-system
spec:
replicas: 1
selector:
matchLabels:
control-plane: controller-manager
template:
metadata:
labels:
control-plane: controller-manager
spec:
containers:
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
- --cluster-name=cn
command:
- /manager
image: ob-operator:latest
imagePullPolicy: Always
name: manager
配置 Kubernetes 节点 label
您需将 Kubernetes 节点配置 label,label 需要与 obcluster.yaml 中的 nodeSelector
配置相匹配。ob-operator 会将 Pod 调度到具有相应 label 的节点上。 推荐配置 label 的 key 为 topology.kubernetes.io/zone
。不同 Zone 推荐配置不同的 label 以做容灾。
kubectl label node nodename topology.kubernetes.io/zone=zonename
kubectl label node ${node_name} topology.kubernetes.io/zone=${zone_name}
部署 local-path-provisioner
ob-operator 默认配置中使用了 local-path-provisioner,需要提前准