@@ -38,7 +38,34 @@ file, but managed by K8s and versioned.
3838
3939### Secret
4040Same as ConfigMap but for sensitive data (passwords, API keys). Base64-encoded at rest.
41- Like Docker secrets.
41+ Like Docker secrets. Referenced via ` secretRef ` in a Deployment's ` envFrom ` — if listed
42+ after a ConfigMap, Secret values override ConfigMap values with the same key.
43+
44+ ** Important:** Never commit Secrets to git. Create them via ` kubectl create secret ` or
45+ apply a gitignored YAML file. GitHub Push Protection will block pushes containing keys.
46+
47+ ### ServiceMonitor
48+ A Custom Resource (CRD) used by the ** kube-prometheus-stack** to tell Prometheus which
49+ services to scrape. Pod annotations like ` prometheus.io/scrape: "true" ` do ** not** work
50+ with kube-prometheus-stack — you must create a ServiceMonitor instead.
51+
52+ Key gotcha: the ServiceMonitor needs a ` release: prometheus ` label (or whatever label
53+ selector your Prometheus instance uses). Without it, Prometheus silently ignores it.
54+
55+ ``` yaml
56+ apiVersion : monitoring.coreos.com/v1
57+ kind : ServiceMonitor
58+ metadata :
59+ labels :
60+ release : prometheus # required!
61+ spec :
62+ selector :
63+ matchLabels :
64+ app : gateway
65+ endpoints :
66+ - port : http # must match a named port on the Service
67+ path : /metrics
68+ ` ` `
4269
4370---
4471
@@ -57,6 +84,17 @@ How K8s deploys a new version: start new pods, wait until they're ready, then ki
5784At no point are zero pods running. This gives you **zero-downtime deployments**. If the new
5885pods fail their readiness probes, K8s stops the rollout automatically.
5986
87+ # ## `kubectl rollout restart`
88+ Triggers a rolling restart of all pods in a deployment without changing any YAML. Needed
89+ when a ConfigMap or Secret changes — K8s does **not** automatically restart pods when their
90+ ConfigMap values change. You have to tell it to.
91+
92+ ` ` ` bash
93+ kubectl rollout restart deployment/gateway deployment/store-worker
94+ kubectl rollout status deployment/gateway # watch progress
95+ kubectl rollout history deployment/gateway # see past revisions
96+ ` ` `
97+
6098# ## Rollback
6199Undo a deployment : ` kubectl rollout undo deployment/my-app` . K8s keeps the previous pod
62100spec and can revert to it instantly.
@@ -67,6 +105,28 @@ spec and can revert to it instantly.
67105- **Limit:** "This container must never use more than 512MB RAM."
68106 If it exceeds the memory limit, K8s kills it (OOMKilled).
69107
108+ # ## Pod READY Column
109+ When you run `kubectl get pods`, the READY column shows `1/1` or `2/2`. This is
110+ ` READY_CONTAINERS/TOTAL_CONTAINERS` in that pod. A pod with an app + sidecar container
111+ would show `2/2` when both are ready, or `1/2` if one is still starting.
112+
113+ # ## `kubectl get all` Limitations
114+ Despite the name, `kubectl get all` only returns a hardcoded subset : Pods, Services,
115+ Deployments, ReplicaSets, StatefulSets, DaemonSets, Jobs, CronJobs. It does **not**
116+ include HPAs, ConfigMaps, Secrets, Ingresses, PVCs, ServiceMonitors, ScaledObjects, etc.
117+
118+ To see everything in a namespace, be explicit :
119+ ` ` ` bash
120+ kubectl get deploy,svc,hpa,ingress,configmap,scaledobject -n documentstream
121+ ` ` `
122+
123+ # ## Default Namespace
124+ Set a default namespace to avoid typing `-n documentstream` on every command :
125+ ` ` ` bash
126+ kubectl config set-context --current --namespace=documentstream
127+ kubectl config view --minify | grep namespace # verify
128+ ` ` `
129+
70130# ## Horizontal Pod Autoscaler (HPA)
71131Watches a metric (CPU, memory, custom) and adjusts the number of pod replicas. Example :
72132" If average CPU > 70%, add more pods. If < 30%, remove pods." Like auto-scaling in cloud
@@ -154,6 +214,27 @@ not in use (you only pay for disk storage while stopped).
154214
155215# ## Azure Blob Storage
156216Object storage for files (like S3). We store the original PDF files here. Extremely cheap.
217+ PDFs are organized as `{doc_id}/{loan_id}/{doc_type}.pdf` in a container called `documents`.
218+
219+ # ## Azurite
220+ Microsoft's local emulator for Azure Storage. Runs as a Docker container and provides the
221+ same API as real Azure Blob Storage. Used in `docker-compose.yml` for local dev so you don't
222+ need a real Azure account to test blob uploads.
223+
224+ # ## Building and Pushing Images to ACR
225+ `docker build` only creates the image **locally**. To deploy to AKS, you must also push :
226+
227+ ` ` ` bash
228+ # Option 1: Build locally + push (need --platform for ARM Mac → AMD64 cluster)
229+ docker build --platform linux/amd64 -t acrdocumentstream.azurecr.io/gateway:latest -f src/gateway/Dockerfile .
230+ az acr login --name acrdocumentstream
231+ docker push acrdocumentstream.azurecr.io/gateway:latest
232+
233+ # Option 2: Build remotely on ACR (no platform flag needed, builds on Linux)
234+ az acr build --registry acrdocumentstream --image gateway:latest --file src/gateway/Dockerfile .
235+ ` ` `
236+
237+ After pushing, `kubectl rollout restart deployment/gateway` tells K8s to pull the new image.
157238
158239---
159240
0 commit comments