Deploying the API

Deploying BookNest's API with a Deployment

The commands above drifted the cluster from k8s/api-deployment.yaml. Put the release in the file and apply it:

Releasing 1.4 from the manifest, then checking every replicaYAML
sed -i 's/booknest-api:1.3/booknest-api:1.4/; s/API 1.3/API 1.4/' k8s/api-deployment.yaml
kubectl diff -f k8s/api-deployment.yaml | grep -E '^[-+] ' | grep -v generation
kubectl apply -f k8s/api-deployment.yaml && kubectl rollout status deployment/api >/dev/null
kubectl get deployment api
R=$(kubectl get pods -l tier=api --field-selector=status.phase=Running -o name)
for p in $R; do echo -n "$p "
  kubectl exec $p -- node -e "fetch('http://localhost:3000/version').then(r => r.text())
    .then(console.log)"; done
Output
-            cpu: 100m
+            cpu: 50m
deployment.apps/api configured
NAME   READY   UP-TO-DATE   AVAILABLE   AGE
api    3/3     3            3           2m52s
pod/api-7bf856ff84-5nbtd {"version":"1.4.0"}
pod/api-7bf856ff84-fm8wj {"version":"1.4.0"}
pod/api-7bf856ff84-m74bt {"version":"1.4.0"}

The diff found one leftover, Pausing and Resuming a Rollout's CPU request. The template then matched revision 2 exactly, so the Deployment scaled ReplicaSet 7bf856ff84 back up rather than create one. On an empty database, three new replicas would race to create the schema; Migration Job moves that into a migration Job.