KKIMS on-site docs
Operate and troubleshoot

Day two

Running KIMS v2 after go-live. Deploy new code through Git and the kims-platform job, roll back the code or the website, scale the CMS and worker, read the logs, run a scheduled task by hand, look at the jobs and site_builds tables, watch for alerts, and change a Secret.

Everything here uses production's namespace kims and Jenkins folder kims-production. For UAT use kims-uat for both. The commands are the same on Linux, macOS and Windows (PowerShell); where a line differs, it is shown per system.

Run kubectl against KIMS's cluster: add --context <KIMS_EKS_CONTEXT> to every command, or select it first with kubectl config use-context <KIMS_EKS_CONTEXT>. The examples leave it out for readability.

#What runs where

Piece Kubernetes object What it does
CMS Deployment kims-cms (2 replicas), Service kims-cms, container cms The editors' screens and the API
Worker Deployment kims-worker (1 replica) Runs the queued jobs: publish, translation, media sizes, site-build trigger, alerts, Google reviews
Migrations Job kims-migrate, a Helm pre-install,pre-upgrade hook Applies new SQL migrations before each deploy; kept until the next one
Scheduled tasks CronJobs kims-cron-scheduled-publish-tick, -translation-tick, -site-build-reap, -alerts, -reviews-sync Each run only queues a job; the worker does the work
Website Jenkins job kims-site-build, S3 website bucket, CloudFront Built from a published version; not in the cluster

The CMS and the worker share one database and the jobs table: a worker claims a job with FOR UPDATE SKIP LOCKED, so more than one worker pod is safe.

#Deploy new code

Code reaches KIMS only through their Git and the kims-platform job. Nothing is deployed from a laptop.

#Production only

  1. Push the change to main in KIMS's Git (Push the code).
  2. In Jenkins, kims-production folder, kims-platform, Build with Parameters (or let the Git trigger start it, if KIMS set one up).
  3. The job runs Checkout, Install (npm ci), Verify (npm run verify: lint, types, tests), Image (tagged with the full commit SHA, linux/amd64,linux/arm64), Deploy (helm upgrade --install ... --wait --timeout 10m, then kubectl rollout status deployment/kims-cms).
  4. It ends Deployed <registry>/kims/kims-v2:<sha> to production (namespace kims).

#With UAT

  1. Push to uat; kims-uat/kims-platform deploys it to namespace kims-uat.
  2. KIMS accepts it on UAT.
  3. Move main to the same commit. From the repo on your machine, with KIMS's Git as remote kims:
bash
git push kims uat:main

It only succeeds as a fast-forward: main is never ahead of uat.

  1. Run kims-production/kims-platform. It finds the image for that commit already in the registry (UAT built it) and reuses it, so production runs exactly what UAT tested.

Details of the job, its parameters and guards: Platform job, Environments.

#What a deploy does to the database

The kims-migrate hook runs before any pod is replaced. If a migration fails, Helm stops, and the running version stays up untouched. Read why:

bash
kubectl -n kims logs job/kims-migrate

A good run ends [migrate] done: N applied, M already in place. The job's failure message in Jenkins also names this command.

#Watch a deploy from your side

bash
kubectl -n kims get pods -w
kubectl -n kims rollout status deployment/kims-cms --timeout 5m
kubectl -n kims rollout status deployment/kims-worker --timeout 5m

Then check it all with deploy.mjs, from <KIMS_FOLDER>:

bash
node deployment-steps/scripts/deploy.mjs kims check --context <KIMS_EKS_CONTEXT>

It ends OK: the deploy in kims is healthy. (Use --namespace kims-uat for UAT.)

#Which version is running

bash
helm -n kims history kims
kubectl -n kims get deployment kims-cms -o jsonpath="{.spec.template.spec.containers[0].image}"

The image tag is the Git commit. helm history lists each revision with its status (deployed, superseded, failed) and time.

On PowerShell the jsonpath line works as written, in double quotes.

#Roll back the code

Two ways. Both leave the database as it is: migrations only go forward, and Helm doesn't run the migrate hook on a rollback. Rolling back is safe when the newer migrations only added things (tables, columns, indexes), which is how this repo's migrations are written. If a release's notes say a migration changed or removed something, ask the developers before rolling back over it.

