diff --git a/apps/api/infra/base/deployment.yaml b/apps/api/infra/base/deployment.yaml new file mode 100644 index 0000000..51e72d8 --- /dev/null +++ b/apps/api/infra/base/deployment.yaml @@ -0,0 +1,59 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: shannon-api + namespace: shannon + labels: + app: shannon-api +spec: + replicas: 1 + selector: + matchLabels: + app: shannon-api + template: + metadata: + labels: + app: shannon-api + spec: + serviceAccountName: shannon-api + containers: + - name: api + image: keygraph/shannon-api:latest + ports: + - containerPort: 3000 + name: http + env: + - name: TEMPORAL_ADDRESS + value: shannon-temporal:7233 + - name: WORKER_IMAGE + value: keygraph/shannon:latest + - name: K8S_NAMESPACE + value: shannon + envFrom: + - secretRef: + name: shannon-credentials + volumeMounts: + - name: workspaces + mountPath: /app/workspaces + livenessProbe: + httpGet: + path: /healthz + port: 3000 + initialDelaySeconds: 5 + periodSeconds: 10 + readinessProbe: + httpGet: + path: /readyz + port: 3000 + initialDelaySeconds: 10 + periodSeconds: 10 + resources: + requests: + memory: 128Mi + cpu: 100m + limits: + memory: 256Mi + volumes: + - name: workspaces + persistentVolumeClaim: + claimName: shannon-workspaces diff --git a/apps/api/infra/base/kustomization.yaml b/apps/api/infra/base/kustomization.yaml new file mode 100644 index 0000000..834c27d --- /dev/null +++ b/apps/api/infra/base/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - deployment.yaml + - service.yaml + - serviceaccount.yaml + - rbac.yaml diff --git a/apps/api/infra/base/rbac.yaml b/apps/api/infra/base/rbac.yaml new file mode 100644 index 0000000..05330f2 --- /dev/null +++ b/apps/api/infra/base/rbac.yaml @@ -0,0 +1,29 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: shannon-api + namespace: shannon +rules: + - apiGroups: ["batch"] + resources: ["jobs"] + verbs: ["create", "get", "list", "delete", "watch"] + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["pods/log"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: shannon-api + namespace: shannon +subjects: + - kind: ServiceAccount + name: shannon-api + namespace: shannon +roleRef: + kind: Role + name: shannon-api + apiGroup: rbac.authorization.k8s.io diff --git a/apps/api/infra/base/service.yaml b/apps/api/infra/base/service.yaml new file mode 100644 index 0000000..bec4d79 --- /dev/null +++ b/apps/api/infra/base/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: shannon-api + namespace: shannon +spec: + selector: + app: shannon-api + ports: + - name: http + port: 3000 + targetPort: 3000 diff --git a/apps/api/infra/base/serviceaccount.yaml b/apps/api/infra/base/serviceaccount.yaml new file mode 100644 index 0000000..07d0dc2 --- /dev/null +++ b/apps/api/infra/base/serviceaccount.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: shannon-api + namespace: shannon diff --git a/apps/api/infra/overlays/dev/kustomization.yaml b/apps/api/infra/overlays/dev/kustomization.yaml new file mode 100644 index 0000000..0ffc74f --- /dev/null +++ b/apps/api/infra/overlays/dev/kustomization.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../base +patches: + - patch: |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: shannon-api + spec: + template: + spec: + containers: + - name: api + imagePullPolicy: Never diff --git a/apps/cli/infra/k8s/namespace.yaml b/apps/cli/infra/k8s/namespace.yaml new file mode 100644 index 0000000..9472cb7 --- /dev/null +++ b/apps/cli/infra/k8s/namespace.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: shannon + labels: + app.kubernetes.io/part-of: shannon diff --git a/apps/cli/infra/k8s/router.yaml b/apps/cli/infra/k8s/router.yaml new file mode 100644 index 0000000..4a0e7b5 --- /dev/null +++ b/apps/cli/infra/k8s/router.yaml @@ -0,0 +1,69 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: shannon-router + namespace: shannon + labels: + app: shannon-router +spec: + replicas: 1 + selector: + matchLabels: + app: shannon-router + template: + metadata: + labels: + app: shannon-router + spec: + containers: + - name: router + image: node:20-slim + command: + - sh + - -c + - | + apt-get update && apt-get install -y gettext-base && + npm install -g @musistudio/claude-code-router && + mkdir -p /root/.claude-code-router && + envsubst < /config/router-config.json > /root/.claude-code-router/config.json && + ccr start + ports: + - containerPort: 3456 + envFrom: + - secretRef: + name: shannon-credentials + env: + - name: HOST + value: "0.0.0.0" + volumeMounts: + - name: config + mountPath: /config + readOnly: true + readinessProbe: + httpGet: + path: /health + port: 3456 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 5 + resources: + requests: + memory: 128Mi + cpu: 100m + volumes: + - name: config + configMap: + name: shannon-router-config +--- +apiVersion: v1 +kind: Service +metadata: + name: shannon-router + namespace: shannon +spec: + selector: + app: shannon-router + ports: + - port: 3456 + targetPort: 3456 diff --git a/apps/cli/infra/k8s/temporal.yaml b/apps/cli/infra/k8s/temporal.yaml new file mode 100644 index 0000000..3232aeb --- /dev/null +++ b/apps/cli/infra/k8s/temporal.yaml @@ -0,0 +1,86 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: temporal-data + namespace: shannon +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: shannon-temporal + namespace: shannon + labels: + app: shannon-temporal +spec: + replicas: 1 + selector: + matchLabels: + app: shannon-temporal + template: + metadata: + labels: + app: shannon-temporal + spec: + containers: + - name: temporal + image: temporalio/temporal:latest + command: + - server + - start-dev + - --db-filename + - /home/temporal/temporal.db + - --ip + - "0.0.0.0" + ports: + - containerPort: 7233 + name: grpc + - containerPort: 8233 + name: web-ui + volumeMounts: + - name: data + mountPath: /home/temporal + readinessProbe: + exec: + command: + - temporal + - operator + - cluster + - health + - --address + - localhost:7233 + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 5 + failureThreshold: 10 + resources: + requests: + memory: 256Mi + cpu: 250m + limits: + memory: 512Mi + volumes: + - name: data + persistentVolumeClaim: + claimName: temporal-data +--- +apiVersion: v1 +kind: Service +metadata: + name: shannon-temporal + namespace: shannon +spec: + selector: + app: shannon-temporal + ports: + - name: grpc + port: 7233 + targetPort: 7233 + - name: web-ui + port: 8233 + targetPort: 8233