Jieun 12 min read
Reliability

A CloudFront 502 on My Morning Commute: From Rollback to Root Cause Analysis

I restored service with a rollback after a CloudFront 502, then traced a certificate mismatch by comparing deployment records with Kubernetes Ingress configuration and verified the fix through the live ALB.

On this page

Introduction

At around 7 p.m. on November 12, I switched the production domain of WITIM, the internal company groupware whose infrastructure I managed, to CloudFront. The website and APIs responded normally immediately after the cutover, and I had not found any problems by around 9 p.m. I covered the reasons for the switch, the development PoC, and the production cutover procedure in Why Did Requests from Korea Reach a U.S. Edge? Moving the Web and API Proxy to CloudFront.

But when I opened the service on my commute the following morning, it returned a 502 Bad Gateway error.

The CloudFront 502 Bad Gateway error shown when accessing the service the morning after the cutover
The CloudFront 502 Bad Gateway error shown when accessing the service the morning after the cutover

The message said CloudFront could not connect to the origin server. The error page alone, however, could not tell me whether the problem was in the application server, load balancer, or TLS connection.

I restored service before investigating the cause.

I pointed the root domain’s CNAME back to the existing NCP ALB and re-enabled the Cloudflare proxy. After confirming that the service was accessible through the previous route, I reported the incident and rollback result to the operations team.

Then I began investigating the underlying cause.

At 11:23 p.m., the Certificate I Had Replaced Changed Again

Before the CloudFront cutover, the NCP ALB used a Cloudflare Origin CA certificate.

CloudFront needs a trusted certificate when communicating with an origin over HTTPS, so I had replaced it with an NCP public CA certificate in the ALB console at around 5:23 p.m. on November 12.

Since I had confirmed successful access after the cutover, I did not initially suspect a certificate problem.

Then I found unexpected entries in NCP Cloud Activity Tracer.

Time (KST)Operation categoryWhat I found
Nov 12, 17:23CONSOLEManual replacement with a public CA certificate
Nov 12, 23:23:14ADMINHTTPS listener change recording the previous certificate number
Nov 12, 23:23:24ADMINAdditional certificate change

My console change had been at 5:23 p.m. About six hours later, at 11:23 p.m., another change occurred on the same ALB listener.

In particular, the Change Listener details recorded the previous Cloudflare Origin CA certificate number.

This suggested that the certificate I had manually replaced had reverted to its previous value.

The operation categories also differed. My change was recorded as CONSOLE, while the late-night changes were recorded as ADMIN. That distinction alone did not establish who or what had made the changes.

Why had the certificate changed when nobody had intentionally replaced it again?

Investigating Three Paths That Could Have Changed the Certificate

To narrow down the cause, I checked how the production infrastructure managed its configuration.

WITIM used Argo CD to deploy Kubernetes configuration from Git. The NCP ALB controller managed the actual load balancer based on the Ingress resource stored in the cluster.

The configuration path from Git through Argo CD and Kubernetes Ingress to the ALB, and its mismatch with the manual console certificate change
The configuration path from Git through Argo CD and Kubernetes Ingress to the ALB, and its mismatch with the manual console certificate change

Within this structure, I considered three possible paths for the certificate change:

  1. Argo CD might have reapplied the production configuration.
  2. The ALB controller might have synchronized the ALB with the existing Ingress.
  3. A separate administrative operation might have run within NCP.

I did not assume that a particular controller was responsible. I compared operation records with the actual configuration and narrowed down the possibilities.

My original handwritten investigation notes in Korean, recording the configuration path, three hypotheses, and certificate numbers
My original handwritten investigation notes in Korean, recording the configuration path, three hypotheses, and certificate numbers

1. GitHub Had No Production Promotion or Deployment Record

I first checked the production branch and deployment history in GitHub.

There was no promotion to main or production deployment around 11 p.m. on November 12.

I also checked the Argo CD Application Controller logs, but found no direct evidence that the Ingress certificate annotation had changed at that time.

The logs included messages such as Reconciliation completed and Update successful, but these can also appear during resource state comparisons. They did not prove that Argo CD had actually reapplied the Ingress.

I therefore considered a new production deployment an unlikely trigger for the certificate change.

Argo CD can still recheck resource state without a Git change, however. The absence of a deployment record did not rule out every reconciliation scenario.

