K8S Nubale3.3部署

K8S Nubale3.3部署

192.168.58.106 master
192.168.83.227 node
192.168.83.228 node
192.168.83.232 node

官方文档

https://docs.nebula-graph.com.cn/3.3.0/nebula-operator/4.connect-to-nebula-graph-service/

部署本地卷插件(如果本地已经部署过一个可跳过)

curl https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/archive/v2.4.0.zip

unzip v2.4.0.zip

修改 v2.4.0/helm/provisioner/values.yaml classes 部分:

hostDir: /mnt/fast-disks 改成 hostDir: /mnt/disks

storageClass: true 改成 storageClass: true。然后执行:

 helm install local-static-provisioner --namespace default sig-storage-local-static-provisioner/helm/provisioner
# 查看 local-static-provisioner 部署情况

$ helm list
NAME                    NAMESPACE REVISION UPDATED                              STATUS  CHART            APP VERSION

local-volume-provisioner default  1      2021-02-10 11:06:34.3540341 +0800 CST deployed provisioner-2.4.0 2.4.0

安装 Helm

wget https://get.helm.sh/helm-v3.5.2-linux-amd64.tar.gz

tar -zxvf helm/helm-v3.5.2-linux-amd64.tgz

mv linux-amd64/helm /usr/bin/helm

安装 NebulaGraph Operator

添加 NebulaGraph Operator chart 仓库至 Helm。

helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts

拉取最新的 Helm 仓库。

helm repo update

参考 Helm 仓库获取更多helm repo相关信息。

安装 NebulaGraph Operator。

helm install nebula-operator nebula-operator/nebula-operator --namespace=<namespace_name> --version=${chart_version}

例如,安装1.3.0版的 Operator 命令如下。

helm install nebula-operator nebula-operator/nebula-operator --namespace=nebula-operator-system --version=1.3.0
  • 上述命令中的nebula-operator-system为用户创建的命名空间。如果用户未创建该命名空间,可以执行kubectl create namespace nebula-operator-system进行创建。用户也可创建其他命名空间。
  • 1.3.0为 NebulaGraph Operator chart 的版本。当 Chart 中只有一个默认版本时,可不指定。执行helm search repo -l nebula-operator查看 Chart 版本。

用户可在执行安装 NebulaGraph Operator chart 命令时自定义其配置。更多信息,查看下文自定义配置 Chart

如果服务器无法连接外网,可以下载 NebulaGraph Operator chart 至本地,再传到服务器。

helm pull nebula-operator/nebula-operator --version=1.3.0
  • --version: 升级版本号。如不指定,则默认为最新版本。

卸载 NebulaGraph Operator

卸载 NebulaGraph Operator chart。

helm uninstall nebula-operator --namespace=<nebula-operator-system>

删除 CRD。

kubectl delete crd nebulaclusters.apps.nebula-graph.io

使用 Kubectl 部署 NebulaGraph 集群

前提条件

  • 安装 NebulaGraph Operator

设置 Kubernetes node节点

# 下面是 Kubernetes 节点列表,我们需要设置 node 节点的调度标签。可以将 192.168.83.227,192.168.83.228,192.168.83.232 打上 nebula=cloud: "cloud" 的标签。
kubectl lable node 192.168.83.227  nebula="cloud" --overwrite
kubectl lable node 192.168.83.228  nebula="cloud" --overwrite
kubectl lable node 192.168.83.232  nebula="cloud" --overwrite

创建集群

本文以创建名为nebula的集群为例,说明如何部署 NebulaGraph 集群。

  1. 创建集群。

    • 社区版集群示例,创建名为apps_v1alpha1_nebulacluster.yaml的文件。
  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: 3
        image: vesoft/nebula-graphd
     version: v3.3.0
     logVolumeClaim:
       resources:
          requests:
           storage: 2Gi
        storageClassName: fast-disks
   metad:
      resources:
        requests:
         cpu: "500m"
          memory: "500Mi"
       limits:
          cpu: "1"
          memory: "1Gi"
      replicas: 3
     image: vesoft/nebula-metad
     version: v3.3.0
     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: 3
      image: vesoft/nebula-storaged
      version: v3.3.0
     logVolumeClaim:
       resources:
         requests:
           storage: 2Gi
        storageClassName: fast-disks
      dataVolumeClaims:   # 从 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

参数描述如下:

