<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Khris on Medium]]></title>
        <description><![CDATA[Stories by Khris on Medium]]></description>
        <link>https://medium.com/@khrisy?source=rss-f08498aed327------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UHocrm60FsMpgZ93cM2ToQ.jpeg</url>
            <title>Stories by Khris on Medium</title>
            <link>https://medium.com/@khrisy?source=rss-f08498aed327------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:24:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@khrisy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Manage certificate with Cert-manager]]></title>
            <link>https://medium.com/@khrisy/manage-certificate-with-cert-manager-bb6dfd2c5815?source=rss-f08498aed327------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb6dfd2c5815</guid>
            <dc:creator><![CDATA[Khris]]></dc:creator>
            <pubDate>Tue, 12 Oct 2021 01:37:22 GMT</pubDate>
            <atom:updated>2021-10-12T06:59:49.341Z</atom:updated>
            <content:encoded><![CDATA[<p>This article walks through the process to setup certificate provisioning and automatic renewal with cert-manager and Let’s Encrypt in Kubernetes.</p><h3>TL;DR</h3><p><a href="https://cert-manager.io/">Cert-manager</a> uses below workflow/resources to provision/renew certificates in Kubernetes.</p><p>Certificate → Issuer → CertificateRequest → Orders → Challenges</p><h3>Installation</h3><p>Install cert-managers via Helm:</p><pre>helm repo add jetstack https://charts.jetstack.io<br>helm repo update<br>helm install \<br>  cert-manager jetstack/cert-manager \<br>  --namespace cert-manager \<br>  --create-namespace \<br>  --version v1.5.3 \<br>  --set installCRDs=true</pre><h3>Certificate</h3><p>The goal here is provision certificates with following Subject Alternative Name (SAN)</p><pre>X509v3 Subject Alternative Name:<br>  DNS:*.exmaple.com, DNS:*.foo.example.com, DNS:*.bar.example.com</pre><p>To do that, we need to create the Certificate resource</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f3ed0fb8ee36b34e90a3a77ef7c4398b/href">https://medium.com/media/f3ed0fb8ee36b34e90a3a77ef7c4398b/href</a></iframe><ul><li>For any changes in spec/dnsNames, cert-manager will try request a new certificate immediately</li><li>If the certificate is successfully created, it will create a kubenetes secret with the same of the Certificate resource, i.e</li></ul><pre>#kubectl krew install view-secret<br>kubectl view_secret letsencrypt-exmaple<br>Multiple sub keys found. Specify another argument, one of:<br>-&gt; tls.crt<br>-&gt; tls.key<br>#To examine the certificate content<br>openssl x509 -text -noout -in \<br>&lt;(k view-secret letsencrypt-exmaple tls.crt)</pre><ul><li>Use kubectl get certificate letsencrypt-exmaple to see certificate status, you may see READY: False in case of the certificate fail to renew, i.e</li></ul><pre>kubectl get cert<br>NAME                      READY   SECRET                    AGE<br>letsencrypt-exmaple       False   letsencrypt-exmaple       77d</pre><ul><li>the secret will update if only the renewal is successful, this means if the certificate renewal failed, the previous certificate/secret is still valid and able to serve as long as it&#39;s not expired</li></ul><h3>Issuer</h3><p>Now we need an Issuer and we here we use letsencrypt as the certificate issuing authority (CA). Here we use Cloudflare as our dns provider, see <a href="https://cert-manager.io/docs/configuration/acme/dns01/#supported-dns01-providers">here</a> for other providers.</p><p>Let’s create a secrete to store the CloudFlare token</p><pre>kubectl apply -n kube-system -f - &lt;&lt;EOF<br>apiVersion: v1<br>kind: Secret<br>metadata:<br>  name: cert-manager-cloudflare<br>type: Opaque<br>data:<br>  api-token: |<em><br>    </em>    &quot;&lt;base64 encoded cloudflare token&gt;&quot;<br>EOF</pre><p>And the Issuer :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/874b57c75a3253486fc2f690be383c3a/href">https://medium.com/media/874b57c75a3253486fc2f690be383c3a/href</a></iframe><p>Let’s have a look at certificate request/renewal workflow again : Certificate → Issuer → CertificateRequest → Orders → Challenges</p><h3>CertificateRequest</h3><ul><li>To see the status of a CertificateRequest(cr)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d94902c1e55ee2b5680cffc7b86fe2a/href">https://medium.com/media/6d94902c1e55ee2b5680cffc7b86fe2a/href</a></iframe><ul><li>Let’s examine the cr that’s not ready</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a0b023dba620ecca2a065c78fdbbfca/href">https://medium.com/media/4a0b023dba620ecca2a065c78fdbbfca/href</a></iframe><h3>Orders</h3><p>From the Events from the CertificateRequest, we can see it&#39;s pending on Orders</p><ul><li>To see the status of a Order</li></ul><pre>➜ k get orders<br>NAME                                       STATE   AGE<br>letsencrypt-exmaple-g6c42-3951340514       valid   26d<br>letsencrypt-exmaple-4l52x-4032545276               79m</pre><ul><li>Let’s examine the order that doesn’t have a valid state</li></ul><pre>kubectl describe order letsencrypt-exmaple-4l52x-4032545276<br>....</pre><blockquote>At the time of writing this article, the Let’s Encrypt server was down, and I got the following errors from cert-manager 🥵</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/795500197ed933d4f2ceaaedb411c4fc/href">https://medium.com/media/795500197ed933d4f2ceaaedb411c4fc/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfP4rXLU4mbxJPix_5QhRg.png" /></figure><p>Luckily, some other servers are still avalable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q0Tc4ITNIJrIwXkaC2RNCg.png" /></figure><p>Let’s update the <strong>Issuer/spec/acme/server</strong> to <a href="http://ocsp.root-x1.letsencrypt.org/">ocsp.root-x1.letsencrypt.org</a> that’s not affected, now we should see the below Events:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6fe430c0f315b8021a6a30ab7c13d201/href">https://medium.com/media/6fe430c0f315b8021a6a30ab7c13d201/href</a></iframe><h3>Challenges</h3><p>Finally, from the Orders events, we can see it generate a Challenge resource for each SAN included in the certificate.</p><ul><li>You can always do kubectl get challanges and kubectl describe challenge to see more details, noted these resource will be cleanup once finish.</li><li>Normally if any of the challenges failed, the order won&#39;t be complete, then the certificateRequest will be pending, the certificate resource won&#39;t be ready, and the kubernetes secret won&#39;t be updated/created.</li></ul><h3>Usage</h3><p>Now we have the certificate issued, what can we do with it? An example is that we can present this certificate on Istio Gateway to serve HTTPS requests</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30fe46d33158034e4366bff523fa43b5/href">https://medium.com/media/30fe46d33158034e4366bff523fa43b5/href</a></iframe><h3>Troubleshoot</h3><p>Finally, below are a few tips for troubleshooting</p><ul><li>Follow the workload and kubectl get/ kubectl describe related resources and get more details</li><li>Look at cert-manager logskubectl logs cert-manager-xxx</li><li>Try deleting one of the below resource, if you think you fix the issue and retry:</li></ul><blockquote>If you delete a Challange resource (kubectl delete challange) it will automatically regenerate by Orders</blockquote><blockquote>If you delete a Orders resource (kubectl delete order) it will automatically regenerate by CertificateRequest</blockquote><blockquote>If you delete a CertificateRequest resource (kubectl delete cr) it will automatically regenerate by Certificate</blockquote><ul><li>Noted Let’s Encrypt has some retry limit, sometimes you have to wait even after the above deletion</li><li>If you add new SAN to your certificate, you may get email from Let’s Encrypted about <strong>“Let’s Encrypt certificate expiration notice for domain…”</strong>, have a look at the domains, it should be fine if that doesn’t include the new SAN you added 😉</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb6dfd2c5815" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>