Skip to content
Open

Nebula #1265

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3270982
k8s deployment for neo4j
jeanyu-habana Feb 4, 2025
0011a66
updated README and added 2 scripts
jeanyu-habana Feb 4, 2025
fee5ffe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2025
e7868fd
fixed hardcoded NS
jeanyu-habana Feb 5, 2025
296f3ed
Merge branch 'main' into neo4jk8s
jeanyu-habana Feb 5, 2025
5ceb03b
Merge remote-tracking branch 'origin/main' into neo4jk8s
jeanyu-habana Feb 5, 2025
8701aab
Merge remote-tracking branch 'origin/neo4jk8s' into neo4jk8s
jeanyu-habana Feb 5, 2025
fb7658f
removed cluster specific configs
jeanyu-habana Feb 5, 2025
9c2ba3b
Merge branch 'main' into neo4jk8s
jeanyu-habana Feb 5, 2025
aaa6d95
Merge remote-tracking branch 'origin/main' into neo4jk8s
jeanyu-habana Feb 5, 2025
4076e21
rename
jeanyu-habana Feb 5, 2025
d3b7003
Merge remote-tracking branch 'origin/neo4jk8s' into neo4jk8s
jeanyu-habana Feb 5, 2025
a20e914
Merge branch 'main' into neo4jk8s
jeanyu-habana Feb 6, 2025
67b2da9
Merge remote-tracking branch 'origin/main' into neo4jk8s
jeanyu-habana Feb 6, 2025
a00e886
Merge remote-tracking branch 'origin/neo4jk8s' into neo4jk8s
jeanyu-habana Feb 6, 2025
23f1ab4
use kubernetes instead of k8s in the path
jeanyu-habana Feb 6, 2025
ea733b3
NebulaGraph k8s deploy
jeanyu-habana Feb 6, 2025
62a70d8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 6, 2025
cf0e0c1
k8s deployment for neo4j
jeanyu-habana Feb 4, 2025
55942e5
updated README and added 2 scripts
jeanyu-habana Feb 4, 2025
320d11e
fixed hardcoded NS
jeanyu-habana Feb 5, 2025
0a45ece
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2025
b097d2b
removed cluster specific configs
jeanyu-habana Feb 5, 2025
c56a3c5
rename
jeanyu-habana Feb 5, 2025
f35edea
use kubernetes instead of k8s in the path
jeanyu-habana Feb 6, 2025
2f01606
NebulaGraph k8s deploy
jeanyu-habana Feb 6, 2025
079e1ec
Merge branch 'main' into nebula
jeanyu-habana Feb 7, 2025
af60a1c
Merge remote-tracking branch 'origin/main' into nebula
jeanyu-habana Feb 7, 2025
109451c
rebase
jeanyu-habana Feb 7, 2025
c4ff066
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2025
3113700
rm neo4j k8s files
jeanyu-habana Feb 7, 2025
413fbc6
resolve conflict
jeanyu-habana Feb 7, 2025
16b9569
fixed yaml error
jeanyu-habana Feb 8, 2025
e0e408d
fixed README
jeanyu-habana Feb 8, 2025
cf278b0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 8, 2025
1cae41e
added instructions/examples for database conenction
jeanyu-habana Feb 8, 2025
e7673c9
Merge branch 'main' into nebula
jeanyu-habana Feb 8, 2025
d84ed29
added info for database connection
jeanyu-habana Feb 8, 2025
c56f9b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 8, 2025
9be528a
fixed README
jeanyu-habana Feb 9, 2025
af58635
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 9, 2025
0876d6e
Merge branch 'main' into nebula
jeanyu-habana Feb 11, 2025
f957a4d
fixed README
jeanyu-habana Feb 11, 2025
332ac41
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 11, 2025
916fbf2
Merge branch 'main' into nebula
lvliang-intel Feb 13, 2025
a22e11f
added test script for nebulagraph component
jeanyu-habana Feb 14, 2025
bc47599
Merge branch 'main' into nebula
jeanyu-habana Feb 14, 2025
aa9f52b
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 14, 2025
7df8202
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 14, 2025
23c3996
fixed path in the test script
jeanyu-habana Feb 14, 2025
4c5a0a8
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 14, 2025
36ce2ad
fixed error in test script
jeanyu-habana Feb 14, 2025
3fb2f89
set storageClass
jeanyu-habana Feb 14, 2025
1edb31f
added wait in the script
jeanyu-habana Feb 14, 2025
6286026
fixed namespace
jeanyu-habana Feb 14, 2025
03530ff
recycle nebula-console pod
jeanyu-habana Feb 14, 2025
0ff8e39
fixed cluster-ip
jeanyu-habana Feb 14, 2025
7a640b1
fixed ns
jeanyu-habana Feb 14, 2025
82df762
fixed test script
jeanyu-habana Feb 18, 2025
fe04811
fixed script
jeanyu-habana Feb 18, 2025
b167636
Merge branch 'main' into nebula
jeanyu-habana Feb 18, 2025
c0215e3
Merge branch 'main' into nebula
jeanyu-habana Feb 18, 2025
4702499
test script update
jeanyu-habana Feb 18, 2025
7fbc25a
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 18, 2025
e79a742
more work for test script
jeanyu-habana Feb 18, 2025
442e659
Merge branch 'main' into nebula
jeanyu-habana Feb 19, 2025
afbb45f
Merge branch 'main' into nebula
xiguiw Feb 25, 2025
cb1535e
updates to address review comments
jeanyu-habana Feb 26, 2025
ec70edb
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 26, 2025
6b7e24f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 26, 2025
3dcba86
updated README with storageClass info
jeanyu-habana Feb 27, 2025
aa4c672
Merge remote-tracking branch 'origin/nebula' into nebula
jeanyu-habana Feb 27, 2025
20480e4
Merge branch 'main' into nebula
jeanyu-habana Mar 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions comps/third_parties/nebula/deployment/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Deploy NebulaGraph cluster (with Kubectl)