参数 默认值 描述
metadata.name 创建的 NebulaGraph 集群名称。
spec.graphd.replicas 1 Graphd 服务的副本数。
spec.graphd.images vesoft/nebula-graphd Graphd 服务的容器镜像。
spec.graphd.version v3.3.0 Graphd 服务的版本号。
spec.graphd.service Graphd 服务 Service 配置。
spec.graphd.logVolumeClaim.storageClassName Graphd 服务的日志盘存储配置。
spec.metad.replicas 1 Metad 服务的副本数。
spec.metad.images vesoft/nebula-metad Metad 服务的容器镜像。
spec.metad.version v3.3.0 Metad 服务的版本号。
spec.metad.dataVolumeClaim.storageClassName Metad 服务的数据盘存储配置。
spec.metad.logVolumeClaim.storageClassName Metad 服务的日志盘存储配置。
spec.storaged.replicas 3 Storaged 服务的副本数。
spec.storaged.images vesoft/nebula-storaged Storaged 服务的容器镜像。
spec.storaged.version v3.3.0 Storaged 服务的版本号。
spec.storaged.dataVolumeClaims.resources.requests.storage Storaged 服务的数据盘存储大小,可指定多块数据盘存储数据。当指定多块数据盘时,路径为:/usr/local/nebula/data1/usr/local/nebula/data2等。
spec.storaged.dataVolumeClaims.resources.storageClassName Storaged 服务的数据盘存储配置。若不指定,则使用全局的存储配置。
spec.storaged.logVolumeClaim.storageClassName Storaged 服务的日志盘存储配置。
spec.storaged.enableAutoBalance true 是否自动均衡数据。
spec.reference.name 依赖的控制器名称。
spec.schedulerName 调度器名称。
spec.imagePullPolicy NebulaGraph 镜像的拉取策略。关于拉取策略详情,请参考 Image pull policy 镜像拉取策略。
  1. 创建 NebulaGraph 集群。

    kubectl create -f apps_v1alpha1_nebulacluster.yaml
  2. 查看 NebulaGraph 集群状态。

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

使用 Helm 部署 NebulaGraph 集群

前提条件

  • 安装 NebulaGraph Operator

创建 NebulaGraph 集群

添加 NebulaGraph Operator chart 仓库至 Helm(如已创添加,略过前面 1 至 2 步,从第 3 步开始执行)。

helm repo add nebula-operator https://vesoft-inc.github.io/nebula-operator/charts

更新 Helm 仓库,拉取最新仓库资源。

helm repo update

设置 Kubernetes node节点

# 下面是 Kubernetes 节点列表,我们需要设置 node 节点的调度标签。可以将 192.168.83.227,192.168.83.228,192.168.83.232 打上 nebula=cloud: "cloud" 的标签。
kubectl lable node 192.168.83.227  nebula="cloud" --overwrite
kubectl lable node 192.168.83.228  nebula="cloud" --overwrite
kubectl lable node 192.168.83.232  nebula="cloud" --overwrite

配置 Helm 的环境变量。

export NEBULA_CLUSTER_NAME=nebula         # NebulaGraph 集群的名字。
export NEBULA_CLUSTER_NAMESPACE=nebula    # NebulaGraph 集群所处的命名空间的名字。
export STORAGE_CLASS_NAME=fast-disks             # NebulaGraph 集群的 StorageClass。

为 NebulaGraph 集群创建命名空间(如已创建,略过此步)。

kubectl create namespace "${NEBULA_CLUSTER_NAMESPACE}"

创建 NebulaGraph 集群。

helm install "${NEBULA_CLUSTER_NAME}" nebula-operator/nebula-cluster \
    --namespace="${NEBULA_CLUSTER_NAMESPACE}" \
    --set nameOverride=${NEBULA_CLUSTER_NAME} \
    --set nebula.storageClassName="${STORAGE_CLASS_NAME}"

查看 NebulaGraph 集群创建状态。

kubectl -n "${NEBULA_CLUSTER_NAMESPACE}" get pod -l "app.kubernetes.io/cluster=${NEBULA_CLUSTER_NAME}"

返回示例:

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

删除集群

使用 Helm 删除集群的命令如下:

helm uninstall "${NEBULA_CLUSTER_NAME}" --namespace="${NEBULA_CLUSTER_NAMESPACE}"

或者使用真实值删除集群,例如:

helm uninstall nebula --namespace=nebula
© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    请登录后查看评论内容