Self-Cert Rotation with Istio

Self-Cert Rotation with Istio

notes to setup Certs for a dev server (becuase i will forget this)

Lets say you are behind a firewall and want to set HTTPS on your Istio ingress using Self-Cert.

you can do this doing the following.

We will do this the Clicky-buntie way in Rancher.

High-Level steps

  • Enable SDS => please see (
  • setup Cert-Manager
  • create the self-cert issuer
  • create Cert from the issuer
  • attach it to the Istio Gateway


there are 2 ways

  • Via Istio Helm install, you can add the following answer certmanager.enabled=true - note this seems to install an old version (it did for me - v0.8.x).
  • Via JetStack Helm (which allows you to get the latest - v0.15.1 in this case)

lets setup via the Jetstack Helm, with rancher (btw the docs are really good:

In the System Rancher Project, add the jetstack helm3 charts (, It should look like this:

Now you can launch it, in the catalog entries, search for cert

we are going to

  • use the cert-manager namespace
  • add the answer installCRDs=true, this sets up all the CRD’s in one step

ok thats done.

Self Cert Issuer

We want to have our TLS certs to be created and rotated for us.

In this case we choose the ClusterIssuer, it will look for Certificates in any namespace and ensure they are keep upto date. The alternative is to use the Issuer which needs to be deployed in the same namespace as the Certificates it will manage.

kind: ClusterIssuer
  name: selfsigning-issuer
  selfSigned: {}


For istio we need to create a Certificate and have this stored in the Kubernetes TLS secerts inside the istio-system namespace… thats a lot just there

using the Cert-Manager Certificate we can describe this to the ClusterIssuer and it will do all the hard work.

kind: Certificate
  name: awesome-io
  namespace: istio-system
  secretName: awesome-io
  # The use of the common name field has been deprecated since 2000
  commonName: ""
  - Awesome inc
  keySize: 2048
  keyAlgorithm: rsa
  keyEncoding: pkcs1
    name: selfsigning-issuer
    kind: ClusterIssuer

note in the above

  • name: selfsigning-issuer - this is the name of the ClusterIssuer
  • namespace: istio-system - as mentioened we need the Cert to be placed in this namespace, to allow for the SDS to attach it to the Gateway correctly (which we setup in the next step)
  • secretName: awesome-io - we will use this to reference it in the Gateway
  • rotationPolicy: Always - this will rotate the private key

we should have and Certificate now :D

Applying TLS Termination in the Gateway

The Gateway is how we can setup which Hosts and ports we will support.

In this case we want to support and apply TLS with out new Cert.

kind: Gateway
  name: awesome-io-gateway
  namespace: istio-system
    istio: ingressgateway # use istio default ingress gateway
  - port:
      number: 443
      name: https
      protocol: HTTPS
      mode: SIMPLE
      credentialName: awesome-io # must be the same as secret
    - ""

The abvoe has a couple of interesting things

  • tls - this is where we reference the TLS Cert, by its secretName
  • hosts - we have set it here, we could have this this to *
  • namespace - we have placed the gateway in the istio-system, it does not have to go, but in this case we would like to reuse it (later post)

Testing locally

For this setup we need to set the host header in the request

 curl -v --resolve "$SECURE_INGRESS_PORT:$INGRESS_HOST" --insecure "$SECURE_INGRESS_PORT/weather/v1/weatherforecast"


  • SECURE_INGRESS_PORT - Is your HTTPS port (31390)
  • INGRESS_HOST - is your cluster DNS or an IP of one of the nodes.

note the --insecure, this is becuase our cert is Self Signed.

the output should look like this (showing all the handshake)

© 2022 All rights reserved.