跳转至

快速创建集群

本文将介绍创建 NebulaGraph 集群的两种方式:

  • 使用 Helm 创建 NebulaGraph 集群
  • 使用 Kubectl 创建 NebulaGraph 集群

前提条件

使用 Helm 创建 NebulaGraph 集群

历史版本兼容性

1.x 版本的 NebulaGraph Operator 不兼容 3.x 以下版本的 NebulaGraph 。

  1. 添加 NebulaGraph Operator Helm 仓库。

    helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts
    
  2. 更新 Helm 仓库,拉取最新仓库资源。

    helm repo update
    
  3. 为安装集群所需的配置参数设置环境变量。

    export NEBULA_CLUSTER_NAME=nebula         # NebulaGraph 集群的名字。
    export NEBULA_CLUSTER_NAMESPACE=nebula    # NebulaGraph 集群所处的命名空间的名字。
    export STORAGE_CLASS_NAME=fast-disks             # NebulaGraph 集群的 StorageClass。
    
  4. 为 NebulaGraph 集群创建命名空间(如已创建,略过此步)。

    kubectl create namespace "${NEBULA_CLUSTER_NAMESPACE}"
    
  5. 创建 NebulaGraph 集群。

    helm install "${NEBULA_CLUSTER_NAME}" nebula-operator/nebula-cluster \
        --set nameOverride="${NEBULA_CLUSTER_NAME}" \
        --set nebula.storageClassName="${STORAGE_CLASS_NAME}" \
        # 指定 NebulaGraph 集群的版本。
        --set nebula.version=v3.6.0 \
        # 指定集群 chart 的版本,不指定则默认安装最新版本 chart。
        # 执行 helm search repo - l nebula-operator/nebula-cluster 命令可查看所有 chart 版本。
        --version=1.8.0 \
        --namespace="${NEBULA_CLUSTER_NAMESPACE}" \      
    

使用 Kubectl 创建 NebulaGraph 集群

历史版本兼容性

1.x 版本的 NebulaGraph Operator 不兼容 3.x 以下版本的 NebulaGraph 。

下面以创建名为nebula的集群为例,说明如何部署 NebulaGraph 集群。

  1. 创建命名空间,例如nebula。如果不指定命名空间,默认使用default命名空间。

    kubectl create namespace nebula
    
  2. 创建集群配置文件,例如nebulacluster.yaml

    展开查看集群的示例配置
    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: v3.6.0
      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: v3.6.0
      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: v3.6.0
    

    关于其它参数的详情,请参考创建 NebulaGraph 集群

  3. 创建 NebulaGraph 集群。

    kubectl create -f nebulacluster.yaml
    

    返回:

    nebulacluster.apps.nebula-graph.io/nebula created
    
  4. 查看 NebulaGraph 集群状态。

    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
    

后续操作

连接集群


最后更新: April 19, 2024