Skip to content

Deploy NebulaGraph clusters with Kubectl

Legacy version compatibility

The 1.x version NebulaGraph Operator is not compatible with NebulaGraph of version below v3.x.

Prerequisites

  • You have prepared the license file for NebulaGraph Enterprise Edition clusters.

    Enterpriseonly

    The license file is required only when creating a NebulaGraph Enterprise Edition cluster.

Create clusters

The following example shows how to create a NebulaGraph cluster by creating a cluster named nebula.

  1. Create a file named apps_v1alpha1_nebulacluster.yaml.

    • The file contents for a NebulaGraph Community cluster are as follows:

      apiVersion: apps.nebula-graph.io/v1alpha1
      kind: NebulaCluster
      metadata:
        name: nebula
      spec:
        graphd:
          resources:
            requests:
              cpu: "500m"
              memory: "500Mi"
            limits:
              cpu: "1"
              memory: "1Gi"
          replicas: 1
          image: vesoft/nebula-graphd
          version: v3.4.1
          logVolumeClaim:
            resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
        metad:
          resources:
            requests:
              cpu: "500m"
              memory: "500Mi"
            limits:
              cpu: "1"
              memory: "1Gi"
          replicas: 1
          image: vesoft/nebula-metad
          version: v3.4.1
          logVolumeClaim:
            resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
          dataVolumeClaim:
            resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
        storaged:
          resources:
            requests:
              cpu: "500m"
              memory: "500Mi"
            limits:
              cpu: "1"
              memory: "1Gi"
          replicas: 1
          image: vesoft/nebula-storaged
          version: v3.4.1
          logVolumeClaim:
            resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
          dataVolumeClaims:  // You can mount multiple disks starting from NebulaGraph Operator 1.3.0.
          - resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
          - resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
          enableAutoBalance: true
        reference:
          name: statefulsets.apps
          version: v1
        schedulerName: default-scheduler
        nodeSelector:
          nebula: cloud
        imagePullPolicy: Always
        unsatisfiableAction: ScheduleAnyway    
      
    • The file contents for a NebulaGraph Enterprise cluster are as follows:

      # Contact our sales team to get a complete NebulaGraph Enterprise Edition cluster YAML example.
      
      apiVersion: apps.nebula-graph.io/v1alpha1
      kind: NebulaCluster
      metadata:
        annotations:
          nebula-graph.io/owner: test
        name: nebula
      spec:
        graphd:
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /status
              port: 19669
              scheme: HTTP
            initialDelaySeconds: 40
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          image: reg.vesoft-inc.com/vesoft-ent/nebula-graphd
          logVolumeClaim:
            resources:
              requests:
                storage: 2Gi
            storageClassName: fast-disks
          replicas: 1
          resources:
            limits:
              cpu: "1"
              memory: 1Gi
            requests:
              cpu: 500m
              memory: 500Mi
          version: v3.4.1
        imagePullPolicy: Always
        imagePullSecrets:
        - name: vesoft
        metad:
          license:
            secretName: nebula-license
            licenseKey: nebula.license
        ...       
      

    The parameters in the file are described as follows:

    Parameter Default value Description
    metadata.name - The name of the created NebulaGraph cluster.
    spec.graphd.replicas 1 The numeric value of replicas of the Graphd service.
    spec.graphd.images vesoft/nebula-graphd The container image of the Graphd service.
    spec.graphd.version v3.4.1 The version of the Graphd service.
    spec.graphd.service - The Service configurations for the Graphd service.
    spec.graphd.logVolumeClaim.storageClassName - The log disk storage configurations for the Graphd service.
    spec.metad.replicas 1 The numeric value of replicas of the Metad service.
    spec.metad.images vesoft/nebula-metad The container image of the Metad service.
    spec.metad.version v3.4.1 The version of the Metad service.
    spec.metad.dataVolumeClaim.storageClassName - The data disk storage configurations for the Metad service.
    spec.metad.logVolumeClaim.storageClassName - The log disk storage configurations for the Metad service.
    spec.storaged.replicas 3 The numeric value of replicas of the Storaged service.
    spec.storaged.images vesoft/nebula-storaged The container image of the Storaged service.
    spec.storaged.version v3.4.1 The version of the Storaged service.
    spec.storaged.dataVolumeClaims.resources.requests.storage - Data disk storage size for the Storaged service. You can specify multiple data disks to store data. When multiple disks are specified, the storage path is /usr/local/nebula/data1, /usr/local/nebula/data2, etc.
    spec.storaged.dataVolumeClaims.resources.storageClassName - The data disk storage configurations for Storaged. If not specified, the global storage parameter is applied.
    spec.storaged.logVolumeClaim.storageClassName - The log disk storage configurations for the Storaged service.
    spec.storaged.enableAutoBalance true Whether to balance data automatically.
    spec.reference.name - The name of the dependent controller.
    spec.schedulerName - The scheduler name.
    spec.imagePullPolicy The image policy to pull the NebulaGraph image. For details, see Image pull policy. The image pull policy in Kubernetes.
    spec.metad.license - The configuration of the license for creating a NebulaGraph Enterprise Edition cluster.

    Enterpriseonly

    Make sure that you have access to NebulaGraph Enterprise Edition images before pulling the image. For details, contact our sales team (inqury@vesoft.com)

  2. Configure the license for the Enterprise Edition cluster.

    Enterpriseonly

    • This step is required only for creating a NebulaGraph Grpah Enterprise Edition cluster.
    • Ignore this step if you are creating a NebulaGraph Community Edition cluster.
    kubectl create secret generic nebula-license --from-file=nebula.license
    

    To check the details of the license, run the following command:

    kubectl get secrets nebula-license -o yaml
    

  3. Create a NebulaGraph cluster.

    kubectl create -f apps_v1alpha1_nebulacluster.yaml
    

    Output:

    nebulacluster.apps.nebula-graph.io/nebula created
    
  4. Check the status of the NebulaGraph cluster.

    kubectl get nebulaclusters.apps.nebula-graph.io nebula
    

    Output:

    NAME     GRAPHD-DESIRED   GRAPHD-READY   METAD-DESIRED   METAD-READY   STORAGED-DESIRED   STORAGED-READY   AGE
    nebula   1                1              1               1             3                  3                86s
    