#Through Git (preferred)

Revert the bad commit on the branch and push; the kims-platform job deploys the new commit like any other. Git, Jenkins and the cluster stay in agreement, and the next deploy doesn't bring the bad code back.

bash
git revert <BAD_COMMIT_SHA>
git push kims main

With UAT, revert on uat first and promote as usual.

#With Helm (fastest)

bash
helm -n kims history kims
helm -n kims rollback kims <REVISION> --wait --timeout 10m

<REVISION> is the number of the last good row in history. Helm puts back that revision's image and values; the pods restart on the old image (it is still in the registry, tagged with its commit). Then check with kims check.

Warning

A Helm rollback is undone by the next kims-platform run, which deploys the branch's newest commit again. Revert the commit in Git too, before anyone runs the job.

#Roll back the website

The website is built from a published version of the content. The site build has a live guard: it never goes back. A build of a version older than the one live is recorded as skipped and changes nothing; a rebuild of the version that is already live goes ahead.

So to undo a bad change on the website:

  1. In the CMS, open the page, its version history, and restore the earlier version.
  2. Get it reviewed and publish. That makes a new published version, with the old content.
  3. The worker asks Jenkins for a build of it; the Builds screen follows it to live (about 15 minutes for all three languages).

To rebuild the version that is already live (for example after the website bucket was emptied, or a build half-deployed), run kims-production/kims-site-build with Build with Parameters, PUBLISH_VERSION set to the live version and CAUSE rebuild. The CMS Builds screen shows which version is live.

The same applies to code that only changes the website's look: once the code is rolled back, rebuild the live version so the website picks it up.

#Restart the CMS or the worker

After a Secret changed, or to clear a stuck process:

bash
kubectl -n kims rollout restart deployment/kims-cms deployment/kims-worker
kubectl -n kims rollout status deployment/kims-cms

With two CMS replicas and the PodDisruptionBudget (minAvailable: 1), the CMS stays up during the restart. The worker stops taking new jobs on SIGTERM, waits up to 25 seconds for the ones in hand, and any job still running is taken over by the next pod once its lock lapses (5 minutes by default).

#Scale

All sizes are in the environment's Helm values file, held in Jenkins as the kims-helm-values credential of the folder. Change the file, replace the credential, then run kims-platform. A kubectl scale works at once but the next deploy puts the file's number back.

What Values key Default When to change
CMS pods cms.replicas 2 Many editors at once, or slow screens with CPU near the limit
CMS CPU and memory cms.resources request 250m / 512Mi, limit 1 CPU / 1Gi Pods OOMKilled or throttled
Worker pods worker.replicas 1 A long queue of jobs (see the queries below)
Jobs one worker runs at once env.WORKER_CONCURRENCY 2 Same, without more pods
Worker CPU and memory worker.resources as the CMS Media resizing OOMKilled
Database connections per process env.DATABASE_POOL_MAX 10 See below
Cron schedules cron.tasks[].schedule see Helm values Rarely

To scale at once (until the next deploy), for example during a busy day:

bash
kubectl -n kims scale deployment/kims-worker --replicas=2

#Database connections

Each process opens up to DATABASE_POOL_MAX connections. Add up every CMS pod, every worker pod, a cron pod or two, a migrate Job during deploys, and the Jenkins site build's export: with the defaults that is roughly (2 + 1 + 2 + 1) × 10 = 60. RDS's limit depends on the instance class (max_connections, shown in the RDS console's parameter group). If the logs show remaining connection slots are reserved, lower DATABASE_POOL_MAX or ask KIMS for a larger class.

#Logs

The apps write one JSON object per line to standard output. KIMS's cluster log shipping (if they have it, for example CloudWatch Container Insights) collects them; the chart doesn't set any up. With kubectl:

To read Command
The CMS, last hour kubectl -n kims logs deploy/kims-cms -c cms --since=1h
Every CMS pod, not just one kubectl -n kims logs -l app.kubernetes.io/component=cms -c cms --since=1h --prefix
The worker, following kubectl -n kims logs deploy/kims-worker -f
A pod that restarted, before the restart kubectl -n kims logs <POD_NAME> --previous
The last migration kubectl -n kims logs job/kims-migrate
A CronJob's runs kubectl -n kims get jobs then kubectl -n kims logs job/<JOB_NAME>
Why a pod won't start kubectl -n kims describe pod <POD_NAME> (the Events at the bottom)
Recent events in the namespace kubectl -n kims get events --sort-by=.lastTimestamp

deploy/kims-cms picks one pod; with two replicas, a request may have gone to the other, so use the label line to see both.

To search the worker's log for one thing:

bash
kubectl -n kims logs deploy/kims-worker --since=24h | grep '"level":"alert"'
bash
kubectl -n kims logs deploy/kims-worker --since=24h | grep '"level":"alert"'
powershell
kubectl -n kims logs deploy/kims-worker --since=24h | Select-String '"level":"alert"'

#Alerts

The alerts scheduled task looks at recent publishes and builds and writes one log line at level alert per problem, once (it remembers what it already reported). There are two conditions:

condition Means First look at
publish-without-build A publish finished but no site build started for it The worker log (Jenkins URL, user, token): Troubleshooting
build-failed A site build failed The Builds screen, then the Jenkins build's console

The line's subject starts [KIMS <environment>]. Nothing is emailed by the app: to be told, KIMS points an alarm in their log tooling at lines containing "level":"alert" (for example a CloudWatch Logs metric filter).

#Run a scheduled task by hand

Each CronJob only queues its job; making a one-off Job from it is safe:

bash
kubectl -n kims create job --from=cronjob/kims-cron-site-build-reap manual-reap-1
kubectl -n kims logs job/manual-reap-1
kubectl -n kims delete job manual-reap-1

The names are kims-cron- followed by scheduled-publish-tick, translation-tick, site-build-reap, alerts or reviews-sync. If the task's job is already queued or running, the new one is folded into it (a dedupe key cron:<task>).

To pause all scheduled tasks (for example during a database restore), set cron.suspend: true in the values file and deploy, or for one CronJob until the next deploy:

bash
kubectl -n kims patch cronjob kims-cron-alerts -p "{\"spec\":{\"suspend\":true}}"

That quoting works in bash and in PowerShell 7. In Windows PowerShell 5.1 use -p '{\"spec\":{\"suspend\":true}}'.

#Look at the queue and the builds

RDS is only reachable from inside KIMS's network. Use a psql pod in the namespace (Database tools), or psql from a machine on KIMS's network with the connection string from your secure notes (never paste it into a shared terminal or ticket). These queries only read.

#Jobs waiting or running

sql
select kind, status, count(*), min(created_at) as oldest
from jobs
where status in ('queued', 'running')
group by kind, status
order by oldest;

A few queued rows that come and go are normal. Rows that stay queued for many minutes mean no worker is taking them (is kims-worker running?); rows running long after their locked_until mean a worker died, and another will take them over.

#Recent failures

sql
select kind, attempts, max_attempts, updated_at, left(last_error, 200) as error
from jobs
where status = 'failed'
order by updated_at desc
limit 20;

A job is retried up to max_attempts (3 by default) before it is marked failed. To try a failed publish or build again, do it from the CMS (publish again, or the Builds screen), not by editing rows.

#Site builds

sql
select number, publish_version, cause, status, stage, queued_at, finished_at, jenkins_build_url
from site_builds
order by number desc
limit 10;

status is queued, running, succeeded, failed, aborted or skipped (an older version than live: the live guard). The site-build-reap task marks as failed a build that says running but that Jenkins no longer has.

#The live version

sql
select max(publish_version) as live
from site_builds
where status = 'succeeded';

#Change a Secret

What changed Do Then
The RDS password node deployment-steps/scripts/deploy.mjs kims secrets create --context <KIMS_EKS_CONTEXT> --replace kims-database with the new connection string in KIMS_DATABASE_URL or at the hidden prompt; update the folder's kims-database-url Jenkins credential too Restart the CMS and worker
The Keycloak client secret ... kims secrets create ... --replace kims-keycloak Restart the CMS
The Jenkins user's API token ... kims secrets create ... --replace kims-jenkins Restart the worker
kims-app Never. Its secrets-key decrypts the stored Google translation key and reviews sign-in; a new one makes them unreadable, and they must be entered again in the CMS

Details: Secrets, deploy.mjs.

#Sources

Built 2026-11-29. Commands are shown for the system picked at the top; every block has all three.