Create a gist now

Instantly share code, notes, and snippets.

Kubernetes + Neo4j
# Headless service to provide DNS lookup
apiVersion: v1
kind: Service
metadata:
labels:
app: neo4j
name: neo4j
spec:
clusterIP: None
ports:
- port: 7474
selector:
app: neo4j
----
# new API name
apiVersion: "apps/v1alpha1"
kind: PetSet
metadata:
name: neo4j
spec:
serviceName: neo4j
replicas: 3
template:
metadata:
annotations:
pod.alpha.kubernetes.io/initialized: "true"
pod.beta.kubernetes.io/init-containers: '[
{
"name": "install",
"image": "gcr.io/google_containers/busybox:1.24",
"command": ["/bin/sh", "-c", "echo \"
unsupported.dbms.edition=enterprise\n
dbms.mode=CORE\n
dbms.connectors.default_advertised_address=$HOSTNAME.neo4j.default.svc.cluster.local\n
dbms.connectors.default_listen_address=0.0.0.0\n
dbms.connector.bolt.type=BOLT\n
dbms.connector.bolt.enabled=true\n
dbms.connector.bolt.listen_address=0.0.0.0:7687\n
dbms.connector.http.type=HTTP\n
dbms.connector.http.enabled=true\n
dbms.connector.http.listen_address=0.0.0.0:7474\n
causal_clustering.raft_messages_log_enable=true\n
causal_clustering.initial_discovery_members=neo4j-0.neo4j.default.svc.cluster.local:5000,neo4j-1.neo4j.default.svc.cluster.local:5000,neo4j-2.neo4j.default.svc.cluster.local:5000\n
causal_clustering.leader_election_timeout=2s\n
\" > /work-dir/neo4j.conf" ],
"volumeMounts": [
{
"name": "confdir",
"mountPath": "/work-dir"
}
]
}
]'
labels:
app: neo4j
spec:
containers:
- name: neo4j
image: "neo4j/neo4j-experimental:3.1.0-M13-beta3-enterprise"
imagePullPolicy: Always
ports:
- containerPort: 5000
name: discovery
- containerPort: 6000
name: tx
- containerPort: 7000
name: raft
- containerPort: 7474
name: browser
- containerPort: 7687
name: bolt
securityContext:
privileged: true
volumeMounts:
- name: datadir
mountPath: /data
- name: confdir
mountPath: /conf
volumes:
- name: confdir
volumeClaimTemplates:
- metadata:
name: datadir
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
for i in $(seq 0 3); do
cat <<EOF | kubectl create -f -
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv${i}
labels:
type: local
app: neo4j
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/tmp/${i}"
EOF
cat <<EOF | kubectl create -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: datadir-neo4j-${i}
labels:
app: neo4j
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
EOF
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment