KKIMS on-site docs
Deploy KIMS (UAT and production)

Production cut-over and rollback

Move the public website host from the old website to KIMS v2's CloudFront distribution, with the TTL lowered first, search engines held back if KIMS wants, checks after the switch, and a rollback plan for DNS, the platform, the website content and the database.

Until now production has been reachable only on https://<DISTRIBUTION_DOMAIN> (and the CMS on https://<CMS_HOST>). Go-live is one change: KIMS's DNS team points the public website host at the distribution. KIMS decides when. UAT has no cut-over; its DNS can point at its distribution as soon as its first build works.

This page uses <SITE_HOST> for the public website host (for example www.kimshospitals.com), <DISTRIBUTION_DOMAIN> for production's d....cloudfront.net domain, and <OLD_TARGET> for whatever the host points at today.

#Before the day

#Prerequisites

  • deploy/acceptance passed on production, and on UAT first if there is one.
  • The first publish (the Emergency hero image) went live: deploy/website.
  • The distribution has <SITE_HOST> (and the bare domain, if used) as Alternate domain names, with the us-east-1 ACM certificate that covers them (aws/cloudfront, aws/certificates-and-dns). CloudFront refuses requests for a host it does not list.
  • SITE_URL=https://<SITE_HOST> in production's kims-site-env (sitemap and canonical links use it).
  • KIMS has named who decides go-live, who changes DNS, and who decides a rollback.
  • You know <OLD_TARGET> exactly (record type, value, TTL), written down, so you can put it back.
  • Redirects for old addresses are decided: none at launch, or a KeyValueStore set up as in Redirects.

#Write down what DNS says today

bash
dig +noall +answer <SITE_HOST>
dig +noall +answer <SITE_HOST> CNAME
bash
dig +noall +answer <SITE_HOST>
dig +noall +answer <SITE_HOST> CNAME
powershell
Resolve-DnsName <SITE_HOST> | Format-Table Name, Type, TTL, NameHost, IPAddress

Expected: the current record, for example www.example.com. 3600 IN CNAME old-host.example.net. Keep this output; it is the rollback target.

#Lower the TTL a day or more before

Ask KIMS's DNS team to lower the TTL of the <SITE_HOST> record to 300 seconds (5 minutes) at least one old TTL before the switch (if the TTL is 86400, a day before). Then a switch, and a switch back, reach most visitors within minutes.

Check the next day:

bash
dig +noall +answer <SITE_HOST>
bash
dig +noall +answer <SITE_HOST>
powershell
Resolve-DnsName <SITE_HOST> -DnsOnly | Format-Table Name, Type, TTL

Expected: a TTL of 300 or less (the number counts down in caching resolvers).

A Route 53 alias record has no TTL of its own; if the host is an alias, skip this step.

#Search engines before launch (optional)

If KIMS wants production built but kept out of search until launch:

  1. Add SITE_NOINDEX=true to production's kims-site-env (jenkins/credentials).
  2. Rebuild the live version (below). robots.txt then says Disallow: /.

On the day, remove the line and rebuild again before the DNS switch, so search engines that visit after the switch see the real robots.txt.

#On the day

#Step 1: final rebuild of the live version

Do this if kims-site-env changed (for example SITE_NOINDEX removed, or SITE_URL corrected).

  1. On the CMS Builds screen, note the live version number.
  2. Jenkins > kims-production > kims-site-build > Build with Parameters.
  3. PUBLISH_VERSION: the live version. CAUSE: rebuild.
  4. Build.

Expected: SUCCESS after about 15 minutes; Builds shows it live.

Note

A build of a version older than the live one is recorded as skipped and deploys nothing. Only the live version, or a newer one, can be built.

#Step 2: check on the distribution address

Run the checks in deploy/website against https://<DISTRIBUTION_DOMAIN>, then:

