{"id":529,"date":"2022-02-28T07:56:04","date_gmt":"2022-02-28T07:56:04","guid":{"rendered":"https:\/\/cloudspert.com\/?p=529"},"modified":"2025-03-13T00:33:37","modified_gmt":"2025-03-13T00:33:37","slug":"opendistro-with-cert-manager","status":"publish","type":"post","link":"https:\/\/cloudspert.com\/?p=529","title":{"rendered":"OpenDistro with cert-manager"},"content":{"rendered":"<p>Last time we talked about installing OpenDistro on Kubernetes using self-signed certificates, this can be a repetitive and boring task to do each time. Instead we can delegate the creation of certificates to a tool like cert-manager.<\/p>\n<p>If you didn\u2019t read the first part of this article you can find it\u00a0here<\/p>\n<p><a href=\"https:\/\/abdellahtdj.medium.com\/opendistro-with-keycloak-ae3bb8ae6051\">OpenDistro with Keycloak<\/a><\/p>\n<h3>cert-manager<\/h3>\n<p>cert-manager is a native Kubernetes certificate management controller. It can help with issuing certificates from a variety of sources, such as Let\u2019s Encrypt, HashiCorp Vault, Venafi, a simple signing key pair, or self\u00a0signed.<\/p>\n<h4>Deploying cert-manager<\/h4>\n<p>cert-manager is really simple to deploy, we\u2019ll be using helm, to do so follow the next\u00a0steps:<\/p>\n<pre>helm repo add jetstack <a href=\"https:\/\/charts.jetstack.io\/\">https:\/\/charts.jetstack.io<\/a><br \/>helm repo update<br \/>helm install <br \/>  cert-manager jetstack\/cert-manager <br \/>  --namespace cert-manager <br \/>  --create-namespace <br \/>  --version v1.4.0 <br \/>  <em>--set installCRDs=true<\/em><\/pre>\n<p>It is as simple as that to install cert-manager on you\u2019re cluster, next step is to configure the\u00a0Issuer.<\/p>\n<h4>Issuers<\/h4>\n<p>An <strong>Issuer<\/strong> is Kubernetes resources that represent certificate authorities (CAs) that are able to generate certificates, there are multiples types of issuers, the most important are\u00a0:<\/p>\n<ul>\n<li><strong>SelfSigned:<\/strong> Certificates will be signed by using the same private-key attached to the signed certificate.<\/li>\n<li><strong>CA: <\/strong>Certificates are signed using an already imported certificate authority<\/li>\n<li><strong>Vault: <\/strong>This will delegate the signing of certificate to vault, which can be configured a\u00a0PKI.<\/li>\n<li><strong>ACME: <\/strong>ACME stand for Automated Certificate Management Environment, some of the well know example for ACME is <strong>lets\u00a0encrypt<\/strong>.<\/li>\n<\/ul>\n<p><strong>Issuer<\/strong> Kubernetes resources are namespaces, when creating an Issuer in a namespace it can only be used within the namespace, to declare an issuer for your hole cluster you can use <strong>ClusterIssuer<\/strong>, which is the same as Issuer but it can be used on a cluster\u00a0level.<\/p>\n<p><strong>Configure Issuers<\/strong><\/p>\n<p>In our case we\u2019ll be using self-signed certificates for cluster certificates, since they will be used only within the OpenDistro.<\/p>\n<pre>apiVersion: cert-manager.io\/v1alpha2                       <br \/>kind: Issuer                       <br \/>metadata:                         <br \/>  name: selfsigned-issuer                         <br \/>  namespace: opendistro                      <br \/>spec:                         <br \/>  selfSigned: {}<\/pre>\n<p><strong>Certificates<\/strong><\/p>\n<p>Certificates are also Kubernetes resources, this resource will base on an Issuer to create certificates that will be stored inside Kubernetes secrets<\/p>\n<p>To create certificates that can be used by OpenDistro we need to pass special configuration options:<\/p>\n<pre>apiVersion: cert-manager.io\/v1                       <br \/>kind: Certificate                       <br \/>metadata:                         <br \/>  name: es-transport-tls                         <br \/>  namespace: opendistro                       <br \/>spec:                         <br \/>  isCA: true                         <br \/>  duration: 2160h # 90d 2160h                         <br \/>  renewBefore: 168h # 7d 168h                         <br \/>  commonName: es-client                         <br \/>  dnsNames:                           <br \/>  - es-client                         <br \/>  privateKey:                           <br \/>    algorithm: RSA                           <br \/>    encoding: PKCS8                           <br \/>    size: 4096                         <br \/>  issuerRef:                          <br \/>    kind: Issuer                           <br \/>    name: selfsigned-issuer                         <br \/>  secretName: es-transport-tls<\/pre>\n<p>Don\u2019t worry we\u2019ll explain some of the options that are not self explicit:<\/p>\n<ul>\n<li><strong>commonName: <\/strong>This needs to be the same as the value of node_dn in OpenDistro configuration.<\/li>\n<li><strong>encoding: <\/strong>by default cert-manager generates privatekeys in PKCS11 format which is not supported by OpenDistro, so we need to change it to a\u00a0PKCS8.<\/li>\n<li><strong>secretName: <\/strong>the name of Kubernetes secret where the certificate and the private key will be\u00a0stored.<\/li>\n<\/ul>\n<h4><strong>OpenDistro configuration:<\/strong><\/h4>\n<p>For OpenDistro most of the configuration will remain the same, but we need to change few options related to certificates names.<\/p>\n<pre>......<br \/>elasticsearch:<br \/>......<br \/>  tls:<br \/>    existingCertSecret: es-transport-tls<br \/>    existingCertSecretCertSubPath: tls.crt<br \/>    existingCertSecretKeySubPath: tls.key<br \/>    existingCertSecretRootCASubPath: ca.crt<br \/>.........<\/pre>\n<p>Since the secret keys are changed we need to adapt the configuration. As for the rest of the installation it will remain the\u00a0same.<\/p>\n<pre>helm upgrade --install <br \/>     -n opendistro  &lt;release_name&gt;  -f values.yaml <br \/>     \/opendistro-build\/helm\/opendistro-es<\/pre>\n<p>As always you can find all the configuration files on my\u00a0GitHub.<\/p>\n<p>I hope that you found this article useful and see you next\u00a0time.<\/p>\n<h3>Bey\u00a0!!!<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/medium.com\/_\/stat?event=post.clientViewed&amp;referrerSource=full_rss&amp;postId=3a95eb4939f0\" width=\"1\" height=\"1\" alt=\"\"\/><\/p>","protected":false},"excerpt":{"rendered":"<p>Last time we talked about installing OpenDistro on Kubernetes using self-signed certificates, this can be a repetitive and boring task to do each time. Instead we can delegate the creation of certificates to a tool like cert-manager. If you didn\u2019t read the first part of this article you can find it\u00a0here OpenDistro with Keycloak cert-manager cert-manager is a native Kubernetes certificate management controller. It can help with issuing certificates from a variety of sources, such as Let\u2019s Encrypt, HashiCorp Vault, Venafi, a simple signing key pair, or self\u00a0signed. Deploying cert-manager cert-manager is really simple to deploy, we\u2019ll be using helm, to do so follow the next\u00a0steps: helm repo add jetstack https:\/\/charts.jetstack.iohelm repo updatehelm install cert-manager jetstack\/cert-manager &#8211;namespace cert-manager &#8211;create-namespace &#8211;version v1.4.0 &#8211;set installCRDs=true It is as simple as that to install cert-manager on you\u2019re cluster, next step is to configure the\u00a0Issuer. Issuers An Issuer is Kubernetes resources that represent certificate authorities (CAs) that are able to generate certificates, there are multiples types of issuers, the most important are\u00a0: SelfSigned: Certificates will be signed by using the same private-key attached to the signed certificate. CA: Certificates are signed using an already imported certificate authority Vault: This will delegate the signing of certificate to vault, which can be configured a\u00a0PKI. ACME: ACME stand for Automated Certificate Management Environment, some of the well know example for ACME is lets\u00a0encrypt. Issuer Kubernetes resources are namespaces, when creating an Issuer in a namespace it can only be used within the namespace, to declare an issuer for your hole cluster you can use ClusterIssuer, which is the same as Issuer but it can be used on a cluster\u00a0level. Configure Issuers In our case we\u2019ll be using self-signed certificates for cluster certificates, since they will be used only within the OpenDistro. apiVersion: cert-manager.io\/v1alpha2 kind: Issuer metadata: name: selfsigned-issuer namespace: opendistro spec: selfSigned: {} Certificates Certificates are also Kubernetes resources, this resource will base on an Issuer to create certificates that will be stored inside Kubernetes secrets To create certificates that can be used by OpenDistro we need to pass special configuration options: apiVersion: cert-manager.io\/v1 kind: Certificate metadata: name: es-transport-tls namespace: opendistro spec: isCA: true duration: 2160h # 90d 2160h renewBefore: 168h # 7d 168h commonName: es-client dnsNames: &#8211; es-client privateKey: algorithm: RSA encoding: PKCS8 size: 4096 issuerRef: kind: Issuer name: selfsigned-issuer secretName: es-transport-tls Don\u2019t worry we\u2019ll explain some of the options that are not self explicit: commonName: This needs to be the same as the value of node_dn in OpenDistro configuration. encoding: by default cert-manager generates privatekeys in PKCS11 format which is not supported by OpenDistro, so we need to change it to a\u00a0PKCS8. secretName: the name of Kubernetes secret where the certificate and the private key will be\u00a0stored. OpenDistro configuration: For OpenDistro most of the configuration will remain the same, but we need to change few options related to certificates names. &#8230;&#8230;elasticsearch:&#8230;&#8230; tls: existingCertSecret: es-transport-tls existingCertSecretCertSubPath: tls.crt existingCertSecretKeySubPath: tls.key existingCertSecretRootCASubPath: ca.crt&#8230;&#8230;&#8230; Since the secret keys are changed we need to adapt the configuration. As for the rest of the installation it will remain the\u00a0same. helm upgrade &#8211;install -n opendistro &lt;release_name&gt; -f values.yaml \/opendistro-build\/helm\/opendistro-es As always you can find all the configuration files on my\u00a0GitHub. I hope that you found this article useful and see you next\u00a0time. Bey\u00a0!!!<\/p>\n","protected":false},"author":3,"featured_media":635,"comment_status":"open","ping_status":"open","sticky":false,"template":"elementor_canvas","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-529","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-opendistro","entry","has-media"],"jetpack_featured_media_url":"https:\/\/cloudspert.com\/wp-content\/uploads\/2022\/02\/OPENDISTRO.webp","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/posts\/529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudspert.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=529"}],"version-history":[{"count":1,"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":637,"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/posts\/529\/revisions\/637"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudspert.com\/index.php?rest_route=\/wp\/v2\/media\/635"}],"wp:attachment":[{"href":"https:\/\/cloudspert.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudspert.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudspert.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}