使用helm部署GraphScope¶
本指南提供了使用helm部署GraphScope的说明,helm是Kubernetes上流行的包管理器。
该方法非常适合已经熟悉helm并希望自动化部署流程的开发者,同时也适用于那些需要对GraphScope的部署进行更好版本控制和管理支持的用户。
前提条件¶
在使用helm部署GraphScope之前,您需要满足以下条件:
一个Kubernetes集群
Helm
如果您没有Kubernetes集群,可以按照deploy_graphscope_on_self_managed_k8s中的说明创建一个。
如果您尚未安装helm,可以按照Installing Helm中的说明进行安装。
安装¶
我们已在chart发布到制品中心,您只需运行以下命令即可轻松获取:
helm repo add graphscope https://graphscope.oss-cn-beijing.aliyuncs.com/charts/
helm repo update
有关repo命令的更多信息,请参阅helm repo文档。
将图表添加到您的代码仓库后,您可以通过运行以下命令进行安装:
# helm install <release-name> graphscope/graphscope
# Replace <release-name> to the name of this release, use `my-gs` for illustration.
helm install my-gs graphscope/graphscope
有关install命令的更多信息,请参阅helm install文档。
请注意,首次运行此命令时拉取镜像可能需要几分钟时间。您可以通过多次执行helm test来监控状态:
# After installation, you can check service availability by:
helm test my-gs
当helm test显示安装成功后,它会打印出连接GraphScope所需的信息。
之后您可以复制粘贴这些指令,将连接信息保存到环境变量中。
您也可以通过以下方式获取GraphScope的端点:
helm status my-gs
当服务类型为NotePort时,示例输出如下
export NODE_IP=$(kubectl --namespace default get pod -l graphscope.coordinator.name=coordinator-my-gs -ojsonpath="{.items[0].status.hostIP}")
export NODE_PORT=$(kubectl --namespace default get services coordinator-service-my-gs -ojsonpath="{.spec.ports[0].nodePort}")
echo "GraphScope service listen on ${NODE_IP}:${NODE_PORT}"
连接到GraphScope¶
你需要安装graphscope-client包才能import graphscope。
由于GraphScope已在集群中运行,您只需连接到它即可。 除了连接过程外,其他语句与通过Python客户端启动的GraphScope集群完全相同。
提示
如果遇到与minikube的连接问题,可以尝试获取服务名称并按如下方式暴露服务:
# kubectl get services
minikube service coordinator-service-<release-name> --url
如需了解更多用法,请参考minikube的访问教程。
import graphscope
graphscope.set_option(show_log=True)
sess = graphscope.session(addr='<ip>:<port>')
# Load an empty graph to get started
g = sess.g()
# create an interactive instance
interactive = graphscope.gremlin(g)
参数 addr 是用于连接预启动服务的端点。 和 是从上一步获取的连接信息。
请注意,同一时间只能有一个会话连接到服务,但在会话关闭后可以重新连接同一服务。
提示
在helm安装过程中,sess.close()不会移除GraphScope的资源(如pods、services等),因为这些资源是由helm管理的。该方法仅断开当前会话与后端的连接。
这也意味着您可以稍后重新连接到同一个GraphScope服务。
要移除资源,请使用helm uninstall。详情请参阅下一节。
# sess = graphscope.session(addr='<ip>:<port>')
sess.close()
sess2 = graphscope.session(addr='<ip>:<port>')
查看创建会话以获取命令文档。
卸载发行版¶
helm uninstall my-gs
这将移除与chart关联的所有Kubernetes组件并删除release。
关于helm uninstall命令文档,请参阅helm uninstall。
配置¶
参见安装前自定义图表。
要查看所有可配置选项及详细注释,请访问图表的values.yaml,或运行以下配置命令:
helm show values graphscope/graphscope
您可以在graphscope图表的主页查看更多详细信息。
离线安装¶
虽然通过查询远程仓库安装graphscope非常方便,但用户可能希望在没有互联网访问权限的环境中使用它。或者用户可能希望在安装前对图表进行一些自定义。
为了满足这些需求,我们提供了两种无需联网即可通过helm安装graphscope的方式。
您可以下载图表文件:
wget https://graphscope.oss-cn-beijing.aliyuncs.com/charts/graphscope-0.20.0.tgz
然后,将软件包复制到服务器,解压并安装graphscope图表。
tar zxvf graphscope-0.20.0.tgz
helm install my-gs ./graphscope
您可以克隆GraphScope的代码仓库以获取图表的源代码
git clone https://github.com/alibaba/GraphScope
cd GraphScope/charts
helm install my-gs ./graphscope