bash
curl -s https://<DISTRIBUTION_DOMAIN>/robots.txt
curl -s https://<DISTRIBUTION_DOMAIN>/sitemap.xml | head -c 400; echo
bash
curl -s https://<DISTRIBUTION_DOMAIN>/robots.txt
curl -s https://<DISTRIBUTION_DOMAIN>/sitemap.xml | head -c 400; echo
powershell
curl.exe -s https://<DISTRIBUTION_DOMAIN>/robots.txt
(curl.exe -s https://<DISTRIBUTION_DOMAIN>/sitemap.xml).Substring(0,400)

Expected: robots.txt has Allow: /, Disallow: /search/, Disallow: /data/ and Sitemap: https://<SITE_HOST>/sitemap.xml; the sitemap's <loc> addresses start with https://<SITE_HOST>/.

#Step 3: test the real host name before DNS changes

This asks the distribution for <SITE_HOST> directly, so you see what visitors will see, certificate included.

bash
IP=$(dig +short <DISTRIBUTION_DOMAIN> | head -1)
curl -sI --resolve <SITE_HOST>:443:$IP https://<SITE_HOST>/bengaluru/doctors/
bash
IP=$(dig +short <DISTRIBUTION_DOMAIN> | head -1)
curl -sI --resolve <SITE_HOST>:443:$IP https://<SITE_HOST>/bengaluru/doctors/
powershell
$IP = (Resolve-DnsName <DISTRIBUTION_DOMAIN> -Type A | Select-Object -First 1).IPAddress
curl.exe -sI --resolve "<SITE_HOST>:443:$IP" https://<SITE_HOST>/bengaluru/doctors/

Expected: HTTP/2 200, and headers including via: ... (CloudFront) and x-cache:. A certificate error means the alternate domain name or the certificate is missing on the distribution.

#Step 4: KIMS switches DNS

KIMS's DNS team, at the agreed time:

Host Record
www style host, for example www.<DOMAIN> CNAME to <DISTRIBUTION_DOMAIN>
Bare domain (<DOMAIN>), in Route 53 A and AAAA Alias to the CloudFront distribution
Bare domain, at another DNS provider Their ALIAS, ANAME or CNAME-flattening record to <DISTRIBUTION_DOMAIN> (a plain CNAME is not allowed at the apex)

In Route 53: Hosted zones > the zone > select the record > Edit record > Alias on > Route traffic to > Alias to CloudFront distribution > choose the distribution > Save.

#Step 5: check after the switch

bash
dig +noall +answer <SITE_HOST>
for p in / /bengaluru/doctors/ /kn/ /hi/ /sitemap.xml /robots.txt /no-such-page/; do
  printf '%-22s ' "$p"; curl -s -o /dev/null -w "%{http_code}\n" "https://<SITE_HOST>$p"
done
bash
dig +noall +answer <SITE_HOST>
for p in / /bengaluru/doctors/ /kn/ /hi/ /sitemap.xml /robots.txt /no-such-page/; do
  printf '%-22s ' "$p"; curl -s -o /dev/null -w "%{http_code}\n" "https://<SITE_HOST>$p"
done
powershell
Resolve-DnsName <SITE_HOST> -DnsOnly | Format-Table Name, Type, TTL, NameHost
foreach ($p in "/","/bengaluru/doctors/","/kn/","/hi/","/sitemap.xml","/robots.txt","/no-such-page/") {
  "{0,-22} {1}" -f $p, (curl.exe -s -o NUL -w "%{http_code}" "https://<SITE_HOST>$p")
}

Expected: the record now names <DISTRIBUTION_DOMAIN> (or, for an alias, CloudFront addresses), then 200 for every address except /no-such-page/, which is 404. Your own resolver may keep the old answer until the old TTL runs out; https://dnschecker.org shows what resolvers around the world see.

Then, in a browser: a few pages, images, a language switch, the 404 page. Ask KIMS to look too.

#Step 6: after go-live

  • Submit https://<SITE_HOST>/sitemap.xml in Google Search Console (KIMS's property) if KIMS manages one.
  • Keep the old website running, untouched, for at least the rollback window KIMS agrees (a week is common), so DNS can be put back.
  • Raise the TTL again (for example 3600) once KIMS is satisfied.

#Redirects from old addresses

Main's viewer-request.js does not redirect. If old addresses must lead to new pages from day one:

  1. Create a CloudFront KeyValueStore and associate it with the kims-viewer-request function first.
  2. Replace the function's code with deploy/cloudfront/viewer-request-redirects.js, test, Publish.
  3. Add KIMS_REDIRECTS_KVS_ARN=<KVS_ARN> to production's kims-site-env.
  4. Enter the redirects on the CMS Redirects screen and publish; the build's Redirects stage fills the store.

Details: aws/cloudfront.

Warning

If the redirects code is published before a store is associated, every request fails, not only redirects. Associate first, then publish.

#Rollback

Decide in advance who may call a rollback. Each part can be rolled back on its own.

#The website: point DNS back

The fastest and most complete rollback. KIMS's DNS team puts back the record written down in Write down what DNS says today. With a 300 second TTL most visitors are back on the old website within minutes. Nothing in AWS has to change; production stays up on its distribution address for fixing.

Check with the dig / Resolve-DnsName command above: the old value again.

#Website content: restore and publish

Older published versions cannot be rebuilt (a build of an older version is skipped). To undo a bad content change:

  1. In the CMS, open the page > its version history > restore the version before the change.
  2. Submit, approve (a different person), publish.

Expected: Builds shows a new build, then live, about 15 minutes later.

#The platform (CMS, worker, scheduled tasks)

Either rerun the platform job on the earlier commit, or roll the Helm release back. Later upgrades and rollbacks: operate/day-two.

Helm rollback:

bash
helm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kims
bash
helm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kims
powershell
helm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kims

Expected: history lists revisions with deployed and superseded; after rollback, Rollback was a success! Happy Helming! and STATUS: deployed with a new revision number. Then run the health checks in deploy/acceptance.

Rerun the job: in KIMS's Git, the branch must point at the earlier commit for the job to build it. Prefer a revert commit (git revert <BAD_COMMIT>, then push), which keeps history and is safe with the UAT fast-forward rule.

Warning

Database migrations are not undone by either route. Code from before a migration usually runs against the newer schema, but not always. If a rollback crosses a migration, ask ClinicSpots before doing it.

#The database: point-in-time recovery

The last resort, for lost or corrupted data. RDS restores to a new instance at a chosen time; it never overwrites the existing one.

  1. RDS console > Databases > the production instance > Actions > Restore to point in time.
  2. Choose the time just before the problem, a new DB instance identifier, the same VPC, subnet group and security groups.
  3. Restore to point in time. Wait until the new instance is Available.
  4. Put the new endpoint in kims-database (the url key) and in the folder's kims-database-url credential, then kubectl -n <NAMESPACE> rollout restart deploy/kims-cms deploy/kims-worker.

Everything written after the chosen time is lost, including CMS edits and publishes. Media files in S3 are not rolled back. More on backups and restores: operate/backup-and-restore.

#UAT and production

UAT Production
Cut-over None; DNS can point at the distribution when the first build works This page, at the time KIMS decides
SITE_NOINDEX Always true Only before launch, if KIMS wants
TTL lowering Not needed A day or more before
Rollback by DNS Not needed The first choice for the website

#Sources

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