<p>I have a strange case. Context:</p>
<p>At the very first, the client was using our domain for their store, the URL was something like <code>somestore.eu.mycompany.com</code></p>
<p>Then, the client upgraded to a custom domain, other clients did this without any problem.</p>
<p>We deleted the whole namespace with the old subdomain and created a new one with the domain.</p>
<p>The root domain works flawlessly, without SSL certificate issues. However the staging subdomain works sometimes, sometimes without an SSL certificate issue, sometime with this error:</p>
<pre><code>$ curl -vI https://staging.somestore.com/
*   Trying 35.102.186.11:443...
* TCP_NODELAY set
* Connected to staging.somestore.com (35.102.186.11) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.eu.mycompany.com
*  start date: Mar 13 09:29:46 2022 GMT
*  expire date: Jun 11 09:29:45 2022 GMT
*  subjectAltName does not match staging.somestore.com
* SSL: no alternative certificate subject name matches target host name 'staging.somestore.com'
</code></pre>
<p>Looking at the logs I can see that <code>nginx-ingress</code> still trying to get the old certificate</p>
<p><code>kubectl logs -f -n ingress-nginx nginx-ingress-controller-55f88544bf-dk7ht | grep my-namespace</code></p>
<blockquote>
<p>SSL certificate &quot;my-namespace/tls-cert&quot; does not contain a Common Name or Subject Alternative Name for server &quot;somestore.eu.mycompany.com&quot;: x509: certificate is valid for somestore.com, staging.somestore.com, <a href="http://www.somestore.com" rel="nofollow noreferrer">www.somestore.com</a>, not somestore.eu.mycompany.com</p>
</blockquote>
<p>Why Kubernetes's nginx-ingress still trying to get the old certificate?</p>

<ol>
<li>make sure you have the correct configmaps, secrets or other configuration in your cluster (E.g. where SSL certs are stored). The desired config must be present, the deprecated must be dumped.</li>
<li>perform a rollout restart on your deployment. ( E.g. if <code>nginx-ingress</code> is the name of the deployment in the <code>ingress</code> namespace, do this: <code>kubectl rollout restart -n ingress deploy/nginx-ingress</code> )</li>
</ol>