2. Evidence for a Separate NCP Administrative Operation Was Also Insufficient

Next, I considered whether a separate administrative operation had run within NCP.

The 11:23 p.m. changes were recorded as ADMIN, but no operator account or request IP was shown.

The records I had did not establish that a separate manual administrative operation had occurred at that time.

I had not obtained the full internal execution logs, so I could not completely rule out the involvement of an internal NCP event.

3. The Live Ingress Still Referenced the Previous Certificate

Finally, I opened the Kubernetes Dashboard and inspected the Ingress in the production namespace.

There I found an important setting.

The original Kubernetes Dashboard screenshot showing the previous Origin CA certificate in the live Ingress annotation, with operational identifiers blurred
The original Kubernetes Dashboard screenshot showing the previous Origin CA certificate in the live Ingress annotation, with operational identifiers blurred

The annotation specifying the ALB’s HTTPS certificate still pointed to the previous Cloudflare Origin CA certificate.

alb.ingress.kubernetes.io/ssl-certificate-no: "68722"

68722 was the previous Cloudflare Origin CA certificate number. The public CA certificate I had selected in the console the day before was 71751.

Where had Kubernetes Ingress obtained this value?

I found that an Ingress YAML file already existed in the production Git repository.

This was not a new file created during the incident response. It had been added when the Kubernetes environment was originally set up and was already serving as the configuration declaration for the production load balancer.

The Ingress declared both which Kubernetes Service should receive requests for each domain and, through an annotation, which HTTPS certificate the ALB should use.

At this point, I needed to distinguish how the YAML in Git connected to the actual ALB.

NKS did not read the YAML file directly from GitHub to modify the ALB.

The actual flow was:

ingress.yaml on GitHub main
↓
Argo CD
↓
Live Ingress stored in Kubernetes
↓
NCP ALB controller
↓
Actual NCP ALB

Argo CD applied the declaration in Git to Kubernetes. The ALB controller then managed the ALB configuration based on the live Ingress resource stored in Kubernetes.

What I had changed in the console the day before was the actual ALB at the bottom of this chain.

The production Git repository and Kubernetes Ingress still referenced the previous certificate number, 68722.

Comparing the three states made the mismatch clear.

Configuration locationCertificate
Manual ALB console change on the afternoon of Nov 1271751 (public CA)
Production Git ingress.yaml68722 (Origin CA)
Live Kubernetes Ingress68722 (Origin CA)

In other words, I had replaced the certificate only in the ALB console, leaving the configuration the controller used as its reference unchanged.

If the ALB controller synchronized the ALB with the Ingress declaration again, the value changed in the console could revert to the previous certificate.

I also contacted NCP support about the situation.

Original NCP support reply in Korean explaining that Ingress YAML is the synchronization reference and console changes can be rolled back
Original NCP support reply in Korean explaining that Ingress YAML is the synchronization reference and console changes can be rolled back

NCP explained that an NKS Ingress ALB is synchronized based on its YAML configuration. If the certificate is changed only in the console and the YAML remains unchanged, the ALB can revert to the declared value. This is a paraphrase of the original Korean reply shown above.

That explanation matched the configuration mismatch I had found.

GitHub had no new production deployment record around 11 p.m., and I had not identified a separate manual administrative operation. Meanwhile, both Git and the live Ingress still referenced the previous certificate, and NCP’s operation history recorded a change back to it.

I therefore judged the ALB controller synchronizing the actual ALB with the existing Ingress configuration to be the most likely explanation.

I could not determine which internal event had triggered the synchronization at 11:23 p.m.

I also did not obtain CloudFront’s internal TLS failure records directly. Still, the reapplication of the previous Origin CA certificate was consistent with a 502 caused by CloudFront being unable to trust the origin certificate.

The target of the fix was now clear: update the Ingress declaration used by the ALB controller, rather than change the certificate in the console again.

Resolution, Stage 1: Updating the Certificate Declaration in Production Git

The service had already been restored through the previous Cloudflare proxy route.

For the first stage, I kept that route in place while correcting the certificate configuration and preparing to switch back to CloudFront.

Cloudflare’s SSL/TLS mode was Full (strict). A public CA certificate meeting the hostname, certificate chain, and validity requirements could also be used with that mode.

