neo4j安装

neo4j安装

neo4j是开源的图数据库.

这里使用helm安装.

参考: https://neo4j.com/docs/operations-manual/current/kubernetes/introduction/

配置helm仓库

helm repo add neo4j https://helm.neo4j.com/neo4j

helm repo update

部署单实例应用

注意, 单实例和cluster(cluster需要license) 使用同一个helm chart.

组件概览

standalone on k8s

创建自定义配置文件

my-neo4j.values.yaml

neo4j:
  name: neo4j
  resources:
    cpu: "0.5"
    memory: "2Gi"

  # Uncomment to set the initial password
  password: "w784319947"

  # Uncomment to use enterprise edition
  #edition: "enterprise"
  #acceptLicenseAgreement: "yes"

volumes:
  data:
    mode: "dynamic"
    dynamic:
      storageClassName: csi-rbd-sc
      requests:
        storage: 10Gi



services:
  # A LoadBalancer Service for external Neo4j driver applications and Neo4j Browser
  neo4j:
    enabled: true

    # Annotations for the K8s Service object
    annotations:
      metallb.universe.tf/allow-shared-ip: "key-to-share-183.129.155.3"
      metallb.universe.tf/address-pool: "public-pool"

    spec:
      # Type of service.
      type: LoadBalancer
      loadBalancerIP: 183.129.155.3
      externalTrafficPolicy: Cluster

这里的service段的内容, 是从chart的values.yaml中复制出来,改了改的.

我这里LoadBalancer的实现是metallb. 这里为了省 公网IP, 允许IP复用.

The value of the annotation is a “sharing key.” Services can share an IP address under the following conditions:

  • They both have the same sharing key.
  • They request the use of different ports (e.g. tcp/80 for one and tcp/443 for the other).
  • They both use the Cluster external traffic policy, or they both point to the exact same set of pods (i.e. the pod selectors are identical).

安装实例

创建命名空间, 设为当前操作默认命名空间

kubectl create namespace neo4j
kubectl config set-context --current --namespace=neo4j

使用helm部署

# 可以先拉下来看下
helm pull neo4j/neo4j
helm pull neo4j/neo4j --untar

# 当前版本是5.19.0

helm install neo4j neo4j/neo4j --namespace neo4j -f my-neo4j.values.yaml

输出

root@wangjm-B550M-K-1:~/k8s/helm/neo4j# helm install neo4j neo4j/neo4j --namespace neo4j -f my-neo4j.values.yaml
NAME: neo4j
LAST DEPLOYED: Fri May 24 18:16:48 2024
NAMESPACE: neo4j
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Thank you for installing neo4j.

Your release "neo4j" has been installed  in namespace "neo4j".

The neo4j user's password has been set to "w784319947".To view the progress of the rollout try:

  $ kubectl --namespace "neo4j" rollout status --watch --timeout=600s statefulset/neo4j

Once rollout is complete you can log in to Neo4j at "neo4j://neo4j.neo4j.svc.cluster.local:7687". Try:

  $ kubectl run --rm -it --namespace "neo4j" --image "neo4j:5.19.0" cypher-shell \
     -- cypher-shell -a "neo4j://neo4j.neo4j.svc.cluster.local:7687" -u neo4j -p "w784319947"

Graphs are everywhere!

WARNING: Passwords set using 'neo4j.password' will be stored in plain text in the Helm release ConfigMap.
Please consider using 'neo4j.passwordFromSecret' for improved security.

看了下service情况, loadbalancer默认使用了另一个ip池,

调头到最前面my-neo4j.values.yaml,修改配置,

重新部署

helm upgrade neo4j neo4j/neo4j --namespace neo4j -f my-neo4j.values.yaml

输出

root@wangjm-B550M-K-1:~/k8s/helm/neo4j# helm upgrade neo4j neo4j/neo4j --namespace neo4j -f my-neo4j.values.yaml
Release "neo4j" has been upgraded. Happy Helming!
NAME: neo4j
LAST DEPLOYED: Fri May 24 18:37:09 2024
NAMESPACE: neo4j
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Thank you for using neo4j.


To view the status of changes to your release "neo4j"  in namespace "neo4j", try:

  $ kubectl --namespace "neo4j" rollout status --watch --timeout=600s statefulset/neo4j

Once rollout is complete you can log in to Neo4j at "neo4j://neo4j.neo4j.svc.cluster.local". Try:

  $ kubectl run --rm -it --namespace "neo4j" --image "neo4j:5.19.0" cypher-shell \
     -- cypher-shell -a "neo4j://neo4j.neo4j.svc.cluster.local:7687"

Graphs are everywhere!


WARNING: Passwords set using 'neo4j.password' will be stored in plain text in the Helm release ConfigMap.
Please consider using 'neo4j.passwordFromSecret' for improved security.

再查看下service的情况

root@wangjm-B550M-K-1:~/k8s/helm/neo4j# kubectl get all
NAME          READY   STATUS    RESTARTS   AGE
pod/neo4j-0   1/1     Running   0          96s

NAME                     TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                                        AGE
service/neo4j            ClusterIP      172.31.3.241   <none>          7687/TCP,7474/TCP                              96s
service/neo4j-admin      ClusterIP      172.31.5.82    <none>          7687/TCP,7474/TCP                              96s
service/neo4j-lb-neo4j   LoadBalancer   172.31.7.147   183.129.155.3   7474:31677/TCP,7473:30459/TCP,7687:31553/TCP   96s

可以了.


评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注