-1

Requirement: To set up a Kubernetes service that is publicly accessible on the browser on HTTPS

I browsed through the internet and everywhere I saw nginx-ingress which can give HTTPS URL.

I have an ingress setup and its working as expected But my doubt is, this ingress will only run on my local, as I make the changes in /etc/hosts file of local? How can I make https url publicly accessible? I want my load balancer service to be accessed publicly with HTTPS. I have my application running on GKE Cluster. Please guide

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
  • Please update your question to add more details on how you have setup the `ingress controller`. If you have already setup the ingress controller you should be able to access your application using the Load Balancer (provided you have setup the `Ingress` resource properly) – Sibtain Feb 17 '23 at 19:44
  • You should create a new DNS A record of your service externalIP pointing to the newly created Ingress domain name. This process can also be automated using externalDNS.. – Elazar Feb 17 '23 at 20:11
  • any, update on this ? feel free to update the status of the question if the below answer resolves your issues or do upvote if found it helpful. – Harsh Manvar Mar 03 '23 at 07:29

1 Answers1

1

I have an ingress setup and its working as expected But my doubt is

Guessing you are GKE with running the Nginx ingress controller, and with that you have the IP address exposed publicly. You might be adding domain records to /etcs/hosts and mapping to IP of Loadbalancer from GCP.

You have to use the DNS to map the load balancer IP with your Hostname. Add A record into the DNS server and map to the domain.

example.com 192.168.xx.xx

You read more here about the HTTPS cert creation : https://kubernetes.github.io/ingress-nginx/user-guide/tls/

You ingress will look like

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  tls:
  - hosts:
    - example.com
    secretName: letsencrypt-staging
  rules:
    - host: example.com
      http:
        paths:
          - path: /api/users/?(.*)
            pathType: Prefix
            backend:
              service:
                name: auth-srv
                port:
                  number: 3000

Read my article if planning to use the cert-manager : https://medium.com/@harsh.manvar111/kubernetes-nginx-ingress-and-cert-manager-ssl-setup-c82313703d0d (article have old API version ingress use above one for ref)

The above one provides the self-signed cert when you will open it in the browser it will throw an error, so would recommend downloading and creating the cert using Cert-manager or Free SSL site.

If you are using the cert-manager it will create the K8s secret in GKE and you have to use this secret with ingress. If downloading from site you have to manually create the K8s secret.

GCP Official ref doc : https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-multi-ssl#secrets

it has all methods mentioned including secret, user-managed, Google managed cert with ingress.

If you are using the Google Cloud Managed cert you can also leverage those and attach to Load Balancer so you will be able to use the HTTPS.

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102