diff --git a/config/samples/child-resources/kind-cell.yaml b/config/samples/child-resources/kind-cell.yaml deleted file mode 100644 index f21897a7..00000000 --- a/config/samples/child-resources/kind-cell.yaml +++ /dev/null @@ -1,56 +0,0 @@ -apiVersion: multigres.com/v1alpha1 -kind: Cell -metadata: - name: kind-cell-sample - namespace: default -spec: - # Logical name of the cell - name: zone-a - - # Physical zone placement (use either 'zone' or 'region', not both) - zone: us-west-1a - - # Container image for multigateway - multigatewayImage: ghcr.io/multigres/multigres:main - - # MultiGateway deployment - query routing - multigateway: - replicas: 1 - resources: - requests: - cpu: 50m - memory: 128Mi - limits: - cpu: 200m - memory: 256Mi - - # Reference to the global topology server - globalTopoServer: - address: kind-global-topo:2379 - rootPath: /multigres/global - implementation: etcd2 - - # Cell-local topology server configuration (optional) - # If specified, creates a local etcd cluster for this cell - topoServer: - etcd: - image: quay.io/coreos/etcd:v3.5.12 - replicas: 1 - storage: - size: 1Gi - resources: - requests: - cpu: 50m - memory: 128Mi - limits: - cpu: 200m - memory: 256Mi - - # List of all cells in the cluster for discovery - allCells: - - zone-a - - # Topology reconciliation settings - topologyReconciliation: - registerCell: true - prunePoolers: true diff --git a/config/samples/child-resources/kind-shard.yaml b/config/samples/child-resources/kind-shard.yaml deleted file mode 100644 index 06fb476e..00000000 --- a/config/samples/child-resources/kind-shard.yaml +++ /dev/null @@ -1,96 +0,0 @@ -apiVersion: multigres.com/v1alpha1 -kind: Shard -metadata: - name: kind-shard-sample - namespace: default -spec: - # Shard identification - databaseName: mydb - tableGroupName: users - shardName: "0" - - # Container images for shard components - images: - multiorch: ghcr.io/multigres/multigres:main - multipooler: ghcr.io/multigres/multigres:main - postgres: postgres:16-alpine - - # Reference to the global topology server - globalTopoServer: - address: kind-global-topo:2379 - rootPath: /multigres/global - implementation: etcd2 - - # MultiOrch configuration for shard orchestration - multiorch: - cells: - - zone-a - replicas: 1 - resources: - requests: - cpu: 50m - memory: 64Mi - limits: - cpu: 200m - memory: 128Mi - - # Shard pools - different types of PostgreSQL replicas - pools: - # Primary replica pool - primary: - type: readWrite - cells: - - zone-a - replicasPerCell: 1 - - # Storage configuration - kind uses local storage provisioner - storage: - size: 1Gi - - # PostgreSQL container configuration - lower resources for kind - postgres: - resources: - requests: - cpu: 100m - memory: 256Mi - limits: - cpu: 500m - memory: 512Mi - - # MultiPooler container configuration - multipooler: - resources: - requests: - cpu: 50m - memory: 64Mi - limits: - cpu: 200m - memory: 128Mi - - # Read replica pool - replica: - type: readOnly - cells: - - zone-a - replicasPerCell: 1 - - storage: - size: 1Gi - - postgres: - resources: - requests: - cpu: 100m - memory: 256Mi - limits: - cpu: 500m - memory: 512Mi - - multipooler: - resources: - requests: - cpu: 50m - memory: 64Mi - limits: - cpu: 200m - memory: 128Mi diff --git a/config/samples/child-resources/kind-toposerver.yaml b/config/samples/child-resources/kind-toposerver.yaml deleted file mode 100644 index d937122e..00000000 --- a/config/samples/child-resources/kind-toposerver.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: multigres.com/v1alpha1 -kind: TopoServer -metadata: - name: kind-toposerver-sample - namespace: default -spec: - # Etcd configuration for the topology server - etcd: - # etcd container image - image: quay.io/coreos/etcd:v3.5.12 - - # Number of etcd replicas (must be odd: 1, 3, 5, etc.) - # Using 1 replica for kind to minimize resource usage - replicas: 1 - - # Storage configuration for etcd data - kind uses local storage provisioner - storage: - size: 1Gi - - # Resource requirements for etcd containers - lower for kind - resources: - requests: - cpu: 50m - memory: 128Mi - limits: - cpu: 200m - memory: 256Mi diff --git a/config/samples/external-etcd.yaml b/config/samples/external-etcd.yaml new file mode 100644 index 00000000..22a9ca25 --- /dev/null +++ b/config/samples/external-etcd.yaml @@ -0,0 +1,46 @@ +apiVersion: multigres.com/v1alpha1 +kind: MultigresCluster +metadata: + name: external-etcd-cluster + namespace: default +spec: + # ---------------------------------------------------------------- + # 1. Global Topology (External) + # ---------------------------------------------------------------- + # Connects to an existing, external Etcd cluster (e.g. cloud managed). + globalTopoServer: + external: + endpoints: + - "https://etcd-1.infra.local:2379" + - "https://etcd-2.infra.local:2379" + caSecret: "etcd-ca-secret" + clientCertSecret: "etcd-client-cert-secret" + rootPath: "/multigres/global" + + # ---------------------------------------------------------------- + # 2. Cell Definitions (Mixed Mode) + # ---------------------------------------------------------------- + cells: + # Cell A: Standard Configuration + # Uses the Global External Etcd defined above. + - name: "zone-a" + zone: "us-east-1a" + + # Cell B: High-Isolation Configuration + # This cell has its own dedicated, Operator-managed Etcd cluster. + # It does NOT use the global etcd for cell-level data. + # Benefit: If the external global etcd has an outage, this cell + # remains fully functional for intra-cell traffic. + - name: "zone-b-isolated" + zone: "us-east-1b" + spec: + localTopoServer: + etcd: + image: "quay.io/coreos/etcd:v3.5" + replicas: 3 + storage: + size: "5Gi" + class: "standard-gp3" + # Since we are defining 'spec', we must also define the gateway + multigateway: + replicas: 2 diff --git a/config/samples/minimal.yaml b/config/samples/minimal.yaml new file mode 100644 index 00000000..3522322b --- /dev/null +++ b/config/samples/minimal.yaml @@ -0,0 +1,18 @@ +apiVersion: multigres.com/v1alpha1 +kind: MultigresCluster +metadata: + name: minimal-cluster + namespace: default +spec: + # A minimal cluster requires at least one cell definition. + # + # The operator will resolve configuration defaults in this order: + # 1. Namespace Defaults: If a template named "default" exists in this namespace + # (e.g., CoreTemplate/default, CellTemplate/default), it will be used. + # 2. Hardcoded Defaults: If no template is found, the operator injects: + # - Default GlobalTopoServer (Managed Etcd, 3 replicas) + # - Default MultiAdmin (1 replica) + # - Default Database ("postgres") with Default TableGroup ("default") + cells: + - name: "zone-a" + zone: "us-east-1a" diff --git a/config/samples/no-templates.yaml b/config/samples/no-templates.yaml new file mode 100644 index 00000000..babf1660 --- /dev/null +++ b/config/samples/no-templates.yaml @@ -0,0 +1,100 @@ +apiVersion: multigres.com/v1alpha1 +kind: MultigresCluster +metadata: + name: advanced-cluster + namespace: default +spec: + # ---------------------------------------------------------------- + # 1. Global Components (Inline) + # ---------------------------------------------------------------- + globalTopoServer: + etcd: + image: "quay.io/coreos/etcd:v3.5" + replicas: 3 + storage: + size: "10Gi" + class: "standard-gp3" + resources: + requests: + cpu: "500m" + memory: "1Gi" + limits: + cpu: "1" + memory: "2Gi" + + multiadmin: + spec: + replicas: 2 + resources: + requests: + cpu: "200m" + memory: "256Mi" + limits: + cpu: "500m" + memory: "512Mi" + + # ---------------------------------------------------------------- + # 2. Cell Definitions (Inline) + # ---------------------------------------------------------------- + cells: + - name: "us-east-1a" + zone: "us-east-1a" + spec: + multigateway: + replicas: 2 + resources: + requests: + cpu: "1" + memory: "2Gi" + limits: + cpu: "2" + memory: "4Gi" + + # ---------------------------------------------------------------- + # 3. Database Topology (Inline) + # ---------------------------------------------------------------- + databases: + - name: "postgres" + default: true + tablegroups: + - name: "default" # Gateway requires this name at the moment. + default: true + shards: + - name: "0" + spec: + multiorch: + cells: + - "us-east-1a" + resources: + requests: + cpu: "200m" + memory: "256Mi" + limits: + cpu: "500m" + memory: "512Mi" + + pools: + main-app: + type: "readWrite" + cells: + - "us-east-1a" + replicasPerCell: 2 + storage: + class: "gp3" + size: "100Gi" + postgres: + resources: + requests: + cpu: "2" + memory: "4Gi" + limits: + cpu: "4" + memory: "8Gi" + multipooler: + resources: + requests: + cpu: "500m" + memory: "1Gi" + limits: + cpu: "1" + memory: "2Gi" diff --git a/config/samples/reference.yaml b/config/samples/reference.yaml deleted file mode 100644 index cbe0890a..00000000 --- a/config/samples/reference.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# This sample is intended to represent a complete cluster. -# Useful as a starting point and as a complete reference for all options. - -apiVersion: v1 -kind: Namespace -metadata: - name: multigres-sample ---- -apiVersion: multigres.com/v1alpha1 -kind: Etcd -metadata: - namespace: multigres-sample - name: sample -spec: {} \ No newline at end of file diff --git a/config/samples/sample.yaml b/config/samples/sample.yaml deleted file mode 100644 index 61228b20..00000000 --- a/config/samples/sample.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: multigres-sample ---- -apiVersion: multigres.com/v1alpha1 -kind: Etcd -metadata: - namespace: multigres-sample - name: sample -spec: {} ---- -apiVersion: multigres.com/v1alpha1 -kind: MultiGateway -metadata: - namespace: multigres-sample - name: sample -spec: {} \ No newline at end of file diff --git a/config/samples/template-defaults.yaml b/config/samples/template-defaults.yaml new file mode 100644 index 00000000..669b3763 --- /dev/null +++ b/config/samples/template-defaults.yaml @@ -0,0 +1,38 @@ +apiVersion: multigres.com/v1alpha1 +kind: MultigresCluster +metadata: + name: standard-ha-cluster + namespace: default +spec: + # 1. Define Cluster-Wide Defaults + templateDefaults: + coreTemplate: "standard-core" + cellTemplate: "standard-cell" + shardTemplate: "standard-shard" + + # 2. Define Cells (Inherits 'standard-cell') + cells: + - name: "us-east-1a" + zone: "us-east-1a" + - name: "us-east-1b" + zone: "us-east-1b" + + # 3. Configure the System Database + # We explicitly define this to ensure it uses our 'standard-shard' template + # and has the correct redundancy. + databases: + - name: "postgres" + default: true # Marks this as the System Catalog + tablegroups: + - name: "default" # MUST be named 'default' for Gateway routing + default: true + shards: + - name: "0" + # Inherits 'standard-shard' template automatically via defaults + overrides: + pools: + main-app: + # Spread the primary pool across both available cells + cells: + - "us-east-1a" + - "us-east-1b" diff --git a/config/samples/templates/cell.yaml b/config/samples/templates/cell.yaml new file mode 100644 index 00000000..1441efae --- /dev/null +++ b/config/samples/templates/cell.yaml @@ -0,0 +1,24 @@ +apiVersion: multigres.com/v1alpha1 +kind: CellTemplate +metadata: + name: "standard-cell" + namespace: default +spec: + multigateway: + replicas: 2 + resources: + requests: + cpu: "500m" + memory: "512Mi" + limits: + cpu: "1" + memory: "1Gi" + affinity: + podAntiAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - weight: 100 + podAffinityTerm: + labelSelector: + matchLabels: + app.kubernetes.io/component: multigateway + topologyKey: "kubernetes.io/hostname" diff --git a/config/samples/templates/core.yaml b/config/samples/templates/core.yaml new file mode 100644 index 00000000..d6041336 --- /dev/null +++ b/config/samples/templates/core.yaml @@ -0,0 +1,30 @@ +apiVersion: multigres.com/v1alpha1 +kind: CoreTemplate +metadata: + name: "standard-core" + namespace: default +spec: + globalTopoServer: + etcd: + image: "quay.io/coreos/etcd:v3.5" + replicas: 3 + storage: + size: "10Gi" + class: "standard-gp3" + resources: + requests: + cpu: "500m" + memory: "1Gi" + limits: + cpu: "1" + memory: "2Gi" + + multiadmin: + replicas: 2 + resources: + requests: + cpu: "200m" + memory: "256Mi" + limits: + cpu: "500m" + memory: "512Mi" diff --git a/config/samples/templates/shard.yaml b/config/samples/templates/shard.yaml new file mode 100644 index 00000000..2696a2b8 --- /dev/null +++ b/config/samples/templates/shard.yaml @@ -0,0 +1,38 @@ +apiVersion: multigres.com/v1alpha1 +kind: ShardTemplate +metadata: + name: "standard-shard" + namespace: default +spec: + multiorch: + resources: + requests: + cpu: "100m" + memory: "128Mi" + limits: + cpu: "200m" + memory: "256Mi" + + pools: + main-app: + type: "readWrite" + replicasPerCell: 2 + storage: + class: "gp3" + size: "100Gi" + postgres: + resources: + requests: + cpu: "1" + memory: "2Gi" + limits: + cpu: "2" + memory: "4Gi" + multipooler: + resources: + requests: + cpu: "500m" + memory: "512Mi" + limits: + cpu: "1" + memory: "1Gi"