I therefore chose to apply and verify the public CA certificate while retaining the existing proxy, then switch back to CloudFront as the final step.

Limiting the Change to One Production Ingress File

The working branch I had been preparing was based on dev. But dev contained many changes that had not yet reached main.

Merging that branch into production to change a single certificate would risk deploying unrelated changes as well.

I created a separate hotfix from the latest main instead.

The target was one file: ingress.yaml in the production overlay.

alb.ingress.kubernetes.io/ssl-certificate-no: "68722"
alb.ingress.kubernetes.io/ssl-certificate-no: "71751"

I changed only the certificate annotation and its related comment.

I confirmed that other services still used the previous Origin CA certificate, so I did not delete it.

Checking the Actual ALB After Argo CD Synchronization

The hotfix was merged into main at around 13:38 on November 13.

Argo CD’s automatic synchronization followed at around 13:42.

Although the certificate change was only one line, the Application synchronization also ran the witim-migrate PreSync hook. The hook succeeded, and I confirmed that there were no pending migrations at that time.

Argo CD reported Synced, Healthy, and Succeeded.

I did not stop verification there.

This incident involved a mismatch between the declaration and the actual ALB configuration. A Git change and a successful Argo CD synchronization alone were not enough to establish that the fix was complete.

I checked the actual state at each step.

Verification targetResult
Production Git mainPublic CA certificate 71751
Argo CDSynced / Healthy / Succeeded
Live Kubernetes IngressCertificate 71751
NCP ALB HTTPS listenerDefault and additional certificates both 71751
Origin HTTPSHostname and public certificate chain validation passed

NCP’s operation history also confirmed successful listener and additional certificate changes at around 13:42.

Production Git, the live Ingress, and the ALB now all used the same certificate. With the origin HTTPS hostname and public certificate chain validated, the certificate preparation and verification required for the CloudFront cutover were complete.

Resolution, Stage 2: Switching Back to CloudFront and Verifying External Access

I began the second stage after verifying the certificate declaration, its actual application, and the origin HTTPS connection in stage one. I switched the root domain back to CloudFront and checked that external requests received normal responses through the new route.

Cloudflare continued to manage DNS, with the root record’s proxy setting changed to DNS only.

After the cutover, I checked the following:

Verification targetResult
Service root pathHTTP 200
Selected production API pathsHTTP 200
CloudFront POPResponse from the Incheon edge confirmed
Public static CSSCache MISS → HIT confirmed

Immediately after the cutover, some connections still returned responses through the previous Cloudflare route. To check the effects of existing DNS caches or connection reuse, I compared requests forced to the previous Cloudflare IP with requests following the current DNS route.

I then confirmed a response from CloudFront’s Incheon POP through the current DNS route.

These checks covered the certificate declaration, the actual origin HTTPS connection, and key HTTP responses through CloudFront.

Adding Notifications

I had found this incident by opening the service the following morning, after confirming normal behavior the night before.

I could not establish the exact start time or the total number of affected users. After recovery, I added notifications to help detect similar incidents sooner.

For CloudFront, I configured a 5xxErrorRate alarm. It evaluates the 5xx error rate in one-minute periods and sends email to the operations contacts through SNS when the rate is at least 1% for two consecutive periods. I also connected notifications for a return to the normal state.

In NCP Certificate Manager, I configured SMS notifications for certificate expiration and renewal results. I also checked the public certificate’s eligibility for automatic renewal and the DNS records used for domain validation.

Conclusion

During this incident, I rolled back to the existing proxy and restored service before identifying the cause. After reporting the situation to the operations team, I found records showing that the certificate had changed again the previous night.

I narrowed down the candidates by checking GitHub deployment records, Argo CD logs, and the live Kubernetes Ingress.

This revealed that the certificate I had selected in the ALB console differed from the one declared in Git and Ingress. I did not identify the exact synchronization trigger, but the most likely explanation was that the ALB controller restored the configuration based on the existing Ingress declaration.

Instead of changing the console again, I updated the certificate declaration in production Git. I verified that the same certificate had reached the live Ingress and ALB before switching back to CloudFront.

The key was to avoid drawing a conclusion from a single error message. I restored service first, compared the change history with the actual configuration, and corrected the declaration that the automation used as its reference.

Comments