Scaling clusters

  • The cluster scaling feature is for NebulaGraph Enterprise Edition only.
  • Scaling a NebulaGraph cluster for Enterprise Edition is supported only with NebulaGraph Operator version 1.1.0 or later.

You can modify the value of replicas in apps_v1alpha1_nebulacluster.yaml to scale a NebulaGraph cluster.

Scale out clusters

The following shows how to scale out a NebulaGraph cluster by changing the number of Storage services to 5:

  1. Change the value of the storaged.replicas from 3 to 5 in apps_v1alpha1_nebulacluster.yaml.

      storaged:
        resources:
          requests:
            cpu: "500m"
            memory: "500Mi"
          limits:
            cpu: "1"
            memory: "1Gi"
        replicas: 5
        image: vesoft/nebula-storaged
        version: v3.4.1
        dataVolumeClaims:
        - resources:
            requests:
              storage: 2Gi
          storageClassName: fast-disks
        - resources:
            requests:
              storage: 2Gi
          storageClassName: fast-disks
        logVolumeClaim:
          resources:
            requests:
              storage: 2Gi
          storageClassName: fast-disks
      reference:
        name: statefulsets.apps
        version: v1
      schedulerName: default-scheduler
    
  2. Run the following command to update the NebulaGraph cluster CR.

    kubectl apply -f apps_v1alpha1_nebulacluster.yaml
    
  3. Check the number of Storage services.

    kubectl  get pods -l app.kubernetes.io/cluster=nebula
    

    Output:

    NAME                READY   STATUS    RESTARTS   AGE
    nebula-graphd-0     1/1     Running   0          2m
    nebula-metad-0      1/1     Running   0          2m
    nebula-storaged-0   1/1     Running   0          2m
    nebula-storaged-1   1/1     Running   0          2m
    nebula-storaged-2   1/1     Running   0          2m
    nebula-storaged-3   1/1     Running   0          5m
    nebula-storaged-4   1/1     Running   0          5m
    

    As you can see above, the number of Storage services is scaled up to 5.

Scale in clusters

The principle of scaling in a cluster is the same as scaling out a cluster. You scale in a cluster if the numeric value of the replicas in apps_v1alpha1_nebulacluster.yaml is changed smaller than the current number. For more information, see the Scale out clusters section above.

Caution

NebulaGraph Operator currently only supports scaling Graph and Storage services and does not support scale Meta services.

Delete clusters

Run the following command to delete a NebulaGraph cluster with Kubectl:

kubectl delete -f apps_v1alpha1_nebulacluster.yaml

What's next

Connect to NebulaGraph databases


Last update: February 19, 2024