KOP Recipes - Create Addon - Rafay Product Documentation

Create Addon

What Will You Do

In this exercise,

Important

This tutorial describes the steps to create and use a cert-manager based blueprint using the Web Console. The entire workflow can also be fully automated and embedded into an automation pipeline.


Assumptions

To use cert-manager with Let’s Encrypt, we should be able to resolve the challenge that Let’s Encrypt makes to verify that we own the domain. In this particular example, we will use Ingress to resolve the challenge and therefore will use the managed Ingress controller from the default cluster blueprint.


Challenges

In order for the ACME CA server to verify that a requester owns the domain, a certificate is being requested for, the client must complete “challenges”. This is to ensure clients are unable to request certificates for domains they do not own and as a result, fraudulently impersonate another’s site.

The ACME Issuer type represents a single account registered with the Automated Certificate Management Environment (ACME) Certificate Authority server. When you create a new ACME Issuer, cert-manager will generate a private key which is used to identify you with the ACME server.


Step 1: Download Helm Chart

Use your helm client to download the latest release of Cert Manager helm chart file cert-manager-x.y.z.tgz to your machine. In this recipe, we use Cert Manager v1.2.0.

helm repo add jetstack https://charts.jetstack.io
helm fetch jetstack/cert-manager

Step 2: Customize Values

In this step, we will be creating a custom "cert-manager-values.yaml" file so that CRD's get installed.

installCRDs: true

Step 3: Create Addon


Step 4: Create Blueprint

Now, we are ready to assemble a custom cluster blueprint using this addon.


Step 5: Apply Blueprint

Now, we are ready to apply this blueprint to a cluster.

This will start the deployment of the addons in the "cert-manager" blueprint to the targeted cluster. The blueprint sync process can take a few minutes. Once complete, the cluster will display the current cluster blueprint details and whether the sync was successful or not.


Step 6: Verify Deployment

Users can optionally verify whether the correct resources have been created on the cluster.

kubectl get ns cert-manager
kubectl get po -n cert-manager

Shown below is an example for what you should see on a cluster where cert-manager has been deployed as a cluster blueprint.

Cert-manager creates a number of Custom Resources-CRDs on the cluster. You can view them by issuing the following command from the KubeCTL CLI utility.

kubectl get crd |grep cert-manager

certificaterequests.cert-manager.io          2021-02-24T19:57:09Z
certificates.cert-manager.io                 2021-02-24T19:57:09Z
challenges.acme.cert-manager.io              2021-02-24T19:57:10Z
clusterissuers.cert-manager.io               2021-02-24T19:57:10Z
issuers.cert-manager.io                      2021-02-24T19:57:11Z
orders.acme.cert-manager.io                  2021-02-24T19:57:12Z

Step 7: Add Cluster Issuer

In this step, we will be adding "Cluster Issuer". The Cluster Issuer is a cluster wide resource and can be leveraged by multiple workloads operating in the cluster.

## Create ClusterIssuer Object
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
  name: letsencrypt-http
  namespace: default
spec:
  acme:
    # The ACME server URL
    server: https://acme-v02.api.letsencrypt.org/directory
    # Email address used for ACME registration
    email: user@example.com
    # Name of a secret used to store the ACME account private key
    privateKeySecretRef:
      name: letsencrypt-http
    solvers:
    - http01:
        serviceType: ClusterIP
        ingress:
          class: nginx

Step 8: Create Addon


Step 9: Update Blueprint

Now, we need to update the custom cluster blueprint that we created earlier for cert-manager using this addon.


Step 10: Apply Blueprint

Now, we are ready to apply this blueprint to a cluster.


Recap

Congratulations! You have successfully created a custom cluster blueprint with the "cert-manager" addon and applied to a cluster. You also created a cluster issuer that can securely interact with Let's Encrypt to programmatically mint certificates. You can now use this blueprint on as many clusters as you require.