helm安装neo4j

本文主要记录了如何采用helm部署kafka,不包含k8s以及helm的安装,方法请自行查阅。

创建storageclass

本文采用nfs作为pvc的后端存储,若想动态创建pvc,需要创建provisioner,具体步骤可参考我的另一篇《helm安装kafka》。chart包内指定StorageClass,StorageClass便会根据provisioner动态在nfs上创建pv。

1
2
3
4
5
6
7
8
9
10
11
12
13
vim nfs-client-class-neo4j.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: neo4j-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
创建:
kubectl create -f nfs-client-class-neo4j.yaml
storageclass.storage.k8s.io "neo4j-nfs-storage" created
查看:
kubectl get storageclass
NAME PROVISIONER AGE
neo4j-nfs-storage fuseim.pri/ifs 49s

具体创建fuseim.pri/ifs的步骤可以参考:

查找neo4j安装包

1
2
3
4
helm search neo4j
NAME CHART VERSION APP VERSION DESCRIPTION
incubator/neo4j 0.3.0 3.2.3 Neo4j is the world's leading graph database
stable/neo4j 0.8.0 3.4.5 Neo4j is the world's leading graph database

获取neo4j安装包

1
helm fetch stable/neo4j

解压安装包

1
tar -xvzf neo4j-0.8.0.tgz && cd neo4j/

配置storageclass

1
2
3
4
5
6
7
vim values.yaml
core:
numberOfServers: 3
persistentVolume:
mountPath: /data
size: 20Gi
storageClass: "neo4j-nfs-storage"

配置neo4j参数

1
2
3
4
5
6
若需要修改neo4j的配置:
在templates/core-statefulset.yaml、templates/readreplicas-deployment.yaml通过在command:下添加类似于如下以NEO4J_为开头的内容来添加:
export NEO4J_dbms_shell_enabled=true
或者在containers下添加例如如下内容:
- name: NEO4J_dbms_shell_enabled
value: "true"

安装neo4j

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
[root@k8s-test2-master neo4j]#  helm install ./neo4j --name neo4j    (注意:这里不要指定neo4j的namespace,因为neo4j的charts包里将namespace默认在default下,若指定

namespace,需要去neo4j/templates/core-statefulset.yaml等文件中将default改成neo4j)
NAME: neo4j
LAST DEPLOYED: Mon Jan 7 17:12:54 2019
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Secret
NAME AGE
neo4j-neo4j-secrets 0s

==> v1/ConfigMap
neo4j-neo4j-tests 0s

==> v1/Service
neo4j-neo4j 0s

==> v1beta1/Deployment
neo4j-neo4j-replica 0s

==> v1beta1/StatefulSet
neo4j-neo4j-core 0s

==> v1/Pod(related)

NAME READY STATUS RESTARTS AGE
neo4j-neo4j-core-0 0/1 ContainerCreating 0 0s


NOTES:
We'll need to wait a few seconds for the Neo4j cluster to form.
We need to see this line in all of our pods' logs:

> Remote interface available at http://neo-helm-neo4j-core-2.neo-helm-neo4j.default.svc.cluster.local:7474/

We can see the content of the logs by running the following command:

kubectl logs -l "app=neo4j,component=core"

We can now run a query to find the topology of the cluster.

kubectl run -it --rm cypher-shell \
--image=neo4j:3.2.3-enterprise \
--restart=Never \
--namespace default \
--command -- ./bin/cypher-shell -u neo4j -p <password> --a neo4j-neo4j.default.svc.cluster.local "call dbms.cluster.overview()"

This will print out the addresses of the members of the cluster.

Note:
You'll need to substitute <password> with the password you set when installing the Helm package.
If you didn't set a password, one will be auto generated.
You can find the base64 encoded version of the password by running the following command:

kubectl get secrets neo4j-neo4j-secrets -o yaml

验证

1
2
3
4
5
6
7
8
9
10
11
12
13
登录其中一台
kubectl exec -ti neo4j-neo4j-core-1 -- bash
./bin/cypher-shell
username: neo4j
password: ********** //密码请查看/var/lib/neo4j/conf/neo4j.conf文件的最后一行
neo4j> CREATE (n:Person {name: "dahua", age: 18});
neo4j> MATCH (a:Person) return a;
+------------------------------------+
| a |
+------------------------------------+
| (:Person {name: "dahua", age: 18}) |
+------------------------------------+
使用成功。
ulysses wechat
订阅+