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 theus-east-1ACM 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'skims-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
dig +noall +answer <SITE_HOST>
dig +noall +answer <SITE_HOST> CNAMEdig +noall +answer <SITE_HOST>
dig +noall +answer <SITE_HOST> CNAMEResolve-DnsName <SITE_HOST> | Format-Table Name, Type, TTL, NameHost, IPAddressExpected: 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:
dig +noall +answer <SITE_HOST>dig +noall +answer <SITE_HOST>Resolve-DnsName <SITE_HOST> -DnsOnly | Format-Table Name, Type, TTLExpected: 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:
- Add
SITE_NOINDEX=trueto production'skims-site-env(jenkins/credentials). - Rebuild the live version (below).
robots.txtthen saysDisallow: /.
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).
- On the CMS Builds screen, note the live version number.
- Jenkins >
kims-production>kims-site-build> Build with Parameters. PUBLISH_VERSION: the live version.CAUSE:rebuild.- Build.
Expected: SUCCESS after about 15 minutes; Builds shows it live.
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:
curl -s https://<DISTRIBUTION_DOMAIN>/robots.txt
curl -s https://<DISTRIBUTION_DOMAIN>/sitemap.xml | head -c 400; echocurl -s https://<DISTRIBUTION_DOMAIN>/robots.txt
curl -s https://<DISTRIBUTION_DOMAIN>/sitemap.xml | head -c 400; echocurl.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.
IP=$(dig +short <DISTRIBUTION_DOMAIN> | head -1)
curl -sI --resolve <SITE_HOST>:443:$IP https://<SITE_HOST>/bengaluru/doctors/IP=$(dig +short <DISTRIBUTION_DOMAIN> | head -1)
curl -sI --resolve <SITE_HOST>:443:$IP https://<SITE_HOST>/bengaluru/doctors/$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
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"
donedig +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"
doneResolve-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.xmlin 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:
- Create a CloudFront KeyValueStore and associate it with the
kims-viewer-requestfunction first. - Replace the function's code with
deploy/cloudfront/viewer-request-redirects.js, test, Publish. - Add
KIMS_REDIRECTS_KVS_ARN=<KVS_ARN>to production'skims-site-env. - Enter the redirects on the CMS Redirects screen and publish; the build's Redirects stage fills the store.
Details: aws/cloudfront.
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:
- In the CMS, open the page > its version history > restore the version before the change.
- 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:
helm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kimshelm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kimshelm -n <NAMESPACE> history kims
helm -n <NAMESPACE> rollback kims <REVISION> --wait
helm -n <NAMESPACE> status kimsExpected: 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.
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.
- RDS console > Databases > the production instance > Actions > Restore to point in time.
- Choose the time just before the problem, a new DB instance identifier, the same VPC, subnet group and security groups.
- Restore to point in time. Wait until the new instance is Available.
- Put the new endpoint in
kims-database(theurlkey) and in the folder'skims-database-urlcredential, thenkubectl -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
kims-v2/docs/ON-SITE-DEPLOYMENT.md(main: AWS set-up C, steps 8 and 9, "Things to tell KIMS")kims-v2/deploy/jenkins/README-site.md(older versions are skipped; rebuilds)kims-v2/deploy/jenkins/site-env-production.examplekims-v2/apps/website/src/app/robots.tskims-v2/deploy/cloudfront/viewer-request.js,viewer-request-redirects.js- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html
- https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-cloudfront-distribution.html
- https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/kvs-with-functions.html
- https://helm.sh/docs/helm/helm_rollback/
- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIT.html