Hi, everybody! As you know, Nebula Operator has been open-source, and we published an introduction to it. Today, I would like to introduce my practice on Nebula Operator on cloud.
About Nebula Operator
What is Nebula Operator? You can refer to Nebula Operator Overview: Automated Operation on Kubernetes. Today, this article will focus on the practice on Nebula Operator. I hope it could help you get started with it soon and enjoy NebulaGraph.
Practicing Nebula Operator on Cloud
In this section, I will introduce the process of deploying and using Nebula Operator on cloud. Alibaba Cloud services are used, but the process is applicable to the similar services of other cloud service providers.
Installation Tools
Install the following tools on your on-premises machine:
For the installation information, see their documentations.
Creating Kubernetes Cluster on Cloud
Nebula Operator is implemented for Kubernetes applications, so Kubernetes is necessary for practicing Nebula Operator.
This practice was performed on a managed Kubernetes cluster on Alibaba Cloud, so the first thing is to log on to the Alibaba Cloud Container Service for Kubernetes (ACK) console and then to create a managed Kubernetes cluster. The configurations must meet your needs.
NOTE: To facilitate access to the Kubernetes API Server from Internet, Expose API Server with EIP was enabled for this practice. Whether to enable it or not is determined by your needs. If it is not enabled, you need to make sure that your on-premises machine can connect to the Kubernetes cluster. Configure other parameters as required.
When the Kubernetes cluster starts, in the Connection Information tab, copy the Public Access content in the code block to the $HOME/.kube/config file of your on-premises machine.
And then on your on-premises machine, run the following command to check the connection to your Kubernetes cluster.
$ kubectl get nodesNAME STATUS ROLES AGE VERSIONcn-beijing.192.168.250.13Ready <none> 51m v1.20.4-aliyun.1cn-beijing.192.168.250.185Ready <none> 51m v1.20.4-aliyun.1cn-beijing.192.168.250.89Ready <none> 51m v1.20.4-aliyun.1
Installing Dependencies for Nebula Operator
Install all the dependencies listed in this section for Nebula Operator.
# Install OpenKruise$ helm install kruise \
https://github.com/openkruise/kruise/releases/download/v0.8.1/kruise-chart.tgz
# Wait fora moment and then check whether OpenKruise is started successfully.
$kubectl -n kruise-system get podNAME READY STATUS RESTARTS AGEkruise-controller-manager-6797f89d9b-ppv65 1/1Running 049skruise-controller-manager-6797f89d9b-wlkbd 1/1Running 049skruise-daemon-7rljq 1/1Running 049skruise-daemon-8kd8d 1/1Running 049skruise-daemon-n6tdw 1/1Running 049s
As you can see from the result of the preceding command, five types of StorageClass are supported on Alibaba Cloud. For this practice, alicloud-disk-ssd was used. If you want to use the services provided by another cloud service provider, choose an applicable StorageClass type.
NOTE: Each cloud service provider may set limits on the storage capacity for your application. For example, on Alibaba Cloud, the limit on SSD is from 20 GiB to 32,768 GiB. Therefore, you must specially consider this configuration when deploying a NebulaGraph cluster.
To view all the configurable parameters, you can run the following command.
$ helm show values nebula-operator/nebula-cluster
In this practice, all these commands were run to deploy a NebulaGraph cluster.
# Name the NebulaGraph cluster.
$exportNEBULA_CLUSTER_NAME=nebula
# Create a namespace forthe NebulaGraph cluster.
$exportNEBULA_CLUSTER_NAMESPACE=nebula
# Specify StorageClass type forthe NebulaGraph cluster. Inthisexample,alicloud-disk-ssd is used.
$exportSTORAGE_CLASS_NAME=alicloud-disk-ssd
# Specify the storage size forthe three processes of NebulaGraph.
$exportSTORAGE_SIZE_GRAPHD=20Gi$ exportSTORAGE_SIZE_METAD=20Gi$ exportSTORAGE_SIZE_STORAGED=20Gi
# Deploy the NebulaGraph cluster.
$helm install ${NEBULA_CLUSTER_NAME}nebula-operator/nebula-cluster \
--namespace ${NEBULA_CLUSTER_NAMESPACE} --create-namespace --version 0.1.0 \
--set nameOverride=${NEBULA_CLUSTER_NAME} \
--set nebula.storageClassName="${STORAGE_CLASS_NAME}" \
--set nebula.graphd.storage="${STORAGE_SIZE_GRAPHD}" \
--set nebula.metad.storage="${STORAGE_SIZE_METAD}" \
--set nebula.storaged.storage="${STORAGE_SIZE_STORAGED}"
# Wait a moment and check whether the NebulaGraph cluster is started successfully.
$kubectl -n ${NEBULA_CLUSTER_NAMESPACE}get nebulaclusterNAME GRAPHD-DESIRED GRAPHD-READY METAD-DESIRED METAD-READY STORAGED-DESIRED STORAGED-READY AGEnebula 2233334m10s$ kubectl -n ${NEBULA_CLUSTER_NAMESPACE}get podNAME READY STATUS RESTARTS AGEnebula-graphd-01/1Running 096snebula-graphd-11/1Running 096snebula-metad-01/1Running 097snebula-metad-11/1Running 097snebula-metad-21/1Running 097snebula-storaged-01/1Running 097snebula-storaged-11/1Running 097snebula-storaged-21/1Running 097s
Of course, you can also run the following command to upgrade the cluster to have five nebula-storaged process instances.
# Upgrade the NebulaGraph cluster.
$helm upgrade ${NEBULA_CLUSTER_NAME}nebula-operator/nebula-cluster \
--namespace ${NEBULA_CLUSTER_NAMESPACE} --create-namespace --version 0.1.0 \
--set nameOverride=${NEBULA_CLUSTER_NAME} \
--set nebula.storageClassName="${STORAGE_CLASS_NAME}" \
--set nebula.graphd.storage="${STORAGE_SIZE_GRAPHD}" \
--set nebula.metad.storage="${STORAGE_SIZE_METAD}" \
--set nebula.storaged.storage="${STORAGE_SIZE_STORAGED}" \
--set nebula.storaged.replicas=5
# Wait fora moment and check whether the cluster is started successfully.
$kubectl -n ${NEBULA_CLUSTER_NAMESPACE}get nebulaclusterNAME GRAPHD-DESIRED GRAPHD-READY METAD-DESIRED METAD-READY STORAGED-DESIRED STORAGED-READY AGEnebula 2233556m12s$ kubectl -n ${NEBULA_CLUSTER_NAMESPACE}get podNAME READY STATUS RESTARTS AGEnebula-graphd-01/1Running 02m30snebula-graphd-11/1Running 02m30snebula-metad-01/1Running 02m30snebula-metad-11/1Running 02m30snebula-metad-21/1Running 02m30snebula-storaged-01/1Running 02m30snebula-storaged-11/1Running 02m30snebula-storaged-21/1Running 02m30snebula-storaged-31/1Running 052snebula-storaged-41/1Running 052s
And then, run this command to connect to the cluster via the created NebulaGraph Console.
$ kubectl exec -it nebula-console -- \
nebula-console -u u -p p --addr ${NEBULA_CLUSTER_NAME}-graphd-svc.${NEBULA_CLUSTER_NAMESPACE}.svc --port 96692021/06/2306:21:22[INFO]connection pool is initialized successfullyWelcome to NebulaGraph!
(u@nebula)[(none)]> show hosts
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-0.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-1.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-2.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-3.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-4.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "Total" | | | 0 | | |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
Got 4rows (time spent7669/9367 us)Wed,23Jun 202106:21:26UTC
Connecting from Outside of Kubernetes
If you want to connect to the services inside Kubernetes from outside, use hostPort, hostNetwork, Ingress, LoadBalancer, and so on. In this practice, I took advantages of the functionalities of Alibaba Cloud and used LoadBalancer.
DO NOT: This operation will expose your NebulaGraph Cluster to the public, so do not use it in the production environment.
Firstly, change the type of nebula-graphd to LoadBalancer, and then view EXTERNAL-IP.
# Change the type of nebula-graphd to LoadBalancer.
$kubectl patch -n ${NEBULA_CLUSTER_NAMESPACE}svc ${NEBULA_CLUSTER_NAME}-graphd-svc \
-p '{"spec": {"type": "LoadBalancer"}}'
# View EXTERNAL-IP. If"pending"is shown,wait a moment and tryagain.
$kubectl -n ${NEBULA_CLUSTER_NAMESPACE}get svc nebula-graphd-svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)AGEnebula-graphd-svc LoadBalancer 172.16.85.222x.x.x.x9669:31460/TCP,19669:32579/TCP,19670:31481/TCP 27m
Now, you can use the EXTERNAL-IP address (for example, x.x.x.xin this example) to connect to the cluster.
$ exportEXTERNAL_IP=x.x.x.x$ docker run -it --rm vesoft/nebula-console:v2-nightly -u u -p p --addr ${EXTERNAL_IP} --port 96692021/06/2306:42:17[INFO]connection pool is initialized successfullyWelcome to NebulaGraph!
(u@nebula)[(none)]> show hosts
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| Host | Port | Status | Leader count | Leader distribution | Partition distribution |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-0.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-1.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-2.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-3.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "nebula-storaged-4.nebula-storaged-headless.nebula.svc.cluster.local" | 9779 | "ONLINE" | 0 | "No valid partition" | "No valid partition" |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
| "Total" | | | 0 | | |
+-----------------------------------------------------------------------+------+----------+--------------+----------------------+------------------------+
Got 4rows (time spent3747/60433 us)Wed,23Jun 202106:42:21UTC
Enjoy
You made it!
Have fun with NebulaGraph!
Join our Slack channel if you want to discuss with the rest of the NebulaGraph community!