快速创建集群
本文将介绍创建 悦数图数据库 集群的两种方式:
- 使用 Helm 创建 悦数图数据库 集群
- 使用 Kubectl 创建 悦数图数据库 集群
前提条件
使用 Helm 创建 悦数图数据库 集群
:::compatibility 历史版本兼容性
1.x 版本的 NebulaGraph Operator 不兼容 3.x 以下版本的 悦数图数据库 。
:::
- 添加 NebulaGraph Operator Helm 仓库。
helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts
- 更新 Helm 仓库,拉取最新仓库资源。
helm repo update
- 为安装集群所需的配置参数设置环境变量。
export NEBULA_CLUSTER_NAME=nebula # <ProductName /> 集群的名字。
export NEBULA_CLUSTER_NAMESPACE=nebula # <ProductName /> 集群所处的命名空间的名字。
export STORAGE_CLASS_NAME=fast-disks # <ProductName /> 集群的 StorageClass。
- 为 悦数图数据库 集群创建命名空间(如已创建,略过此步)。
kubectl create namespace "${NEBULA_CLUSTER_NAMESPACE}"
- 创建 悦数图数据库 集群。
helm install "${NEBULA_CLUSTER_NAME}" nebula-operator/nebula-cluster \
--set nameOverride="${NEBULA_CLUSTER_NAME}" \
--set nebula.storageClassName="${STORAGE_CLASS_NAME}" \
# 指定 <ProductName /> 集群的版本。
--set nebula.version=v<Var name="nebula_release" /> \
# 指定集群 chart 的版本,不指定则默认安装最新版本 chart。
# 执行 helm search repo - l nebula-operator/nebula-cluster 命令可查看所有 chart 版本。
--version=1.8.0 \
--namespace="${NEBULA_CLUSTER_NAMESPACE}" \
使用 Kubectl 创建 悦数图数据库 集群
:::compatibility 历史版本兼容性
1.x 版本的 NebulaGraph Operator 不兼容 3.x 以下版本的 悦数图数据库 。
:::
下面以创建名为nebula的集群为例,说明如何部署 悦数图数据库 集群。
- 创建命名空间,例如
nebula。如果不指定命名空间,默认使用default命名空间。
kubectl create namespace nebula
- 创建集群配置文件,例如
nebulacluster.yaml。
??? info "展开查看集群的示例配置"
apiVersion: apps.nebula-graph.io/v1alpha1
kind: NebulaCluster
metadata:
name: nebula
namespace: default
spec:
topologySpreadConstraints:
- topologyKey: "kubernetes.io/hostname"
whenUnsatisfiable: "ScheduleAnyway"
graphd:
# Graph 服务的容器镜像。
image: vesoft/nebula-graphd
logVolumeClaim:
resources:
requests:
storage: 2Gi
# 用于存储 Graph 服务的日志的存储类名称。
storageClassName: local-sc
replicas: 1
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
version: v<Var name="nebula_release" />
imagePullPolicy: Always
metad:
# Meta 服务的容器镜像。
image: vesoft/nebula-metad
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: local-sc
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: local-sc
replicas: 1
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
version: v<Var name="nebula_release" />
reference:
name: statefulsets.apps
version: v1
schedulerName: default-scheduler
storaged:
# Storage 服务的容器镜像。
image: vesoft/nebula-storaged
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: local-sc
dataVolumeClaims:
- resources:
requests:
storage: 2Gi
storageClassName: local-sc
replicas: 1
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
version: v<Var name="nebula_release" />
关于其它参数的详情,请参考创建 悦数图数据库 集群。
- 创建 悦数图数据库 集群。
kubectl create -f nebulacluster.yaml
返回:
nebulacluster.apps.nebula-graph.io/nebula created
- 查看 悦数图数据库 集群状态。
kubectl get nc nebula
返回:
NAME READY GRAPHD-DESIRED GRAPHD-READY METAD-DESIRED METAD-READY STORAGED-DESIRED STORAGED-READY AGE
nebula True 1 1 1 1 1 1 86s