Skip to content

Commit 872880c

Browse files
Anmol1696claude
andcommitted
expand local-simple k8s overlay to full stack
Add all infrastructure needed for a self-contained k8s dev environment without Knative: postgres, minio, constructive-server, db-setup job, job-service, secrets, and configmap. Update function manifests with proper env vars and tsx --watch command for hot reload. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e1639d2 commit 872880c

13 files changed

Lines changed: 483 additions & 4 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: constructive
5+
data:
6+
PORT: "3000"
7+
SERVER_HOST: "0.0.0.0"
8+
SERVER_TRUST_PROXY: "true"
9+
SERVER_ORIGIN: "*"
10+
SERVER_STRICT_AUTH: "false"
11+
12+
PGHOST: "postgres.default.svc.cluster.local"
13+
PGPORT: "5432"
14+
PGDATABASE: "launchql"
15+
16+
API_ENABLE_META: "true"
17+
API_EXPOSED_SCHEMAS: "collections_public,meta_public"
18+
API_ANON_ROLE: "administrator"
19+
API_ROLE_NAME: "administrator"
20+
API_DEFAULT_DATABASE_ID: "dbe"
21+
22+
LOG_TIMESTAMP: "true"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: batch/v1
2+
kind: Job
3+
metadata:
4+
name: constructive-db
5+
spec:
6+
backoffLimit: 6
7+
template:
8+
spec:
9+
restartPolicy: OnFailure
10+
containers:
11+
- name: lql
12+
image: ghcr.io/constructive-io/constructive-db-job:latest
13+
imagePullPolicy: IfNotPresent
14+
env:
15+
- name: LAUNCHQL_DOMAIN
16+
value: "localhost"
17+
envFrom:
18+
- configMapRef:
19+
name: constructive
20+
- secretRef:
21+
name: pg-credentials
22+
command: ["bash", "-c"]
23+
args:
24+
- |
25+
cd /app
26+
echo "Creating database $PGDATABASE"
27+
createdb -h "$PGHOST" -U "$PGUSER" "$PGDATABASE" || true
28+
29+
echo "Applying bootstrap roles"
30+
pgpm admin-users bootstrap --yes
31+
pgpm admin-users add --test --yes
32+
33+
echo "Deploying Services"
34+
pgpm deploy --yes --database "$PGDATABASE" --package app-svc-prod
35+
36+
export LAUNCHQL_DOMAIN="${LAUNCHQL_DOMAIN:-localhost}"
37+
echo "Rename domains to ${LAUNCHQL_DOMAIN}"
38+
psql -h "$PGHOST" -U "$PGUSER" -d "$PGDATABASE" -v ON_ERROR_STOP=1 \
39+
-c "BEGIN;
40+
UPDATE services_public.domains
41+
SET domain = '${LAUNCHQL_DOMAIN}'
42+
WHERE domain = ANY(ARRAY['lql.io', 'constructive.io', 'dbe.la', 'localhost']);
43+
COMMIT;"
44+
45+
echo "Continue with db-meta and pgpm-database-jobs"
46+
pgpm deploy --yes --database "$PGDATABASE" --package metaschema
47+
pgpm deploy --yes --database "$PGDATABASE" --package pgpm-database-jobs
48+
49+
echo "Done"
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: constructive-server
5+
labels:
6+
app: constructive-server
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: constructive-server
12+
template:
13+
metadata:
14+
labels:
15+
app: constructive-server
16+
spec:
17+
containers:
18+
- name: server
19+
image: ghcr.io/constructive-io/constructive:latest
20+
imagePullPolicy: IfNotPresent
21+
command: ["cnc"]
22+
args: ["server", "--port", "3000", "--origin", "*", "--strictAuth", "false"]
23+
envFrom:
24+
- configMapRef:
25+
name: constructive
26+
- secretRef:
27+
name: pg-credentials
28+
- secretRef:
29+
name: constructive-uploads
30+
env:
31+
- name: BUCKET_NAME
32+
value: constructive-uploads
33+
- name: AWS_REGION
34+
value: us-east-1
35+
- name: LOG_LEVEL
36+
value: debug
37+
- name: MINIO_ENDPOINT
38+
value: "http://minio:9000"
39+
ports:
40+
- containerPort: 3000
41+
name: server-http
42+
readinessProbe:
43+
httpGet:
44+
path: /healthz
45+
port: server-http
46+
initialDelaySeconds: 5
47+
periodSeconds: 10
48+
livenessProbe:
49+
httpGet:
50+
path: /healthz
51+
port: server-http
52+
initialDelaySeconds: 10
53+
periodSeconds: 20
54+
resources:
55+
requests:
56+
cpu: "100m"
57+
memory: "256Mi"
58+
limits:
59+
cpu: "300m"
60+
memory: "512Mi"
61+
- name: explorer
62+
image: ghcr.io/constructive-io/constructive:latest
63+
imagePullPolicy: IfNotPresent
64+
command: ["cnc"]
65+
args: ["explorer", "--port", "3001", "--origin", "*"]
66+
envFrom:
67+
- configMapRef:
68+
name: constructive
69+
- secretRef:
70+
name: pg-credentials
71+
env:
72+
- name: PORT
73+
value: "3001"
74+
ports:
75+
- containerPort: 3001
76+
name: explorer-http
77+
readinessProbe:
78+
httpGet:
79+
path: /healthz
80+
port: explorer-http
81+
initialDelaySeconds: 5
82+
periodSeconds: 10
83+
livenessProbe:
84+
httpGet:
85+
path: /healthz
86+
port: explorer-http
87+
initialDelaySeconds: 10
88+
periodSeconds: 20
89+
resources:
90+
requests:
91+
cpu: "50m"
92+
memory: "128Mi"
93+
limits:
94+
cpu: "200m"
95+
memory: "256Mi"
96+
---
97+
apiVersion: v1
98+
kind: Service
99+
metadata:
100+
name: constructive-server
101+
spec:
102+
type: ClusterIP
103+
selector:
104+
app: constructive-server
105+
ports:
106+
- name: http
107+
port: 3000
108+
targetPort: server-http
109+
- name: explorer
110+
port: 3001
111+
targetPort: explorer-http
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: knative-job-service
5+
labels:
6+
app: knative-job-service
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: knative-job-service
12+
template:
13+
metadata:
14+
labels:
15+
app: knative-job-service
16+
spec:
17+
containers:
18+
- name: knative-job-service
19+
image: constructive-functions:local
20+
command: ["node"]
21+
args: ["job/service/dist/run.js"]
22+
envFrom:
23+
- configMapRef:
24+
name: constructive
25+
- secretRef:
26+
name: pg-credentials
27+
env:
28+
- name: NODE_ENV
29+
value: "development"
30+
- name: INTERNAL_JOBS_CALLBACK_PORT
31+
value: "8080"
32+
- name: INTERNAL_JOBS_CALLBACK_URL
33+
value: "http://knative-job-service.default.svc.cluster.local:8080"
34+
- name: JOBS_SUPPORT_ANY
35+
value: "false"
36+
- name: JOBS_SUPPORTED
37+
value: "simple-email,send-email-link"
38+
- name: JOBS_CALLBACK_HOST
39+
value: "knative-job-service.default.svc.cluster.local"
40+
- name: JOBS_CALLBACK_BASE_URL
41+
value: "http://knative-job-service.default.svc.cluster.local:8080/callback"
42+
- name: KNATIVE_SERVICE_URL
43+
value: "default.svc.cluster.local"
44+
- name: INTERNAL_GATEWAY_URL
45+
value: "http://simple-email.default.svc.cluster.local"
46+
- name: INTERNAL_GATEWAY_DEVELOPMENT_MAP
47+
value: '{"simple-email":"http://simple-email.default.svc.cluster.local","send-email-link":"http://send-email-link.default.svc.cluster.local"}'
48+
- name: HOSTNAME
49+
valueFrom:
50+
fieldRef:
51+
fieldPath: metadata.name
52+
ports:
53+
- containerPort: 8080
54+
name: jobs-http
55+
resources:
56+
requests:
57+
memory: "128Mi"
58+
cpu: "100m"
59+
limits:
60+
memory: "512Mi"
61+
cpu: "500m"
62+
---
63+
apiVersion: v1
64+
kind: Service
65+
metadata:
66+
name: knative-job-service
67+
labels:
68+
app: knative-job-service
69+
spec:
70+
type: ClusterIP
71+
selector:
72+
app: knative-job-service
73+
ports:
74+
- name: jobs-http
75+
port: 8080
76+
targetPort: jobs-http
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33

4+
namespace: default
5+
46
resources:
5-
- simple-email.yaml
6-
- send-email-link.yaml
7+
# Infrastructure
8+
- ./postgres-local.yaml
9+
- ./minio-local.yaml
10+
# Secrets & config
11+
- ./config.yaml
12+
- ./pg-secret.yaml
13+
- ./mailgun-secret.yaml
14+
- ./server-bucket-secret.yaml
15+
# Constructive server + db setup
16+
- ./constructive-server.yaml
17+
- ./constructive-db-job.yaml
18+
# Job service
19+
- ./job-service.yaml
20+
# Functions (plain Deployments, no Knative)
21+
- ./simple-email.yaml
22+
- ./send-email-link.yaml
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: mailgun-credentials
5+
stringData:
6+
MAILGUN_API_KEY: "empty-mailgun-api-key"
7+
MAILGUN_KEY: "empty-mailgun-key"
8+
MAILGUN_DOMAIN: "empty.mailgun.domain"
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: minio
5+
labels:
6+
app: minio
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: minio
12+
template:
13+
metadata:
14+
labels:
15+
app: minio
16+
spec:
17+
containers:
18+
- name: minio
19+
image: minio/minio:latest
20+
args:
21+
- server
22+
- /data
23+
env:
24+
- name: MINIO_ACCESS_KEY
25+
value: minioadmin
26+
- name: MINIO_SECRET_KEY
27+
value: minioadmin
28+
ports:
29+
- containerPort: 9000
30+
name: http
31+
volumeMounts:
32+
- name: data
33+
mountPath: /data
34+
resources:
35+
requests:
36+
cpu: "100m"
37+
memory: "128Mi"
38+
limits:
39+
cpu: "300m"
40+
memory: "256Mi"
41+
volumes:
42+
- name: data
43+
emptyDir: {}
44+
---
45+
apiVersion: v1
46+
kind: Service
47+
metadata:
48+
name: minio
49+
labels:
50+
app: minio
51+
spec:
52+
type: ClusterIP
53+
selector:
54+
app: minio
55+
ports:
56+
- name: http
57+
port: 9000
58+
targetPort: http
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: default
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: pg-credentials
5+
stringData:
6+
PGUSER: postgres
7+
PGPASSWORD: postgres123!

0 commit comments

Comments
 (0)