Chapter 4. OpenShift Service Mesh and cert-manager
The cert-manager tool provides a unified API to manage X.509 certificates for applications in a Kubernetes environment. You can use cert-manager to integrate with public or private key infrastructures (PKI) and automate certificate renewal.
The cert-manager tool ensures the certificates are valid and up-to-date by attempting to renew certificates at a configured time before they expire.
4.1. About integrating Service Mesh with cert-manager and istio-csr Copy linkLink copied to clipboard!
The cert-manager Operator for Red Hat OpenShift enhances certificate management for securing workloads and control plane components in Red Hat OpenShift Service Mesh and Istio. It supports issuing, delivering, and renewing certificates used for mutual Transport Layer Security (mTLS) through cert-manager issuers.
By integrating Istio with the istio-csr agent, which the cert-manager Operator manages, you enable Istio to request and manage the certificates directly. The integration simplifies security configuration and centralizes certificate management within the cluster.
You must install the cert-manager Operator for Red Hat OpenShift before you create and install your Istio resource.
4.1.1. Installing cert-manager Copy linkLink copied to clipboard!
Integrate the cert-manager Operator with OpenShift Service Mesh by deploying the istio-csr agent and configuring an Istio resource to process certificate signing requests for workloads and the control plane.
Prerequisites
- You have installed the cert-manager Operator for Red Hat OpenShift version 1.15.1.
- You have logged in to OpenShift Container Platform 4.14 or later.
- You have installed the OpenShift Service Mesh Operator.
-
You have a
IstioCNIinstance running in the cluster. -
You have installed the
istioctlcommand.
Procedure
Create the
istio-systemnamespace by running the following command:$ oc create namespace istio-systemCreate the root issuer by creating an
Issuerobject in a YAML file.Create an
Issuerobject similar to the following example:NoteThe
selfSignedissuer serves demonstration purposes, testing, or proof-of-concept environments. For production deployments, use a secure and trusted CA.apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: selfsigned namespace: istio-system spec: selfSigned: {} --- apiVersion: cert-manager.io/v1 kind: Certificate metadata: name: istio-ca namespace: istio-system spec: isCA: true duration: 87600h # 10 years secretName: istio-ca commonName: istio-ca privateKey: algorithm: ECDSA size: 256 subject: organizations: - cluster.local - cert-manager issuerRef: name: selfsigned kind: Issuer group: cert-manager.io --- apiVersion: cert-manager.io/v1 kind: Issuer metadata: name: istio-ca namespace: istio-system spec: ca: secretName: istio-ca ---Create the objects by running the following command:
$ oc apply -f issuer.yamlWait for the
istio-cacertificate to contain the "Ready" status condition by running the following command:$ oc wait --for=condition=Ready certificates/istio-ca -n istio-system
Copy the
istio-cacertificate to thecert-managernamespace so it can be used by istio-csr:apiVersion: operator.openshift.io/v1alpha1 kind: IstioCSR metadata: name: default namespace: istio-csr spec: istioCSRConfig: certManager: issuerRef: name: istio-ca kind: Issuer group: cert-manager.io istiodTLSConfig: trustDomain: cluster.local istio: namespace: istio-systemCreate the
istio-csragent by running the following command:$ oc create -f istioCSR.yamlVerify that the
istio-csrdeployment is ready by running the following command:$ oc get deployment -n istio-csr
Install the
istioresource:NoteThe configuration disables the built-in CA server for Istio and forwards certificate signing requests from
istiodto theistio-csragent. Theistio-csragent obtains certificates for bothistiodand mesh workloads from the cert-manager Operator. Theistio-csragent generates theistiodTLS certificate, and the system mounts it into the pod at a known location.Create the
Istioobject similar to the following example:apiVersion: sailoperator.io/v1 kind: Istio metadata: name: default spec: version: v1.24-latest namespace: istio-system values: global: caAddress: cert-manager-istio-csr.istio-csr.svc:443 pilot: env: ENABLE_CA_SERVER: "false"Create the
Istioresource by running the following command:$ oc apply -f istio.yamlVerify that the
istioresource displays the "Ready" status condition by running the following command:$ oc get -n istio-system secret istio-ca -o jsonpath='{.data.tls\.crt}' | base64 -d > ca.pemCreate a secret from the local certificate file in the
cert-managernamespace by running the following command:$ oc create secret generic -n cert-manager istio-root-ca --from-file=ca.pem=ca.pem