How to add a SSL/TLS certificate on Google Kubernetes

5/19/2020

I am working on a web project where the front-end is built on react and hosted over github using gh-pages. Now the backend is built on node.js and hosted on google cloud using kubernetes engine.

The problem is Front-end is on https and Back-end is on Http due to which I am facing mixed content error. I have tried adding ingress but things don't work out for me. This is first time I am hosting something on google cloud.

I don't know how to correctly add ssl certificate to kubernetes to convert http to http(s). I have tried all things present over google cloud documentation but still stuck with no clue what is going wrong.

And also I don't have any domain.

-- Mayank
gcloud
google-cloud-platform
kubectl
kubernetes

1 Answer

5/19/2020

Looking at the Documentation, GCP seems to favor the K8s Standard way of adding SSL/TLS to your Cluster:

https://cloud.google.com/kubernetes-engine/docs/concepts/ingress-xlb

This means, you have to configure your Ingress entity to use a TLS secret:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: my-ingress-2
spec:
  tls:
  - secretName: secret-name
  rules:
  - http:
      paths:
      - path: /*
        backend:
          serviceName: service-name
          servicePort: 60000

You require a valid Certificate that is stored in a K8s TLS Secret. To attain such a Certificate - and not only a self signed Cert that makes clients bring up additional prompts - you do require a valid Domain name.

For a full walk-through, please refer to this article.

-- Fritz Duchardt
Source: StackOverflow