-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase-with-topology.yaml
More file actions
65 lines (57 loc) · 2.38 KB
/
database-with-topology.yaml
File metadata and controls
65 lines (57 loc) · 2.38 KB
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
58
59
60
61
62
63
64
65
# Example: Database with Custom Topology Distribution
#
# This example shows how to create a database with a specific topology
# that distributes across available cluster servers.
#
# TOPOLOGY CONCEPTS:
# - Cluster Topology: Infrastructure servers (e.g., 5 servers in the cluster)
# - Database Topology: How this database uses those servers (e.g., 2 primaries + 1 secondary = 3 servers used)
#
# REQUIREMENTS:
# - Referenced resource "my-neo4j-cluster" must exist and be ready
# - For clusters: Must have at least 3 servers available (2 primaries + 1 secondary)
# - For standalone: Topology will be ignored (single-node databases only)
#
# DISTRIBUTION (Clusters only):
# - 2 servers will host primary replicas (read/write)
# - 1 server will host secondary replica (read-only)
# - Remaining cluster servers can be used by other databases
apiVersion: neo4j.neo4j.com/v1alpha1
kind: Neo4jDatabase
metadata:
name: orders-database
namespace: default
spec:
# Reference to Neo4j Enterprise Cluster or Standalone deployment
# Can reference either Neo4jEnterpriseCluster or Neo4jEnterpriseStandalone
clusterRef: my-neo4j-cluster
# Database name as it appears in Neo4j
name: orders
# Wait for database creation to complete before marking as ready
wait: true
# Create only if it doesn't exist (avoids errors on reapply)
ifNotExists: true
# Database topology: Distribution across cluster servers
#
# This specifies how the "orders" database should be distributed
# across the available servers in "my-neo4j-cluster".
#
# Example: If cluster has 5 servers, this database will use 3 of them
# (2 primaries + 1 secondary), leaving 2 servers for other databases.
topology:
primaries: 2 # 2 servers handle read/write for this database
secondaries: 1 # 1 server provides read-only access for scaling
# Database-specific configuration options
options:
txLogEnrichment: "FULL" # Enhanced transaction logging
# Initial data import after database creation
initialData:
source: cypher
cypherStatements:
- "CREATE CONSTRAINT order_id_unique IF NOT EXISTS ON (o:Order) ASSERT o.orderId IS UNIQUE"
- "CREATE INDEX order_date_index IF NOT EXISTS FOR (o:Order) ON (o.orderDate)"
---
# Create the admin secret required by the cluster
# kubectl create secret generic neo4j-admin-secret \
# --from-literal=username=neo4j \
# --from-literal=password=your-secure-password