-
Notifications
You must be signed in to change notification settings - Fork 105
feat(mesh): cert-manager for control plane certificates #5613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lmilan
wants to merge
7
commits into
main
Choose a base branch
from
feat/mesh-cert-manager
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
04ac164
how-to draft
lmilan a6106fa
Update use-cert-manager-for-control-plane-certificates.md
lmilan 8d14493
Update use-cert-manager-for-control-plane-certificates.md
lmilan 9877e8b
fixes
lmilan e4fe609
fixes
lmilan 6075e9c
add links
lmilan 16a5efd
copy edits
lmilan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 197 additions & 0 deletions
197
app/_how-tos/mesh/use-cert-manager-for-control-plane-certificates.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| --- | ||
| title: Use cert-manager for control plane certificates | ||
| description: Learn how to use cert-manager to provision and rotate TLS certificates for the {{site.mesh_product_name}} control plane on Kubernetes. | ||
| content_type: how_to | ||
| permalink: /mesh/use-cert-manager-for-control-plane-certificates/ | ||
| products: | ||
| - mesh | ||
| works_on: | ||
| - on-prem | ||
| breadcrumbs: | ||
| - /mesh/ | ||
| tags: | ||
| - cert-manager | ||
| - certificates | ||
| - security | ||
| tldr: | ||
| q: How do I use cert-manager to manage control plane TLS certificates? | ||
| a: Create a self-signed `ClusterIssuer`, a CA `Certificate`, a CA-backed `Issuer`, and a control plane `Certificate` in the `kong-mesh-system` namespace, then set `controlPlane.tls.general.secretName` in your Helm values to point to the generated secret. | ||
| prereqs: | ||
| inline: | ||
| - title: Helm | ||
| include_content: prereqs/helm | ||
| - title: A running Kubernetes cluster | ||
| include_content: prereqs/kubernetes/mesh-cluster | ||
| - title: Install cert-manager | ||
| include_content: prereqs/cert-manager | ||
| cleanup: | ||
| inline: | ||
| - title: Clean up {{site.mesh_product_name}} | ||
| include_content: cleanup/products/mesh | ||
| related_resources: | ||
| - text: Deploy Mesh on Kubernetes | ||
| url: /mesh/deploy-mesh-on-kubernetes/ | ||
| - text: Deploy Mesh (self-managed) | ||
| url: /mesh/deploy-mesh-self-managed/ | ||
| - text: Kubernetes cert-manager CA policy (data plane certificates) | ||
| url: /mesh/cert-manager/ | ||
| --- | ||
|
lmilan marked this conversation as resolved.
|
||
|
|
||
| By default, {{site.mesh_product_name}} generates its own self-signed control plane certificates at startup. Using cert-manager lets you manage the full certificate lifecycle, issuance, rotation, and expiration, outside of the control plane itself. This guide walks you through creating the required cert-manager resources and configuring {{site.mesh_product_name}} to use them. | ||
|
|
||
| ## Create the {{site.mesh_product_name}} namespace | ||
|
|
||
| The cert-manager resources in the following steps are scoped to the `kong-mesh-system` namespace, which {{site.mesh_product_name}} uses at install time: | ||
|
|
||
| ```sh | ||
| kubectl create namespace kong-mesh-system | ||
| ``` | ||
|
|
||
| ## Create a self-signed ClusterIssuer | ||
|
|
||
| A `ClusterIssuer` is a cluster-scoped resource that cert-manager uses to sign certificates. Create a self-signed one as the root of your certificate chain: | ||
|
|
||
| ```sh | ||
| echo "apiVersion: cert-manager.io/v1 | ||
| kind: ClusterIssuer | ||
| metadata: | ||
| name: selfsigned-issuer | ||
| spec: | ||
| selfSigned: {}" | kubectl apply -f - | ||
| ``` | ||
|
|
||
| ## Create the CA certificate | ||
|
|
||
| Use the `selfsigned-issuer` to create a CA certificate in the `kong-mesh-system` namespace. This certificate acts as the root CA that signs the control plane certificate: | ||
|
|
||
| ```sh | ||
| echo "apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: kong-mesh-selfsigned-ca | ||
| namespace: kong-mesh-system | ||
| spec: | ||
| isCA: true | ||
| commonName: kong-mesh-selfsigned-ca | ||
| secretName: root-secret | ||
| privateKey: | ||
| algorithm: ECDSA | ||
| size: 256 | ||
| issuerRef: | ||
| name: selfsigned-issuer | ||
| kind: ClusterIssuer | ||
| group: cert-manager.io" | kubectl apply -f - | ||
| ``` | ||
|
|
||
| cert-manager stores the CA certificate and key in a secret named `root-secret` in the `kong-mesh-system` namespace. | ||
|
|
||
| ## Create the CA-backed Issuer | ||
|
|
||
| Create a namespace-scoped `Issuer` in `kong-mesh-system` that uses the CA secret to sign certificates: | ||
|
|
||
| ```sh | ||
| echo "apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: kong-mesh-issuer | ||
| namespace: kong-mesh-system | ||
| spec: | ||
| ca: | ||
| secretName: root-secret" | kubectl apply -f - | ||
| ``` | ||
|
|
||
| ## Create the control plane certificate | ||
|
|
||
| 1. Create a `Certificate` resource that cert-manager uses to issue and renew the control plane TLS certificate. The `dnsNames` must include all the DNS names that data planes use to reach the control plane: | ||
|
|
||
| ```sh | ||
| echo "apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: control-plane-cert | ||
| namespace: kong-mesh-system | ||
| spec: | ||
| secretName: control-plane-cert | ||
| duration: 2160h | ||
| renewBefore: 360h | ||
| isCA: false | ||
| privateKey: | ||
| algorithm: RSA | ||
| encoding: PKCS1 | ||
| size: 2048 | ||
| usages: | ||
| - server auth | ||
| dnsNames: | ||
| - kong-mesh-control-plane.kong-mesh-system.svc | ||
| - kong-mesh-control-plane | ||
| - kong-mesh-control-plane.kong-mesh-system | ||
| - kong-mesh-control-plane.kong-mesh-system.svc.local | ||
| issuerRef: | ||
| name: kong-mesh-issuer | ||
| kind: Issuer" | kubectl apply -f - | ||
| ``` | ||
|
|
||
| 1. Wait for the certificate to be issued: | ||
|
|
||
| ```sh | ||
| kubectl wait -n kong-mesh-system --for=condition=ready certificate/control-plane-cert --timeout=60s | ||
| ``` | ||
|
|
||
| ## Install {{site.mesh_product_name}} with the cert-manager certificate | ||
|
|
||
| Install {{site.mesh_product_name}} and point the control plane TLS configuration at the secret cert-manager created: | ||
|
|
||
| ```sh | ||
| helm repo add kong-mesh https://kong.github.io/kong-mesh-charts | ||
| helm repo update | ||
| helm upgrade --install \ | ||
| --namespace kong-mesh-system \ | ||
| kong-mesh kong-mesh/kong-mesh \ | ||
| --set controlPlane.tls.general.secretName=control-plane-cert | ||
| kubectl wait -n kong-mesh-system --for=condition=ready pod --selector=app=kong-mesh-control-plane --timeout=90s | ||
| ``` | ||
|
lmilan marked this conversation as resolved.
|
||
|
|
||
| {:.info} | ||
| > If {{site.mesh_product_name}} is already installed, run `helm upgrade` instead of `helm install` with the same `--set` flag. | ||
|
|
||
| ## Validate | ||
|
|
||
| Verify that the control plane is running and using the cert-manager-issued certificate. | ||
|
|
||
| 1. Confirm the control plane pod is healthy: | ||
|
|
||
| ```sh | ||
| kubectl get pods -n kong-mesh-system | ||
| ``` | ||
|
|
||
| The `kong-mesh-control-plane` pod should show `Running` in the `STATUS` column. | ||
| {:.no-copy-code} | ||
|
|
||
| 1. Inspect the certificate that cert-manager stored in the secret: | ||
|
|
||
| ```sh | ||
| kubectl get secret -n kong-mesh-system control-plane-cert \ | ||
| -o jsonpath='{.data.tls\.crt}' | base64 -d | \ | ||
| openssl x509 -noout -subject -issuer -dates | ||
| ``` | ||
|
|
||
| The output should show `kong-mesh-selfsigned-ca` as the issuer and an expiration date 90 days from issuance. For example: | ||
|
|
||
| ```text | ||
| subject= | ||
| issuer=CN=kong-mesh-selfsigned-ca | ||
| notBefore=Jun 17 09:50:10 2026 GMT | ||
| notAfter=Sep 15 09:50:10 2026 GMT | ||
| ``` | ||
| {:.no-copy-code} | ||
|
|
||
| {:.info} | ||
| > The subject is empty because cert-manager sets identity via SANs rather than a common name. | ||
|
|
||
| 1. Confirm cert-manager will renew the certificate automatically: | ||
|
|
||
| ```sh | ||
| kubectl get certificate -n kong-mesh-system control-plane-cert | ||
| ``` | ||
|
|
||
| The `READY` column should show `True`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Install cert-manager in your cluster to issue and rotate certificates automatically: | ||
|
|
||
| ```sh | ||
| helm repo add jetstack https://charts.jetstack.io | ||
| helm repo update | ||
| helm upgrade --install \ | ||
| cert-manager jetstack/cert-manager \ | ||
| --namespace cert-manager \ | ||
| --create-namespace \ | ||
| --set crds.enabled=true | ||
| kubectl wait -n cert-manager --for=condition=ready pod --all --timeout=90s | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.