How to access kubernetes websites via https

10/17/2019

I built my own 1 host kubernetes cluster (1 host, 1 node, many namespaces, many pods and services) on a virtual machine, running on a always-on server.

The applications running on the cluster are working fine (basically, a NodeJS backend and HTML frontend). So far, I have a NodePort Service, which is exposing Port 30000:

NAME                      TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                  AGE
traefik-ingress-service   NodePort    10.109.211.16    <none>        443:30000/TCP            147d

So, now I can access the web interface by typing https://<server-alias>:30000 in my browser adress bar.

But I would like to access it without giving the port, by only typing https://<server-alias>. I know, this can be done with the kubectl port-forwarding command: kubectl -n kube-system port-forward --address 0.0.0.0 svc/traefik-ingress-service 443:443

This works. But it does not seem to be a very professional thing to do.

Port forwarding also seems to keep disconnecting from time to time. Sometimes, it throws an error and quits, but leaves the process open, which leaves the port open - have to kill the process manually.

So, is there a way to do that access-my-application stuff professionally? How do the cluster provider (AWS, GCP...) do that?

Thank you!

-- xola
access
cluster-computing
kubernetes
portforwarding

2 Answers

10/20/2019

Since the Type of your Traefik Ingress Service is NodePort, you get to access to the port provided which will have a value from 30000-32000.

You can also configure it to be of type LoadBalancer and interface with a cloud-based Load Balancer. Ref: https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/

Here's a very related question: Should I use NodePort in my Traefik deployment on Kubernetes?

-- mOchi
Source: StackOverflow

10/17/2019

Using Ingress Nginx you can access to you website with the name server:

  1. Step 1: Install Nginx ingress in you cluster you can flow this link

After the installation is completed you will have a new pod

NAME                                    READY   STATUS

nginx-ingress-xxxxx                     1/1     Running

And a new Service

NAME                             TYPE           CLUSTER-IP     EXTERNAL-IP
nginx-ingress                    LoadBalancer   10.109.x.y     a.b.c.d
  1. Step 2 : Create new deployment for you application but be sure that you are using the same name space for nginx ingress svc/pod and you application and you set the svc type to ClusterIP

  2. Step 3: Create Kubernetes Ingress Object

Now you have to create the ingress object

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
  namespace: **Same Name Space**
spec:
  rules:
  - host: your DNS  <server-alias>
    http:
      paths:
      - backend:
          serviceName: svc Name
          servicePort: svc Port

Now you can access to your website using the .

To create a DNS for free you can use freenom or you can use /etc/hosts update it with :

server-alias a.b.c.d
-- hajji_0081
Source: StackOverflow