Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to enable https tls on kubernetes GCE

I successfully deployed my web app on kubernetes in Google cloud. It is serving via http. I followed all guides on how to add ssl certificate and it was added according to Google cloud console however, it only work as http , when you try to access the web app as HTTPS. the browser says "This site can’t be reached"

my ingress YAML looks like this

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: no-rules-map
spec:
  tls:
  - secretName: testsecret
  backend:
    serviceName: s1
    servicePort: 80

for Secret

apiVersion: v1
data:
  tls.crt: [crt]
  tls.key: [key]
kind: Secret
metadata:
  name: testsecret
  namespace: default
type: Opaque
like image 941
Mujtaba Alboori Avatar asked Jul 25 '26 03:07

Mujtaba Alboori


1 Answers

I used this command to upload my ssl certificate

kubectl create secret tls tls-secret --key=/tmp/tls.key --cert=/tmp/tls.crt

instead of yaml file Secret below and it works better. At least for Google Cloud

apiVersion: v1
data:
  tls.crt: [crt]
  tls.key: [key]
kind: Secret
metadata:
  name: testsecret
  namespace: default
type: Opaque

Make sure when you go to Kubernates Engine -> Configuration in Google Cloud Console that your secret type is Secret: kubernetes.io/tls and not only Secret. when you create your secret using yaml it is created as secret only and not Secret: kubernetes.io/tls.

For more information you can take a look at these following links: https://github.com/kubernetes/ingress-gce#backend-https

enter link description here

https://cloud.google.com/kubernetes-engine/docs/tutorials/http-balancer#remarks

like image 154
Mujtaba Alboori Avatar answered Jul 28 '26 06:07

Mujtaba Alboori