Managed Certificates simplify user flow in managing HTTPS traffic. Instead of manually acquiring an SSL certificate from a Certificate Authority, configuring it on the load balancer and renewing it on time, now it is only necessary to create a Managed Certificate Custom Resource object and provide the domains for which you want to obtain a certificate. The certificate will be auto-renewed when necessary.
For that to work you need to run your cluster on a platform with Google Cloud Load Balancer, that is a cluster in GKE or your own cluster in GCP.
In GKE all the components are already installed. Follow the how-to for more information. For a GCP setup follow the instructions below.
This feature status is GA.
Managed Certificates consist of two parts:
You need to grant permissions to the controller so that it is allowed to use the GCP Compute API.
Alternatively:
Create a dedicated service account with minimal roles.
export NODE_SA_NAME=mcrt-controller-sa
gcloud iam service-accounts create $NODE_SA_NAME --display-name "managed-certificate-controller service account"
export NODE_SA_EMAIL=`gcloud iam service-accounts list --format='value(email)' \
--filter='displayName:managed-certificate-controller'`
export PROJECT=`gcloud config get-value project`
gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$NODE_SA_EMAIL \
--role roles/monitoring.metricWriter
gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$NODE_SA_EMAIL \
--role roles/monitoring.viewer
gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$NODE_SA_EMAIL \
--role roles/logging.logWriter
gcloud projects add-iam-policy-binding $PROJECT --member serviceAccount:$NODE_SA_EMAIL \
--role roles/compute.loadBalancerAdmin
gcloud iam service-accounts keys create ./key.json --iam-account $NODE_SA_EMAIL
kubectl create secret generic sa-key --from-file=./key.json
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: "/etc/gcp/key.json"
- name: sa-key-volume
mountPath: /etc/gcp
readOnly: true
- name: sa-key-volume
secret:
secretName: sa-key
items:
- key: key.json
path: key.json
To install Managed Certificates in your own cluster in GCP, you need to:
$ kubectl create -f deploy/managedcertificates-crd.yaml
gcr.io/gke-release/managed-certificate-controller:v1.2.11
which is deployed in GKE, however this README likely will not be kept up to date with
future GKE updates, and so this image may become stale.
$ kubectl create -f deploy/managed-certificate-controller.yaml
apiVersion: networking.gke.io/v1
kind: ManagedCertificate
metadata:
name: example-certificate
spec:
domains:
- example1.com
- example2.com
$ kubectl annotate ingress [your-ingress-name] networking.gke.io/managed-certificates=example-certificate
If you need, you can specify multiple managed certificates here, separating their names with commas.
You can do the below steps in any order to turn SSL off:
$ kubectl annotate ingress [your-ingress-name] networking.gke.io/managed-certificates-
(note the minus sign at the end of annotation name)
$ kubectl delete -f deploy/managed-certificate-controller.yaml
$ kubectl delete -f deploy/managedcertificates-crd.yaml
Check Kubernetes events attached to ManagedCertificate and Ingress resources for information on temporary failures.
Use the same ManagedCertificate resource at every endpoint to which your domain resolves to.
A real life example is when your example.com domain points at two IP addresses, one for IPv4 and one for IPv6. You deploy two Ingress objects to handle IPv4 and IPv6 traffic separately. If you create two separate ManagedCertificate resources and attach each of them to one of the Ingresses, one of the ManagedCertificate resources may not be provisioned. The reason is that the Certificate Authority is free to verify challenges on any of the IP addresses the domain resolves to.
Managed Certificates communicate with GKE Ingress using annotation kubernetes.io/pre-shared-cert. Problems may arise for instance if you: