Project Workshop — DocuMind K8s Production Setup
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
Kubernetes · Helm · Ingress · KEDA · cert-manager · RBAC
Expected effort: 20–32 focused hours · Minimum meaningful tests: 12What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | Nginx Ingress + Cert-Manager automatic TLS produces the specified behavior inside Ingress, HPA & KEDA | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | HPA: CPU/memory targets produces the specified behavior inside Ingress, HPA & KEDA | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | custom metrics HPA (requests per second) produces the specified behavior inside Ingress, HPA & KEDA | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | KEDA: event-driven scaling (Kafka lag/queue depth) produces the specified behavior inside Ingress, HPA & KEDA | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.5 | PodDisruptionBudget for availability produces the specified behavior inside Ingress, HPA & KEDA | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | Chart.yaml/values.yaml/templates/ structure produces the specified behavior inside Helm charts | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | {{ .Values.image.tag }} template syntax produces the specified behavior inside Helm charts | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | _helpers.tpl for reusable templates produces the specified behavior inside Helm charts | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.4 | helm install/upgrade/rollback/lint/template produces the specified behavior inside Helm charts | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.5 | pre-install migration job hooks produces the specified behavior inside Helm charts | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | ServiceAccount/Role/ClusterRole/RoleBinding produces the specified behavior inside RBAC & PersistentVolumes | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | kubectl auth can-i auditing produces the specified behavior inside RBAC & PersistentVolumes | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.3 | PV/PVC with dynamic StorageClass produces the specified behavior inside RBAC & PersistentVolumes | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.4 | StatefulSet volumeClaimTemplates produces the specified behavior inside RBAC & PersistentVolumes | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | ReadWriteOnce/ReadOnlyMany/ReadWriteMany/ReadWriteOncePod access modes produces the specified behavior inside Storage & pod security details | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | PVC online expansion prerequisites produces the specified behavior inside Storage & pod security details | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | fsGroup/runAsUser/runAsNonRoot/readOnlyRootFilesystem produces the specified behavior inside Storage & pod security details | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | capability drop and seccomp RuntimeDefault produces the specified behavior inside Storage & pod security details | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1delivery/2├── app/3├── Dockerfile4├── compose.yaml5├── .github/workflows/6├── deploy/{base,overlays,helm}/7├── cloud/{sam,terraform}/8├── observability/{prometheus,grafana,otel,alerts}/9├── tests/{smoke,policy,load}/10└── runbooks/Build plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | Ingress, HPA & KEDA | Nginx Ingress + Cert-Manager automatic TLS; HPA: CPU/memory targets; custom metrics HPA (requests per second) | Demonstration plus focused tests |
| 2 | Helm charts | Chart.yaml/values.yaml/templates/ structure; {{ .Values.image.tag }} template syntax; _helpers.tpl for reusable templates | Demonstration plus focused tests |
| 3 | RBAC & PersistentVolumes | ServiceAccount/Role/ClusterRole/RoleBinding; kubectl auth can-i auditing; PV/PVC with dynamic StorageClass | Demonstration plus focused tests |
| 4 | Storage & pod security details | ReadWriteOnce/ReadOnlyMany/ReadWriteMany/ReadWriteOncePod access modes; PVC online expansion prerequisites; fsGroup/runAsUser/runAsNonRoot/readOnlyRootFilesystem | Demonstration plus focused tests |
| 5 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1apiVersion: autoscaling/v22kind: HorizontalPodAutoscaler3metadata: {name: documind-api}4spec:5 scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: documind-api}6 minReplicas: 27 maxReplicas: 108 behavior:9 scaleDown:10 stabilizationWindowSeconds: 30011 metrics:12 - type: Resource13 resource:14 name: cpu15 target: {type: Utilization, averageUtilization: 70}16---17apiVersion: policy/v118kind: PodDisruptionBudget19metadata: {name: documind-api}20spec: {minAvailable: 1, selector: {matchLabels: {app: documind-api}}}Expected result
1CPU pressure scales within 2–10 replicas; voluntary disruption keeps at least one selected Pod available.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | apiVersion: autoscaling/v2 | Declares one level of a desired-state or automation document. |
| 2 | kind: HorizontalPodAutoscaler | Declares one level of a desired-state or automation document. |
| 3 | metadata: {name: documind-api} | Declares one level of a desired-state or automation document. |
| 4 | spec: | Declares one level of a desired-state or automation document. |
| 5 | scaleTargetRef: {apiVersion: apps/v1, kind: Deployment, name: documind-api} | Implements the next yaml statement in the example's data flow. |
| 6 | minReplicas: 2 | Implements the next yaml statement in the example's data flow. |
| 7 | maxReplicas: 10 | Implements the next yaml statement in the example's data flow. |
| 8 | behavior: | Implements the next yaml statement in the example's data flow. |
| 9 | scaleDown: | Implements the next yaml statement in the example's data flow. |
| 10 | stabilizationWindowSeconds: 300 | Implements the next yaml statement in the example's data flow. |
| 11 | metrics: | Implements the next yaml statement in the example's data flow. |
| 12 | - type: Resource | Implements the next yaml statement in the example's data flow. |
| 13 | resource: | Implements the next yaml statement in the example's data flow. |
| 14 | name: cpu | Implements the next yaml statement in the example's data flow. |
| 15 | target: {type: Utilization, averageUtilization: 70} | Implements the next yaml statement in the example's data flow. |
| 16 | --- | Implements the next yaml statement in the example's data flow. |
| 17 | apiVersion: policy/v1 | Declares one level of a desired-state or automation document. |
| 18 | kind: PodDisruptionBudget | Declares one level of a desired-state or automation document. |
| 19 | metadata: {name: documind-api} | Declares one level of a desired-state or automation document. |
| 20 | spec: {minAvailable: 1, selector: {matchLabels: {app: documind-api}}} | Declares one level of a desired-state or automation document. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| Ingress, HPA & KEDA | Kafka lag here is a scaling signal, not the SQL LAG window function; autoscaling cannot repair an exhausted database. | Set realistic requests, stabilize scale decisions, test zero-to-one activation, and monitor the downstream bottleneck as replicas grow. |
| Helm charts | A Helm migration hook is not a Django migration explanation, and rolling manifests back cannot undo arbitrary data changes. | Keep defaults safe, validate values, render and lint in CI, make hooks idempotent, and use expand-migrate-contract for schemas. |
| RBAC & PersistentVolumes | Kubernetes RBAC is not JWT application authorization, and deleting a claim can delete data under some reclaim policies. | Grant namespaced least privilege, test permissions with auth can-i, select access modes from the storage backend, and rehearse restore and expansion. |
| Storage & pod security details | Granting broad capabilities such as SYS_ADMIN or disabling seccomp turns a small application exploit into a much larger host/kernel attack surface. | Drop all capabilities, add back only a measured requirement, avoid privilege escalation, and run integration tests under the production seccomp profile. |
Engineering checklist for this stack
- To do: run with least privilege and immutable artifacts
- To do: declare resource bounds and health behavior
- To do: separate secrets from versioned configuration
- To do: prove rollback and restore
- To do: correlate deployment version with metrics, logs, and traces
Test strategy
Implement at least 12 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 4 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1set -euo pipefail2docker build --check .3trivy image --exit-code 1 "$IMAGE_DIGEST"4helm lint ./deploy/helm5helm template test ./deploy/helm | kubeconform -strict6pytest -q tests/smoke7locust --headless --users 100 --spawn-rate 10 --run-time 2mFailure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?