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¶
- LM has been installed and the License Key has been successfully loaded (Enterprise only)
Create clusters¶
The following example shows how to create a NebulaGraph cluster by creating a cluster named nebula
.
-
Create a namespace, for example,
nebula
. If not specified, thedefault
namespace is used.kubectl create namespace nebula
-
Create a Secret for pulling the NebulaGraph Enterprise image from a private repository.
Note
Skip this step if you are using NebulaGraph Community Edition.
kubectl -n <nebula> create secret docker-registry <image-pull-secret> \ --docker-server=DOCKER_REGISTRY_SERVER \ --docker-username=DOCKER_USER \ --docker-password=DOCKER_PASSWORD
<nebula>
: The namespace where this Secret will be stored.<image-pull-secret>
: Specify the name of the Secret.DOCKER_REGISTRY_SERVER
: Specify the server address of the private repository from which the image will be pulled, such asreg.example-inc.com
.DOCKER_USER
: The username for the image repository.DOCKER_PASSWORD
: The password for the image repository.
-
Create a file named
apps_v1alpha1_nebulacluster.yaml
.-
For a NebulaGraph Community cluster
Create a file named
apps_v1alpha1_nebulacluster.yaml
. For the file content, see the sample configuration.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.image
vesoft/nebula-graphd
The container image of the Graphd service. spec.graphd.version
v3.5.0
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.image
vesoft/nebula-metad
The container image of the Metad service. spec.metad.version
v3.5.0
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.image
vesoft/nebula-storaged
The container image of the Storaged service. spec.storaged.version
v3.5.0
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.agent
{}
Configuration of the Agent service. This is used for backup and recovery as well as log cleanup functions. If you do not customize this configuration, the default configuration will be used. 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.logRotate
- Log rotation configuration. For more information, see Manage cluster logs. spec.enablePVReclaim
false
Define whether to automatically delete PVCs and release data after deleting the cluster. For more information, see Reclaim PVs.
-
For a NebulaGraph Enterprise cluster
Enterpriseonly
Make sure that you have access to NebulaGraph Enterprise Edition images before pulling the image.
Create a file named
apps_v1alpha1_nebulacluster.yaml
. Contact our sales team to get a complete NebulaGraph Enterprise Edition cluster YAML example. You must customize and modify the following parameters, and other parameters can be changed as needed.spec.metad.licenseManagerURL
spec.<graphd|metad|storaged>.image
spec.imagePullSecrets
The parameters only for NebulaGraph Enterprise Edition are described as follows:
Parameter Default value Description spec.metad.licenseManagerURL
- Configure the URL that points to the LM, which consists of the access address and port number (default port 9119
) of the LM. For example,192.168.8.100:9119
. You must configure this parameter in order to obtain the license information; otherwise, the enterprise edition cluster cannot be used.spec.storaged.enableAutoBalance
false
Specifies whether to enable automatic data balancing. For more information, see Balance storage data after scaling out. spec.enableBR
false
Specifies whether to enable the BR tool. For more information, see Backup and restore. spec.imagePullSecrets
- Specifies the Secret for pulling the NebulaGraph Enterprise service images from a private repository.
-
-
Create a NebulaGraph cluster.
kubectl create -f apps_v1alpha1_nebulacluster.yaml
Output:
nebulacluster.apps.nebula-graph.io/nebula created
-
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:
-
Change the value of the
storaged.replicas
from3
to5
inapps_v1alpha1_nebulacluster.yaml
.storaged: resources: requests: cpu: "500m" memory: "500Mi" limits: cpu: "1" memory: "1Gi" replicas: 5 image: vesoft/nebula-storaged version: v3.5.0 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
-
Run the following command to update the NebulaGraph cluster CR.
kubectl apply -f apps_v1alpha1_nebulacluster.yaml
-
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