## 1. Install cert-manager

```bash
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/<release_version>/cert-manager.yaml
```

## 2. Install Nebula Operator

```bash
helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts
helm repo update
helm install nebula-operator nebula-operator/nebula-operator --namespace=<namespace_name> --version=1.1.0
```

## 3. Install and start NebulaGraph cluster

Choose between the Enterprise and Community configuration files base on your license. Create a StorageClass or use an existing one in the k8s cluster. Edit the config with the proper storageClassName and run the command below:

```bash
kubectl create -f enterprise_edition.yaml
or
kubectl create -f community_edition.yaml
```

## 4. Connect to NebulaGraph databases

Once you've set up a NebulaGraph cluster using Nebula Operator on Kubernetes, you can connect to NebulaGraph databases both from inside the cluster and from external sources.

### 4.1. Connect to NebulaGraph databases from within a NebulaGraph cluster

Run the following command to check the IP of the Service:

```bash
$ kubectl get service -l app.kubernetes.io/cluster=<nebula> #<nebula> is a variable value. Replace it with the desired name.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should be? Replace it by what value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be any desired name.

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nebula-graphd-svc ClusterIP 10.98.213.34 <none> 9669/TCP,19669/TCP,19670/TCP 23h
nebula-metad-headless ClusterIP None <none> 9559/TCP,19559/TCP,19560/TCP 23h
nebula-storaged-headless ClusterIP None <none> 9779/TCP,19779/TCP,19780/TCP,9778/TCP
```

Run the following commands to get the cluster ip and service port of the service:

```bash
cluster_ip=$(kubectl get service | grep nebula-graphd-svc | awk '/nebula-graphd-svc/ {print $3}')
service_port=$(kubectl get service | grep nebula-graphd-svc | awk '{print $5}' | cut -d',' -f1 | cut -d'/' -f1)
```

Run the following command to connect to the NebulaGraph database using the cluster ip and service port the <cluster-name>-graphd-svc service above:

```bash
kubectl run -ti --image vesoft/nebula-console --restart=Never -- <nebula_console_name> -addr <cluster_ip> -port <service_port> -u <username> -p <password>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be better to give users direct bash commands to get <cluster_ip>, <service_port> .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the bash commands to find <cluster_ip>, <service_port> in README.

```

For example:

```bash
kubectl run -ti --image vesoft/nebula-console --restart=Never -- nebula-console -addr 10.98.213.34 -port 9669 -u root -p vesoft

```

A successful connection to the database is indicated if the following is returned:

If you don't see a command prompt, try pressing enter.

(root@nebula) [(none)]>

### 4.2. Connect to NebulaGraph databases from outside a NebulaGraph cluster

Refer to the [NebulaGraph Database Manual](https://docs.nebula-graph.io/3.1.3/nebula-operator/4.connect-to-nebula-graph-service/) for more information.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps.nebula-graph.io/v1alpha1
kind: NebulaCluster
metadata:
name: nebula
#namespace: nebula-operator-system
spec:
graphd:
resources:
requests:
cpu: "500m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 1
image: vesoft/nebula-graphd:v3.8.0
service:
type: NodePort
externalTrafficPolicy: Local
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: "${STORAGE_CLASS_NAME}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nebula requires k8s to have a valid storage class, we'd better to say it clearly in README. Also if we follow the README strictly, this ${STORAGE_CLASS_NAME} dereference could cause the kubectl create -f enterprise_edition.yaml fail due to the mismatch of storageClassName. Does nebula operator support not setting specific storageClassName?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a storage class is required. The current readme me already mentioned that the storageClassName in the yaml file. I have add the following in the README to address the issue:
"Create a StorageClass or use an existing one in the k8s cluster. Edit the config with the proper storageClassName and run the command below".

metad:
resources:
requests:
cpu: "500m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 1
image: vesoft/nebula-metad:v3.8.0
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: "${STORAGE_CLASS_NAME}"
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: "${STORAGE_CLASS_NAME}"
storaged:
resources:
requests:
cpu: "500m"
memory: "500Mi"
limits:
cpu: "1"
memory: "1Gi"
replicas: 3
image: vesoft/nebula-storaged:v3.8.0
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: "${STORAGE_CLASS_NAME}"
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: "${STORAGE_CLASS_NAME}"
reference:
name: statefulsets.apps
version: v1
schedulerName: default-scheduler
imagePullPolicy: Always
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Copyright (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps.nebula-graph.io/v1alpha1
kind: NebulaCluster
metadata:
annotations:
nebula-graph.io/owner: test
name: nebula
spec:
enablePVReclaim: true
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.1.3
imagePullPolicy: Always
imagePullSecrets:
- name: vesoft
metad:
license:
secretName: nebula-license
licenseKey: nebula.license
readinessProbe:
failureThreshold: 3
httpGet:
path: /status
port: 19559
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
image: reg.vesoft-inc.com/vesoft-ent/nebula-metad
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: fast-disks
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: fast-disks
replicas: 1
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
version: v3.1.3
reference:
name: statefulsets.apps
version: v1
schedulerName: default-scheduler
storaged:
readinessProbe:
failureThreshold: 3
httpGet:
path: /status
port: 19779
scheme: HTTP
initialDelaySeconds: 40
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
image: reg.vesoft-inc.com/vesoft-ent/nebula-storaged
logVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: fast-disks
dataVolumeClaim:
resources:
requests:
storage: 2Gi
storageClassName: fast-disks
replicas: 3
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
version: v3.1.3
enableAutoBalance: true
2 changes: 2 additions & 0 deletions comps/third_parties/nebula/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
118 changes: 118 additions & 0 deletions tests/third_parties/test_third_parties_nebula.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/bin/bash
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

set +e
set -x

WORKPATH=$(dirname "$PWD")
LOG_PATH="$WORKPATH/tests"
export STORAGE_CLASS_NAME=$(kubectl get storageclass -o jsonpath='{.items[0].metadata.name}')

if [ -n "$STORAGE_CLASS_NAME" ]; then
echo "Using StorageClass: $STORAGE_CLASS_NAME"
else
echo "No StorageClass found."
exit 1
fi

function deploy_and_start_service() {
stop_service
sleep 60s

cd $WORKPATH/comps/third_parties/nebula/deployment/kubernetes
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.9.1/cert-manager.yaml
sleep 60s

kubectl create namespace nebula-operator-system
helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts
helm repo update
helm install nebula-operator nebula-operator/nebula-operator --namespace=nebula-operator-system --version=1.1.0
sleep 60s

#kubectl create -f community_edition.yaml
envsubst < community_edition.yaml | kubectl create -f -
sleep 120s
}

function validate_database() {
cluster_ip=$(kubectl get service | grep nebula-graphd-svc | awk '/nebula-graphd-svc/ {print $3}')

if [ -n "$cluster_ip" ]; then
echo "Using cluster_ip: $cluster_ip"
else
echo "No cluster_ip found."
exit 1
fi

kubectl delete pod nebula-console --ignore-not-found
# test create space
echo "[ test create ] creating space.."
query="CREATE SPACE my_space(partition_num=10, replica_factor=1, vid_type=FIXED_STRING(32)); USE my_space; CREATE TAG person(name string, age int);"

create_response=$(kubectl run -ti --rm --image vesoft/nebula-console --restart=Never -- nebula-console -addr "$cluster_ip" -port 9669 -u root -p vesoft -e "$query" 2>&1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can other microservices access Nebula Database? Are there any software APIs or endpoints available? Using Nebula-Console is not good way for this purpose.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can other microservices access Nebula Database? Are there any software APIs or endpoints available? Using Nebula-Console is not good way for this purpose.

@jeanyu-habana

Could you resolve this?


if [[ $? -eq 0 ]]; then
echo "[ test create ] create space succeed"
echo $create_response >> ${LOG_PATH}/nebulagraph_create_space.log
else
echo "[ test create ] create space failed"
echo $create_response >> ${LOG_PATH}/nebulagraph_create_space.log
exit 1
fi

sleep 30s

# test insert data
echo "[ test insert ] inserting data.."
query="USE my_space; INSERT VERTEX person(name, age) VALUES 'person1':('Alice', 30); INSERT VERTEX person(name, age) VALUES 'person2':('Bob', 25);"

insert_response=$(kubectl run -ti --rm --image vesoft/nebula-console --restart=Never -- nebula-console -addr "$cluster_ip" -port 9669 -u root -p vesoft -e "$query" 2>&1)

if [[ $? -eq 0 ]]; then
echo "[ test insert ] insert data succeed"
echo $insert_response >> ${LOG_PATH}/nebulagraph_insert_data.log
else
echo "[ test insert ] insert data failed"
echo $insert_response >> ${LOG_PATH}/nebulagraph_insert_data.log
exit 1
fi

sleep 30s

# test search data
echo "[ test search ] searching data.."
query="USE my_space; MATCH (p:person) RETURN p;"

search_response=$(kubectl run -ti --rm --image vesoft/nebula-console --restart=Never -- nebula-console -addr "$cluster_ip" -port 9669 -u root -p vesoft -e "$query" 2>&1)

if [[ $? -eq 0 ]]; then
echo "[ test search ] search data succeed"
echo $search_response >> ${LOG_PATH}/nebulagraph_search_data.log
else
echo "[ test search ] search data failed"
echo $search_response >> ${LOG_PATH}/nebulagraph_search_data.log
exit 1
fi
}

function stop_service() {
cd $WORKPATH/comps/third_parties/nebula/deployment/kubernetes
kubectl delete pod nebula-console --ignore-not-found
kubectl delete -f community_edition.yaml
helm uninstall nebula-operator --namespace nebula-operator-system
kubectl delete crd nebulaclusters.apps.nebula-graph.io
kubectl delete namespace nebula-operator-system
}

function main() {

deploy_and_start_service

validate_database

stop_service

}

main