/

October 25, 2023

Using Google Managed SSL Certificates with GKE Ingress Controller

Google Managed SSL Certificates on Google Cloud Platform (GCP) is a service that secures your website or app with SSL or TLS encryption. It offers automatic certificate management to ensure secure and reliable data transmission for your website worldwide. 

These certificates integrate with numerous GCP services, undergo automatic renewal to prevent outages, and prove highly beneficial. Configuring SSL/TLS encryption is straightforward and offers easy accessibility, even for users without a background in security.

Basically, Googlemanaged SSL certificates on GCP to simplify and improve website security while simplifying the certificate management process to ensure a good and reliable experience.

  1. You should be owning own your domain in order to point the load balancer to your hosting name.
  2. Reserve an External IP address in VPC 
  3. Go to VPC Services and click on “IP Address”.
tRPEYISDxJH6pg5XK9th99yUZTNzF MnFyVXtsTdpL5Vcgg2pvOzpxz6JK4LOOrBw2cj5FtXOSIPtmoomKl
  1. Now click on Reserve External IP address 
FYXIyaZWWmZEfZbKKw5N03YJW429fLyOMfHTFbZiTQ71pNUXGcA6juVEWEovLmoxO08bH3LjGMGijlTcBOMBj 5xjJobBA uCGbeWtqvBPSJVEgXV0 ssTfVV7vRQa5fAH2SzR4CyZCR Xjg6vRIXzduV7vgCJLs
  1. Type a name for this IP and provide a little description.
  2. Select Global in TYPE secation and click on reserve. 

Now, assign this IP to your subdomain by creating an A record in your DNS zone. Use your desired domain name and point the Reserved External IP to this domain.

  1. Go to the GKE cluster and connect through the cloud shell by typing the gcloud cli command for authenticating into your GKE cluster.

gcloud container clusters get-credentials <your-cluster-name> –region <your-cluster-region> –project <your-project-name>

  1. Now create a managed certificate yaml manifest file in order to create  a SSL certificate using any text editor.

apiVersion: networking.gke.io/v1

kind: ManagedCertificate

metadata:

  name: managed-cert

spec:

  domains:

    – <your-hosting-domain>

Save this file as managed-cert.yaml

  1. Now execute this yaml file by using “kubectl” command:

Kubectl apply -f managed-cert.yaml

Now wait for some time to get this certificate provisioned and the status to turn to Active.

  1. To check whether the certificate is active or not, type the following command:

kubectl get managedcertificate <your-cert-name> -n <your-namespace>

P LPC9yiB4tYA8Pua B1lxGE6HIuxtoMy0bKQ3gPouUSI4V2SRXm 041ckUjLeh2V9Z4h4F30p1ryosky kmVBhh3uoRaHGffw6EPFXLtk6oltcOTG2toIBwmgvKzA2G89L Sf9vZB SJCpmGfY0 1dFrXwOrVG
  1. Now create an ingress file and name it “managed-cert-ingress.yaml” and its content and structure should be like this:

apiVersion: networking.k8s.io/v1

kind: Ingress

metadata:

  name: joyscore-ingress

  namespace: joyscore

  annotations:

    networking.gke.io/managed-certificates: “<your-cert-name>”

    kubernetes.io/ingress.global-static-ip-name: “<your-reserved-static-external-ip-name>”

spec:

  rules:

    – host: stgapi.joyscore.dev

      http:

        paths:

          – path: /

            pathType: Prefix

            backend:

              service:

                name: exp-gateway

                port:

                  number: 8080

  1. Now execute it using “kubectl” command:

Kubectl apply -f managed-cert-ingress.yaml

  1. Now check the description of the services through the following command:
  1. For check the managed certificate 

kubectl describe managedcertificate -n <your-namespace>

1CY2Z jBcx7eygGYOIfeT0hf0XAALTYMzedXEjLan2SI8k6LpZaHiKr dVN0Bsar3PCbjILhwxtD4TKomEVLVYjSDdFXKRry7XusazWbYZjAX1tTx subIJy2 o3 QTNl0hLs2wq7MfAP8l8ZOpGRIq csul bDU
  1. For checking the ingress controller service

kubectl describe ingress <ingress-name> -n joyscore

NA59T8UqxVEX Kj8vWTnuULCY7RtSHSbEmE2JpQk OheNaUIFEcMFYWlO21BMC3AOQZ3XkmDzjtxcE8YbWHToGfP97XekjqEcMfEWGXOX0iXLayhRj2vneL0SUdzz5ajMi73pu4Q o5r8ya6FgjzoNn1v2Ka 5GM
  1. For checking the ingress 

kubectl get ingress -n <your-namespace> 

2O9UYRoCmFxOkI SN2g NIhTyg3osa0Sf6uuFGye49CDybQlSkl2LvPDVsah oZGdGytOl9CvGvRUSsw8R81QJVjU vZbsY0jfM77qQFDYMtpdbDqdW1RrJvghnhPXFyeaT Ml52NuYkN97YRS0qWNsVLwrkLV5X

Now if you go to the browser and hit the URL that you have hosted to point this ingress, it will display the page with valid https ssl certificate.

bXElSvBMfhAV9cu4WN4BOcH7jKbdqZMIaeAFNfdoThSs4UsJJe64GThxD7vq3wYgprkIuu9FTMmBQktSeEV11hWydR71b0TzkHH6bo x8RtVv2G8wU3

So, in this blog, we have learned how to use Google-Managed SSL Certificate for the GKE Ingress Controller.