Skip to content

Commit b01f022

Browse files
committed
docs: add multi-user self-service provisioning guide
Document how users can self-provision TinycodeInstance CRs with appropriate RBAC. No operator changes required — just a ClusterRole and per-namespace RoleBindings.
1 parent 4649c9c commit b01f022

1 file changed

Lines changed: 169 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,175 @@ Together, Tekton + Argo CD cover everything the operator + GitHub Actions do tod
204204

205205
Making the operator itself Kubernetes-portable (auto-detecting OpenShift vs vanilla Kubernetes and falling back to `Ingress` when SCCs are unavailable) is a potential enhancement for future releases.
206206

207+
## Multi-User Self-Service Provisioning
208+
209+
**Primary deployment model**: One `TinycodeInstance` CR per user, managed centrally by a cluster-admin in the "Creating a TinycodeInstance" section above.
210+
211+
**Alternative for self-service teams**: Users can provision their own `TinycodeInstance` CRs if your team prefers a self-service model. No code changes to the operator are required — it already watches all namespaces and scopes all resources (Deployments, Services, Routes, PVCs, ServiceAccounts, SCC bindings) by CR name + namespace. Two users in different namespaces get completely isolated resources with no collisions.
212+
213+
### Setup (Cluster-Admin, One-Time)
214+
215+
1. **Create a ClusterRole** granting users permission to manage their own TinycodeInstance CRs:
216+
217+
```yaml
218+
---
219+
apiVersion: rbac.authorization.k8s.io/v1
220+
kind: ClusterRole
221+
metadata:
222+
name: tinycode-user-role
223+
rules:
224+
- apiGroups:
225+
- tinycode.dev
226+
resources:
227+
- tinycodeinstances
228+
verbs:
229+
- create
230+
- get
231+
- list
232+
- watch
233+
- delete
234+
```
235+
236+
Save this as `tinycode-user-role.yaml` and apply once:
237+
238+
```bash
239+
oc apply -f tinycode-user-role.yaml
240+
```
241+
242+
### Per-User Setup (Cluster-Admin or Delegated)
243+
244+
For each user who will self-provision, create a namespace and bind the ClusterRole:
245+
246+
```yaml
247+
---
248+
apiVersion: v1
249+
kind: Namespace
250+
metadata:
251+
name: tinycode-alice
252+
253+
---
254+
apiVersion: rbac.authorization.k8s.io/v1
255+
kind: RoleBinding
256+
metadata:
257+
name: alice-tinycode-user
258+
namespace: tinycode-alice
259+
roleRef:
260+
apiGroup: rbac.authorization.k8s.io
261+
kind: ClusterRole
262+
name: tinycode-user-role
263+
subjects:
264+
- kind: User
265+
name: alice@example.com
266+
apiGroup: rbac.authorization.k8s.io
267+
```
268+
269+
Save as `alice-tinycode-rolebinding.yaml` and apply:
270+
271+
```bash
272+
oc apply -f alice-tinycode-rolebinding.yaml
273+
```
274+
275+
The user also needs to create Secrets (password) in their namespace. Grant that permission by adding a namespace Role:
276+
277+
```yaml
278+
---
279+
apiVersion: rbac.authorization.k8s.io/v1
280+
kind: Role
281+
metadata:
282+
name: tinycode-secret-creator
283+
namespace: tinycode-alice
284+
rules:
285+
- apiGroups:
286+
- ""
287+
resources:
288+
- secrets
289+
verbs:
290+
- create
291+
- get
292+
293+
---
294+
apiVersion: rbac.authorization.k8s.io/v1
295+
kind: RoleBinding
296+
metadata:
297+
name: alice-secret-creator
298+
namespace: tinycode-alice
299+
roleRef:
300+
apiGroup: rbac.authorization.k8s.io
301+
kind: Role
302+
name: tinycode-secret-creator
303+
subjects:
304+
- kind: User
305+
name: alice@example.com
306+
apiGroup: rbac.authorization.k8s.io
307+
```
308+
309+
### User Workflow (Self-Service)
310+
311+
Once the cluster-admin has set up the namespace and RoleBinding, the user can:
312+
313+
```bash
314+
# 1. Create a password secret in their namespace
315+
oc create secret generic tinycode-password \
316+
--from-literal=TINYCODE_SERVER_PASSWORD=mypassword \
317+
-n tinycode-alice
318+
319+
# 2. Create their TinycodeInstance CR
320+
oc apply -f - <<EOF
321+
---
322+
apiVersion: tinycode.dev/v1alpha1
323+
kind: TinycodeInstance
324+
metadata:
325+
name: alice-dev
326+
namespace: tinycode-alice
327+
spec:
328+
image: quay.io/bjohns/tinycode-container:latest
329+
replicas: 1
330+
resources:
331+
limits:
332+
cpu: "2"
333+
memory: "2Gi"
334+
requests:
335+
cpu: "200m"
336+
memory: "512Mi"
337+
storage:
338+
dataSize: "1Gi"
339+
projectsSize: "10Gi"
340+
auth:
341+
passwordSecret: tinycode-password
342+
tlsTermination: edge
343+
EOF
344+
345+
# 3. Wait for the instance to be ready
346+
oc get tinycodeinstance alice-dev -n tinycode-alice -w
347+
348+
# 4. Get the URL
349+
oc get tinycodeinstance alice-dev -n tinycode-alice -o jsonpath='{.status.url}'
350+
```
351+
352+
### Resource Consumption
353+
354+
Each user gets their own pod, PVCs (data and projects), and OpenShift Route. This is **instance-per-user isolation**, not shared multi-tenancy. Resource consumption scales linearly with users:
355+
356+
- **Default limits**: 2 CPU, 2Gi memory per instance
357+
- **Default requests**: 200m CPU, 512Mi memory per instance
358+
- **Storage**: 1Gi (config/DB) + 10Gi (projects) per instance
359+
360+
For 10 users with default settings, the cluster needs capacity for at least 2 CPU cores and 5Gi memory across all tinycode instances, plus infrastructure and other workloads.
361+
362+
### Cleanup
363+
364+
A user can delete their instance:
365+
366+
```bash
367+
oc delete tinycodeinstance alice-dev -n tinycode-alice
368+
```
369+
370+
Cluster-admin can revoke access by removing the RoleBinding:
371+
372+
```bash
373+
oc delete rolebinding alice-tinycode-user -n tinycode-alice
374+
```
375+
207376
## Project Structure
208377

209378
```

0 commit comments

Comments
 (0)