Skip to content

Instantly share code, notes, and snippets.

@mj-01
Forked from pydevops/gke-ingress-manged-tls.md
Created December 25, 2022 17:42
Show Gist options
  • Save mj-01/572d5d08e84c4e99c73b1ddb47be36aa to your computer and use it in GitHub Desktop.
Save mj-01/572d5d08e84c4e99c73b1ddb47be36aa to your computer and use it in GitHub Desktop.
Create a GCP managed TLS certificate for the GKE ingress

Solution #1 (ManagedCertificate CRD in GKE)

  • GKE with Google-managed SSL certificates
    • Use ManagedCertificate CRD to create a object.
    • Associate the ManagedCertificate object to an Ingress by adding an annotation networking.gke.io/managed-certificates to the Ingress. This annotation is a comma-separated list of ManagedCertificate resources, cert1,cert2,cert3 for example.

Solution #2 (Google Cloud SSL Certificate)

Assumption

Assumes you are using the default L7 GLBC ingress controller. default for GKE cluster.

create a certficate

gcloud compute ssl-certificates create ci-example --domains ci.example.com

list a certifcate

gcloud compute ssl-certificates list

checking certificate provisoning status

gcloud compute ssl-certificates describe ci-example

Please note with a correct configuration the total time for provisioning certificates is likely to take from 30 to 60 minutes.

configure the GKE ingress with a preshared cert

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ci
  namespace: ci
  annotations:
    ingress.gcp.kubernetes.io/pre-shared-cert: 'ci-example'
spec:
  backend:
    serviceName: jenkins-ui
    servicePort: 8080

ingress.gcp.kubernetes.io/pre-shared-cert is used by ingress-gce

Solution # 3 (k8s secrets)

kubectl create secret tls ci-example \
    --cert ci-example.pem --key ci-example-key.pem

SNI with multiple certficates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment