KIMS v2 is the KIMS Hospitals public website and the CMS that KIMS's staff use to edit it. It runs on services KIMS already operates: EKS (Kubernetes), Amazon RDS for PostgreSQL 18, their Keycloak for sign-in, their Jenkins, and S3 with CloudFront. There is no Lambda and nothing else from AWS: only S3 and CloudFront, reached through IAM roles, never access keys.
The public website is static: plain HTML, CSS, JavaScript and images in an S3 bucket behind CloudFront. Nothing runs on a server when a visitor opens a page. The CMS is a server application in EKS. When an editor publishes, a Jenkins job rebuilds the static site from the database and uploads it.
#Production, and UAT only if KIMS wants it
Production is always deployed. UAT is optional and still undecided by KIMS: ask at the start of the day. UAT, when there is one, is a second, separate copy of the whole platform, deployed from its own Git branch. Nothing in the code changes between "production only" and "UAT and production", and UAT can be added later.
| Production | UAT (only if KIMS wants it) | |
|---|---|---|
| Git branch | main |
uat, made from main |
| Jenkins folder (holds both jobs and their credentials) | kims-production |
kims-uat |
| Kubernetes namespace | kims |
kims-uat |
Helm values (folder credential kims-helm-values) |
from values-production.example.yaml |
from values-uat.example.yaml |
Site build settings (folder credential kims-site-env) |
from site-env-production.example |
from site-env-uat.example |
KIMS_ENVIRONMENT (Helm), KIMS_ENV (site build) |
production |
uat |
| Search engines | Indexed (no SITE_NOINDEX) |
Kept out (SITE_NOINDEX=true) |
Each environment has its own database, assets and website buckets, CloudFront distribution, website and CMS host names, IAM role for the pods, Kubernetes Secrets, Keycloak client and Jenkins folder. They share the Git repository, the image registry, the Jenkins agent and KIMS's Keycloak realm.
Guards. The platform job takes the environment from the branch it built (main is production, uat is UAT) and refuses a Helm values file whose KIMS_ENVIRONMENT says otherwise. The site build refuses to run when KIMS_ENV in its settings file and its branch disagree. UAT's settings can never deploy over production, or the reverse.
#The pieces
#One image, four modes
All the server-side code is one Docker image, kims/kims-v2, built from deploy/Dockerfile on Node.js 24. What a container does is chosen at start by the MODE environment variable (or the first argument):
| Mode | Runs as | What it does |
|---|---|---|
cms |
Deployment kims-cms (2 replicas), Service on port 80, Ingress |
The Next.js CMS on port 3000. Health: GET /api/health (alive) and GET /api/health?check=ready (can reach the database) |
worker |
Deployment kims-worker (1 replica) |
Background jobs: publishing, image resizing, translation, the Google reviews sync, starting site builds, alerts |
cron <task> |
One Kubernetes CronJob per task | Adds one job to the queue, then exits. The worker does the work |
migrate |
Job kims-migrate, a Helm hook before every install and upgrade |
Applies pending SQL migrations (db/migrations/), then exits |
data-bundle <command> |
A one-off pod (deploy/handover/load-bundle-pod.yaml) |
Loads the handover content and media into a new environment. Used once per environment |
The pods run as a non-root user (uid 1000) with a read-only root filesystem. The image is built for linux/amd64 and linux/arm64 by default, so it runs on either kind of EKS node.
The scheduled tasks (CronJobs):
| Task | What it queues |
|---|---|
scheduled-publish.tick |
Publish anything whose scheduled time has passed |
translation.tick |
Carry on machine-translation work (after a quota limit or an outage) |
site-build.reap |
Mark as failed any site build stuck as running for over 3 h 15 min that Jenkins is not running |
alerts |
Log an alert for a publish no build picked up, or a failed latest build |
reviews.sync |
Fetch the latest Google reviews |
Their schedules are in the chart's values.yaml (cron.tasks); the example values files set cron.timeZone: Asia/Kolkata.
#The database: RDS PostgreSQL 18
One database, kims, owned by one user, per environment. It holds everything that changes:
| Tables | What they hold |
|---|---|
state_objects |
Drafts, workflow (submitted, approved), indexes, audit |
publish_versions, published_files |
Every publish as a numbered publish version, with its files |
media_assets, media_usage |
The media library's records (the files are in S3) |
cms_users, sessions |
Who may do what in the CMS, and signed-in sessions |
jobs |
The background job queue |
site_builds |
Every website build and its stages, shown on the CMS Builds screen |
secrets |
The Google translation key and reviews sign-in, encrypted with SECRETS_KEY |
schema_migrations |
Which migrations have run |
Git holds code only. Content never goes through Git, and is not promoted between environments: each environment loads the handover data bundle on its first day, and after that content is edited and published in production's CMS.
#Sign-in: KIMS's Keycloak
The CMS is an OpenID Connect client of KIMS's realm (a confidential client, standard flow with PKCE S256), one client per environment. Keycloak decides who may sign in: a person needs that client's role cms-access and a verified email. The CMS decides what they may do, with its own roles on its People screen.
Keycloak calls the CMS's back-channel logout URL when a session ends there, so signing someone out in Keycloak ends their CMS session at once. Disabling an account or removing cms-access takes effect at the CMS's next check with Keycloak, within 5 minutes.
#Two S3 buckets and CloudFront
| Bucket | Written by | Read by | Holds |
|---|---|---|---|
| Assets | The CMS (browser uploads with presigned URLs), the worker (resized images) | The CMS, the worker, the site build | originals/ (uploads) and derived/ (resized versions). Versioning on: it holds the only copy of every upload |
| Website | The site build only (through the Jenkins agent's IAM role) | CloudFront only | The complete static site, every language |
The pods' IAM role (IRSA) has the assets bucket only. The website bucket and the CloudFront invalidation belong to the Jenkins agent's role.
CloudFront serves the website bucket through Origin Access Control (the bucket stays private). A small viewer-request function from deploy/cloudfront/ runs on every request:
viewer-request.js(installed on day one) turns directory URLs like/about/into/about/index.html. Without it only the home page works.viewer-request-redirects.js(only once KIMS wants redirects) also answers redirects from a CloudFront KeyValueStore. The store must be associated with the function before this code is published, or every request fails.
#Jenkins: two jobs per environment
| Job | File | What it does | Started by |
|---|---|---|---|
kims-platform |
deploy/jenkins/Jenkinsfile.platform |
Checks the code (npm run verify), builds the image with docker buildx, pushes it tagged with the full commit SHA, runs helm upgrade --install |
A push to the folder's branch (webhook or polling), or by hand |
kims-site-build |
deploy/jenkins/Jenkinsfile.site |
Builds the static website from one publish version and deploys it | The CMS worker, through the Jenkins API, after each publish |
Each environment's folder (kims-production, kims-uat) holds both jobs and its own credentials under the same IDs. The platform job pins agents labelled kims-build. The site build job's Jenkinsfile says agent any, so on a Jenkins with other agents it can land on one that lacks its tools: Jenkins agent says how to keep it on the right one. The agent needs Node.js 24, Docker with buildx, Helm 3, kubectl, git, Chrome or Chromium (for the Lighthouse quality gate) and about 15 GB of free disk (30 GB if one agent builds both environments).
From the CMS and worker pods, over HTTPS:
- Cloud Translation API (v2) for machine translation into Kannada and Hindi. The API key is entered on the CMS's Translation screen and stored encrypted.
- Google Business Profile APIs for the reviews wall. The OAuth client is saved once per environment; an Admin then clicks Connect Google in the CMS.
- Google Tag Manager (optional): a container id baked into the site at build time.
#The region
Everything goes in the region KIMS's EKS cluster is in: Hyderabad ap-south-2 is recommended (closest, data stays in India), Mumbai ap-south-1 if the cluster is there. The one exception is the website's TLS certificate, which CloudFront requires in us-east-1. Note that where a setting is left unset, the code falls back to ap-south-1, so always set the region explicitly.
#The picture
#Everything and what it talks to (one environment)
Visitors KIMS staff (browser)
| |
v v
+---------------------+ +------------------+
| CloudFront | | Ingress (ALB or | https://<CMS_HOST>
| viewer-request fn | | KIMS's class) |
| (+ KeyValueStore | +--------+---------+
| if redirects) | |
+----------+----------+ v
| OAC +---------------- EKS, namespace kims (UAT: kims-uat) --+
v | kims-cms (x2) kims-worker CronJobs (x5) |
+---------------------+ | kims-migrate (Helm hook) service account kims |
| S3 website bucket | | (IRSA: assets bucket) |
+----------^----------+ +-------+-----------------+----------------+-----------+
| | | |
| sync + delete v v v
+---------------------+-------------+ +-----------+ +-------------------------------------+
| Jenkins <folder>/kims-site-build |---->| S3 assets | | RDS PostgreSQL 18, database kims |
| agent label kims-build | | bucket | | content, jobs, sessions, builds |
| export, build, gates, media, |---------------------> reads content, writes progress |
| sync, invalidate CloudFront | +-----^-----+ +-------------------------------------+
+---------------^-------------------+ |
| buildWithParameters | presigned PUT (browser uploads, CORS)
| (API token) |
+---- kims-worker +---- KIMS staff browser
Jenkins <folder>/kims-platform: git -> npm run verify -> docker buildx -> registry (ECR) -> helm upgrade -> EKS
kims-cms <---- OIDC sign-in, token refresh ----> KIMS Keycloak (realm; client per environment; role cms-access)
kims-cms <---- back-channel logout ------------- KIMS Keycloak
kims-cms, kims-worker ---- HTTPS ----> Google Translation, Google OAuth, Google Business Profile APIs#Who reaches what over the network
| From | To | Port | Fails as |
|---|---|---|---|
| Pods (CMS, worker, CronJobs, migrate) | RDS | 5432 | Pods never ready |
| Pods | Keycloak (the issuer URL) | 443 | Sign-in fails |
| Keycloak | https://<CMS_HOST>/api/auth/backchannel-logout |
443 | Revoking a person takes 5 minutes instead of seconds |
| Pods | S3 and STS in the region (an S3 VPC gateway endpoint is the cheap way) | 443 | Uploads never get their sizes |
| Pods | The Jenkins URL | 443 | Publish succeeds but no build starts |
| Pods | translation.googleapis.com, www.googleapis.com, oauth2.googleapis.com, mybusiness.googleapis.com, mybusinessaccountmanagement.googleapis.com, mybusinessbusinessinformation.googleapis.com |
443 | Translation and Google reviews fail |
| Jenkins agent | RDS | 5432 | Site build fails at its first stage |
| Jenkins agent | S3, cloudfront.amazonaws.com, the CloudFront KeyValueStore API (if redirects), the registry, the EKS API |
443 | Site build fails at Deploy; platform job at Image or Deploy |
| Jenkins agent | The npm registry, KIMS's Git | 443 | Both jobs fail at Install or Checkout |
| Staff browsers | Assets bucket | 443 | Media uploads fail (needs the CORS rule) |
Outbound access and Networking say how to test each path.
#How a page request works
- A visitor opens
https://<SITE_HOST>/bengaluru/doctors/. - CloudFront runs the viewer-request function. With the redirects version, it first looks the path up in the KeyValueStore and on a hit answers with a 301 to the new address.
- Otherwise it rewrites
/bengaluru/doctors/to/bengaluru/doctors/index.html. - CloudFront serves the file from its cache, or fetches it from the website bucket through Origin Access Control. A missing file (S3 answers 403 behind OAC) is turned into the site's
/404.htmlwith status 404 by the distribution's custom error responses.
No pod, database or Jenkins is involved. If EKS were down, the public site would keep working.
#How a publish works
- An editor changes a page in the CMS and submits it for review.
- A reviewer (a different person: approving your own change is refused) approves it. It appears on the Publishing screen.
- An Admin publishes. The CMS adds a publish job to the
jobstable. - The worker claims the job and writes a new publish version N.
- The worker calls Jenkins:
POST <JENKINS_URL>/job/kims-production/job/kims-site-build/buildWithParameters(UAT:job/kims-uat/...) withPUBLISH_VERSION=NandCAUSE=publish, authenticated withJENKINS_USERand theJENKINS_TOKENAPI token. - Jenkins checks the environment (the
kims-site-envfile'sKIMS_ENVagainst the branch), then runsscripts/site-build/run.mjs, which records every stage insite_buildsso the CMS Builds screen can follow it:- Export content version N from the database.
- Export the media manifest.
- Write the Google reviews feeds.
- Build every enabled language (English, Kannada, Hindi).
- Run the quality gates (page count floor, hospital logos,
robots.txtagainstKIMS_ENV, Lighthouse with Chrome, and more). A failure stops the build before anything is deployed. - Copy every media file the pages reference from the assets bucket.
- Sync the build into the website bucket, then delete what the build no longer has.
- Invalidate CloudFront.
- Sync the redirects KeyValueStore (skipped when
KIMS_REDIRECTS_KVS_ARNis unset).
- The Builds screen shows the build as live. A full build of three languages takes about 15 minutes.
Builds run one at a time per job. A build of a version older than the one already live is recorded as skipped and deploys nothing.
#How a code change reaches EKS
#Production only
- A commit is pushed to
mainin KIMS's Git. kims-production/kims-platformruns:npm ci,npm run verify,docker buildx buildfor amd64 and arm64, push tagged with the full commit SHA.helm upgrade --install kims deploy/helm/kimsinto namespacekims, with the folder'skims-helm-valuesfile. Thekims-migratehook runs first and applies any new migrations, then the CMS and worker roll out.
#With UAT
- A change goes to the
uatbranch.kims-uat/kims-platformbuilds and deploys it intokims-uat. - KIMS accepts it on UAT.
mainis moved to the same commit withgit push kims uat:main(it only succeeds as a fast-forward, somainis never ahead ofuat).kims-production/kims-platformdeploys it, reusing UAT's image of that commit rather than building it again.
#Rollback
helm rollback kims <REVISION> -n kims (UAT: -n kims-uat), or rerun kims-platform on an earlier commit. Content is rolled back in the CMS from a page's version history. The database has RDS point-in-time recovery.
#Sources
kims-v2/CLAUDE.mdkims-v2/docs/ON-SITE-DEPLOYMENT.md(branchmain, including "Production, and UAT if KIMS wants it" and "AWS set-up")kims-v2/docs/CONFIG.mdkims-v2/deploy/Dockerfile,kims-v2/deploy/entrypoint.shkims-v2/deploy/helm/kims/values.yaml,values-production.example.yaml,values-uat.example.yaml,templates/migrate-job.yamlkims-v2/deploy/jenkins/README.md,README-site.md,Jenkinsfile.platform,Jenkinsfile.site,check-environment.sh,site-env-production.examplekims-v2/deploy/cloudfront/viewer-request.js,kims-v2/deploy/cloudfront/viewer-request-redirects.jskims-v2/apps/worker/src/schedule.tskims-v2/db/migrations/kims-v2/scripts/site-build/run.mjs