{"id":1460,"date":"2021-10-09T18:28:21","date_gmt":"2021-10-09T16:28:21","guid":{"rendered":"https:\/\/www.netexpertise.eu\/en\/?p=1460"},"modified":"2021-11-13T10:16:08","modified_gmt":"2021-11-13T08:16:08","slug":"auto-renew-letsencrypt-certificate-on-kubernetes","status":"publish","type":"post","link":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html","title":{"rendered":"Auto Renew LetsEncrypt Certificates on Kubernetes"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Install cert-manager<\/h2>\n\n\n\n<p><a href=\"https:\/\/cert-manager.io\/docs\/\" target=\"_blank\" rel=\"noreferrer noopener\">Cert-manager<\/a> comes as a Helm chart with its own custom resources you can install on your Kubernetes cluster. It helps certificates automation, renewal and management. It is a MUST have when you deal with certificate providers who offer APIs that let you automate these processes. On the side, you&#8217;d better renew LetsEncrypt certificate automatically since they are valid for a 3 month period.<\/p>\n\n\n\n<p>cert-manager is available on the Jetstack Helm repository, add it to your Helm repository list<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">helm repo add jetstack https:\/\/charts.jetstack.io\nhelm repo update<\/code><\/pre>\n\n\n\n<p><br>Cert-manager runs in its own namespace, so first create it, and install cert-manager helm chart<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">kubectl create namespace cert-manager\nhelm install cert-manager \\\n     --namespace cert-manager jetstack\/cert-manager \\\n     --set installCRDs=true<\/code><\/pre>\n\n\n\n<p><em>&#8211;set installCRDs=true<\/em> tells cert-manager to install custom resources such as certificaterequests, certificates or clusterissuers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>LetsEncrypt Cluster issuer<\/h2>\n\n\n\n<p>A cluster issuer will contain information about a certificate provider. If you want to get your SSL certificates signed by LetsEncrypt, you will need to apply this yaml file to the Kubernetes cluster:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">apiVersion: cert-manager.io\/v1\nkind: ClusterIssuer\nmetadata:\n  name: letsencrypt-prod\nspec:\n  acme:\n    email: it@company.xxx\n    privateKeySecretRef:\n      name: letsencrypt-prod\n    server: <a target=\"_blank\" href=\"https:\/\/acme-v02.api.letsencrypt.org\/directory\" rel=\"noreferrer noopener\">https:\/\/acme-v02.api.letsencrypt.org\/directory<\/a>\n    solvers:\n    - http01:\n        ingress:\n          class: public-iks-k8s-nginx<\/code><\/pre>\n\n\n\n<p><br>LetsEncrypt belongs to the <a href=\"https:\/\/cert-manager.io\/docs\/configuration\/acme\/\" target=\"_blank\" rel=\"noreferrer noopener\">ACME<\/a> issuers category, meaning it is trusted by most web browsers. It provides a certificate after checking you are the owner of the domain. The check can be done in 2 ways: either a DNS TXT entry or an HTTP challenge. Kubernetes serves HTTP so most people will go for the HTTP01 challenge. This is defined in the solvers section.<br><br>The second important piece of information is the class. cert-manager will look at ingresses whose class matches and will provide them with an SSL certificate. <a href=\"\/en\/tag\/ibmcloud\">IBM Cloud<\/a> public ingress class annotation is called public-iks-k8s-nginx, so you need to set it in your cluster issuer configuration. Check your ingress to adapt to your own needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Ingress Definition<\/h2>\n\n\n\n<p>Now that you have a cluster issuer and cert-manager installed, you need to tell them which ingress they should provide certificates to. This is done with ingress annotations.<br>Simply set the cluster issuer in the <em>cert-manager.io\/cluster-issuer<\/em> annotation.<br>As seen before, the <em>kubernetes.io\/ingress.class<\/em> annotation is set to <em>public-iks-k8s-nginx<\/em> on IKS. Set whatever suits your setup.<br>Add acme.cert-manager.io\/http01-edit-in-place wether you want to create a separate ingress for the HTTP challenge or want it to be part of the existing ingress.<br><br><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">apiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: app-ingress\n  labels:\n    name: app-ingress\n  annotations:\n    acme.cert-manager.io\/http01-edit-in-place: \"true\"\n    cert-manager.io\/cluster-issuer: letsencrypt-prod\n    kubernetes.io\/ingress.class: public-iks-k8s-nginx\nspec:\n  tls:\n  - hosts:\n    - www.netexpertise.eu\n    secretName: letsencrypt-netexpertise\n\n  rules:\n  - host: www.netexpertise.eu\n    http:\n      paths:\n      - path: \/\n        pathType: Prefix\n        backend:\n          service:\n            name: app-backend-app\n            port:\n              number: 80<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><br>Renew LetsEncrypt Certificate<\/h2>\n\n\n\n<p>Cert-manager will create ingress, service and pod in your own namespace that will provide a web page for the HTTP challenge. They will disappear as soon as LetsEncrypt certificate has been renewed and delivered into the secret defined in secretName.<br><br>If something goes wrong, you can check the logs of the different pods in the cert-manager namespace, as well as the certificate resource status. A <em>kubectl describe cert<\/em> should give all necessary information.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install cert-manager Cert-manager comes as a Helm chart with its own custom resources you can install on your Kubernetes cluster. It helps certificates automation, renewal and management. It is a MUST have when you deal with certificate providers who offer APIs that let you automate these processes. On the side, you&#8217;d better renew LetsEncrypt certificate [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[424],"tags":[408,215,436,443,442,31],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes<\/title>\n<meta name=\"description\" content=\"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes\" \/>\n<meta property=\"og:description\" content=\"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html\" \/>\n<meta property=\"og:site_name\" content=\"Netexpertise\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-09T16:28:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-11-13T08:16:08+00:00\" \/>\n<meta name=\"author\" content=\"dave\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@netexpertise\" \/>\n<meta name=\"twitter:site\" content=\"@netexpertise\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html\",\"name\":\"Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes\",\"isPartOf\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\"},\"datePublished\":\"2021-10-09T16:28:21+00:00\",\"dateModified\":\"2021-11-13T08:16:08+00:00\",\"author\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\"},\"description\":\"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically\",\"breadcrumb\":{\"@id\":\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.netexpertise.eu\/en\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Auto Renew LetsEncrypt Certificates on Kubernetes\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#website\",\"url\":\"http:\/\/www.netexpertise.eu\/en\/\",\"name\":\"Netexpertise\",\"description\":\"Systems \/ Networks \/ DevOps\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa\",\"name\":\"dave\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g\",\"caption\":\"dave\"},\"sameAs\":[\"http:\/\/www.netexpertise.eu\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes","description":"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html","og_locale":"en_US","og_type":"article","og_title":"Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes","og_description":"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically","og_url":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html","og_site_name":"Netexpertise","article_published_time":"2021-10-09T16:28:21+00:00","article_modified_time":"2021-11-13T08:16:08+00:00","author":"dave","twitter_card":"summary_large_image","twitter_creator":"@netexpertise","twitter_site":"@netexpertise","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html","url":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html","name":"Netexpertise - Auto Renew LetsEncrypt Certificates on Kubernetes","isPartOf":{"@id":"http:\/\/www.netexpertise.eu\/en\/#website"},"datePublished":"2021-10-09T16:28:21+00:00","dateModified":"2021-11-13T08:16:08+00:00","author":{"@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa"},"description":"Create and renew LetsEncrypt SSL Certificate with Cert Manager on IBM Cloud Kubernetes Services and other providers automatically","breadcrumb":{"@id":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.netexpertise.eu\/en\/docker\/kubernetes\/auto-renew-letsencrypt-certificate-on-kubernetes.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.netexpertise.eu\/en"},{"@type":"ListItem","position":2,"name":"Auto Renew LetsEncrypt Certificates on Kubernetes"}]},{"@type":"WebSite","@id":"http:\/\/www.netexpertise.eu\/en\/#website","url":"http:\/\/www.netexpertise.eu\/en\/","name":"Netexpertise","description":"Systems \/ Networks \/ DevOps","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.netexpertise.eu\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/cb4cd666549d22e9070ec1cfc1a496fa","name":"dave","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.netexpertise.eu\/en\/#\/schema\/person\/image\/","url":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","contentUrl":"http:\/\/1.gravatar.com\/avatar\/1129916e1f4955bd632f27f836f64e55?s=96&d=mm&r=g","caption":"dave"},"sameAs":["http:\/\/www.netexpertise.eu"]}]}},"_links":{"self":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1460"}],"collection":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/comments?post=1460"}],"version-history":[{"count":0,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.netexpertise.eu\/en\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}