Deploy Nebula Graph clusters with Kubectl¶
Prerequisites¶
Create clusters¶
The following example shows how to create a Nebula Graph cluster by creating a cluster named nebula
.
-
Create a file named
apps_v1alpha1_nebulacluster.yaml
.The file contents 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: v2.5.1 service: type: NodePort externalTrafficPolicy: Local storageClaim: resources: requests: storage: 2Gi storageClassName: gp2 metad: resources: requests: cpu: "500m" memory: "500Mi" limits: cpu: "1" memory: "1Gi" replicas: 1 image: vesoft/nebula-metad version: v2.5.1 storageClaim: resources: requests: storage: 2Gi storageClassName: gp2 storaged: resources: requests: cpu: "500m" memory: "500Mi" limits: cpu: "1" memory: "1Gi" replicas: 3 image: vesoft/nebula-storaged version: v2.5.1 storageClaim: resources: requests: storage: 2Gi storageClassName: gp2 reference: name: statefulsets.apps version: v1 schedulerName: default-scheduler imagePullPolicy: IfNotPresent
The parameters in the file are described as follows:
Parameter Default value Description metadata.name
- The name of the created Nebula Graph 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
v2.5.1
The version of the Graphd service. spec.graphd.service
- The Service configurations for the Graphd service. spec.graphd.storageClaim
- The 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
v2.5.1
The version of the Metad service. spec.metad.storageClaim
- The 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
v2.5.1
The version of the Storaged service. spec.storaged.storageClaim
- The storage configurations for the Storaged service. spec.reference.name
- The name of the dependent controller. spec.schedulerName
- The scheduler name. spec.imagePullPolicy
The image policy to pull the Nebula Graph image. For details, see Image pull policy. The image pull policy in Kubernetes. -
Create a Nebula Graph cluster.
kubectl create -f apps_v1alpha1_nebulacluster.yaml
Output:
nebulacluster.apps.nebula-graph.io/nebula created
-
Check the status of the Nebula Graph 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-cluster 1 1 1 1 3 3 31h
Scaling clusters¶
You can modify the value of replicas
in apps_v1alpha1_nebulacluster.yaml
to scale a Nebula Graph cluster.
Scale out clusters¶
The following shows how to scale out a Nebula Graph cluster by changing the number of Storage services to 5:
-
Change the value of the
storaged.replicas
inapps_v1alpha1_nebulacluster.yaml
from3
to5
.storaged: resources: requests: cpu: "1" memory: "1Gi" limits: cpu: "1" memory: "1Gi" replicas: 5 image: vesoft/nebula-storaged version: v2.5.1 storageClaim: resources: requests: storage: 2Gi storageClassName: fast-disks
-
Run the following command to update the Nebula Graph 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
Nebula 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 Nebula Graph cluster with Kubectl:
kubectl delete -f apps_v1alpha1_nebulacluster.yaml
What's next¶
Connect to Nebula Graph databases