Skip to content

Commit 81537c6

Browse files
authored
Merge pull request #75 from numtide/api-spec-rbac
Adjust RBAC setup for full deployment
2 parents 0c57f41 + c8ef74e commit 81537c6

File tree

9 files changed

+230
-8
lines changed

9 files changed

+230
-8
lines changed

api/v1alpha1/cell_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ type CellStatus struct {
173173
// +kubebuilder:printcolumn:name="Orch Ready",type="string",JSONPath=".status.multiorchAvailable",description="Orchestrator status"
174174
// +kubebuilder:printcolumn:name="Topo Ready",type="string",JSONPath=".status.topoServerAvailable",description="Topo server status"
175175
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
176+
// +kubebuilder:rbac:groups=multigres.com,resources=cells,verbs=get;list;watch;create;update;patch;delete
177+
// +kubebuilder:rbac:groups=multigres.com,resources=cells/status,verbs=get;update;patch
178+
// +kubebuilder:rbac:groups=multigres.com,resources=cells/finalizers,verbs=update
179+
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
180+
// +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
176181

177182
// Cell is the Schema for the Cells API
178183
type Cell struct {

api/v1alpha1/shard_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ type MultiPoolerSpec struct {
108108
// MultiOrchSpec defines the configuration for the MultiPooler container.
109109
type MultiOrchSpec struct {
110110
// Cells is the name of the cells MultiOrch needs to be deployed to.
111+
// TODO: This must have at least one item, otherwise deployment won't work.
111112
Cells []string `json:"cells,omitempty"`
112113

113114
// Image is the MultiOrch container image to use.
@@ -158,6 +159,12 @@ type ShardStatus struct {
158159
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.readyPods",description="Ready pods"
159160
// +kubebuilder:printcolumn:name="Total",type="string",JSONPath=".status.totalPods",description="Total pods"
160161
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
162+
// +kubebuilder:rbac:groups=multigres.com,resources=shards,verbs=get;list;watch;create;update;patch;delete
163+
// +kubebuilder:rbac:groups=multigres.com,resources=shards/status,verbs=get;update;patch
164+
// +kubebuilder:rbac:groups=multigres.com,resources=shards/finalizers,verbs=update
165+
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
166+
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
167+
// +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
161168

162169
// Shard is the Schema for the Shards API
163170
type Shard struct {

api/v1alpha1/toposerver_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ type TopoServerStatus struct {
108108
// +kubebuilder:printcolumn:name="Total",type="string",JSONPath=".status.replicas",description="Total replicas"
109109
// +kubebuilder:printcolumn:name="Service",type="string",JSONPath=".status.clientServiceName",description="Client Service"
110110
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
111+
// +kubebuilder:rbac:groups=multigres.com,resources=toposervers,verbs=get;list;watch;create;update;patch;delete
112+
// +kubebuilder:rbac:groups=multigres.com,resources=toposervers/status,verbs=get;update;patch
113+
// +kubebuilder:rbac:groups=multigres.com,resources=toposervers/finalizers,verbs=update
114+
// +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete
115+
// +kubebuilder:rbac:groups="",resources=services,verbs=get;list;watch;create;update;patch;delete
111116

112117
// TopoServer is the Schema for the toposervers API
113118
type TopoServer struct {

config/crd/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5+
- bases/multigres.com_cells.yaml
56
- bases/multigres.com_etcds.yaml
67
- bases/multigres.com_multigateways.yaml
78
- bases/multigres.com_multiorches.yaml
89
- bases/multigres.com_multipoolers.yaml
10+
- bases/multigres.com_shards.yaml
11+
- bases/multigres.com_toposervers.yaml
912
# +kubebuilder:scaffold:crdkustomizeresource
1013

1114
patches:

config/manager/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: controller
8-
newTag: dev
7+
newName: ghcr.io/numtide/multigres-operator
8+
newTag: 076c82c-dirty

config/rbac/role.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ rules:
3232
- apiGroups:
3333
- multigres.com
3434
resources:
35-
- etcds
36-
- multigateways
35+
- cells
36+
- shards
37+
- toposervers
3738
verbs:
3839
- create
3940
- delete
@@ -45,15 +46,17 @@ rules:
4546
- apiGroups:
4647
- multigres.com
4748
resources:
48-
- etcds/finalizers
49-
- multigateways/finalizers
49+
- cells/finalizers
50+
- shards/finalizers
51+
- toposervers/finalizers
5052
verbs:
5153
- update
5254
- apiGroups:
5355
- multigres.com
5456
resources:
55-
- etcds/status
56-
- multigateways/status
57+
- cells/status
58+
- shards/status
59+
- toposervers/status
5760
verbs:
5861
- get
5962
- patch
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: Cell
3+
metadata:
4+
name: kind-cell-sample
5+
namespace: default
6+
spec:
7+
# Logical name of the cell
8+
name: zone-a
9+
10+
# Container images for cell components
11+
images:
12+
multigateway: ghcr.io/multigres/multigateway:latest
13+
multiorch: ghcr.io/multigres/multiorch:latest
14+
15+
# MultiGateway deployment - query routing
16+
multigateway:
17+
replicas: 1
18+
resources:
19+
requests:
20+
cpu: 50m
21+
memory: 128Mi
22+
limits:
23+
cpu: 200m
24+
memory: 256Mi
25+
26+
# MultiOrch deployment - cell orchestration
27+
multiorch:
28+
replicas: 1
29+
resources:
30+
requests:
31+
cpu: 50m
32+
memory: 64Mi
33+
limits:
34+
cpu: 200m
35+
memory: 128Mi
36+
37+
# Reference to the global topology server
38+
globalTopoServer:
39+
rootPath: /multigres
40+
clientServiceName: kind-global-topo-client
41+
42+
# Cell-local topology server configuration
43+
# If managedSpec is set, a TopoServer CR will be created for this cell
44+
topoServer:
45+
managedSpec:
46+
image: quay.io/coreos/etcd:v3.5.12
47+
replicas: 1
48+
49+
# Storage for etcd data - kind uses local storage provisioner
50+
dataVolumeClaimTemplate:
51+
accessModes:
52+
- ReadWriteOnce
53+
resources:
54+
requests:
55+
storage: 1Gi
56+
57+
# Resource requirements for etcd - lower for kind
58+
resources:
59+
requests:
60+
cpu: 50m
61+
memory: 128Mi
62+
limits:
63+
cpu: 200m
64+
memory: 256Mi
65+
66+
# List of all cells in the cluster for discovery
67+
allCells:
68+
- zone-a
69+
70+
# Topology reconciliation settings
71+
topologyReconciliation:
72+
registerCell: true
73+
pruneTablets: true
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: Shard
3+
metadata:
4+
name: kind-shard-sample
5+
namespace: default
6+
spec:
7+
# Container images for shard components
8+
images:
9+
postgres: postgres:16-alpine
10+
multipooler: ghcr.io/multigres/multipooler:latest
11+
12+
# MultiOrch configuration for shard orchestration
13+
multiOrch:
14+
cells:
15+
- zone-a
16+
image: ghcr.io/multigres/multiorch:latest
17+
resources:
18+
requests:
19+
cpu: 50m
20+
memory: 64Mi
21+
limits:
22+
cpu: 200m
23+
memory: 256Mi
24+
25+
# Shard pools - different types of PostgreSQL replicas
26+
pools:
27+
# Primary replica pool
28+
primary:
29+
type: replica
30+
cell: zone-a
31+
database: mydb
32+
tableGroup: users
33+
replicas: 1
34+
35+
# Storage configuration - kind uses local storage provisioner
36+
dataVolumeClaimTemplate:
37+
accessModes:
38+
- ReadWriteOnce
39+
resources:
40+
requests:
41+
storage: 1Gi
42+
43+
# PostgreSQL container configuration - lower resources for kind
44+
postgres:
45+
resources:
46+
requests:
47+
cpu: 100m
48+
memory: 256Mi
49+
limits:
50+
cpu: 500m
51+
memory: 512Mi
52+
53+
# MultiPooler container configuration
54+
multipooler:
55+
resources:
56+
requests:
57+
cpu: 50m
58+
memory: 64Mi
59+
limits:
60+
cpu: 200m
61+
memory: 128Mi
62+
63+
# Read replica pool
64+
replica:
65+
type: replica
66+
cell: zone-a
67+
database: mydb
68+
tableGroup: users
69+
replicas: 1
70+
71+
dataVolumeClaimTemplate:
72+
accessModes:
73+
- ReadWriteOnce
74+
resources:
75+
requests:
76+
storage: 1Gi
77+
78+
postgres:
79+
resources:
80+
requests:
81+
cpu: 100m
82+
memory: 256Mi
83+
limits:
84+
cpu: 500m
85+
memory: 512Mi
86+
87+
multipooler:
88+
resources:
89+
requests:
90+
cpu: 50m
91+
memory: 64Mi
92+
limits:
93+
cpu: 200m
94+
memory: 128Mi
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: multigres.com/v1alpha1
2+
kind: TopoServer
3+
metadata:
4+
name: kind-toposerver-sample
5+
namespace: default
6+
spec:
7+
# Root path for topology data in etcd
8+
rootPath: /multigres/global
9+
10+
# etcd container image
11+
image: quay.io/coreos/etcd:v3.5.12
12+
13+
# Number of etcd replicas (must be odd: 1, 3, 5, etc.)
14+
# Using 1 replica for kind to minimize resource usage
15+
replicas: 1
16+
17+
# Storage configuration for etcd data - kind uses local storage provisioner
18+
dataVolumeClaimTemplate:
19+
accessModes:
20+
- ReadWriteOnce
21+
resources:
22+
requests:
23+
storage: 1Gi
24+
25+
# Resource requirements for etcd containers - lower for kind
26+
resources:
27+
requests:
28+
cpu: 50m
29+
memory: 128Mi
30+
limits:
31+
cpu: 200m
32+
memory: 256Mi

0 commit comments

Comments
 (0)