0

I am trying to expose one of my applications running on minikube to outer world. I have already used a Nodeport and I can access the application within the same hist machine using a web browser.

But I need to expose this application to one of my friends who is living somewhere far, so he can see it in his browser too.

This is how my deployment.yaml files look like, should I use an Ingress or how can I do this using an ingress ?

apiVersion: apps/v1
kind: Deployment
metadata:
        name: node-web-app
spec:
  replicas: 2
  selector:
    matchLabels:
            name: node-web-app
  template:
    metadata:
      labels:
        # you can specify any labels you want here
              name: node-web-app
    spec:
      containers:
      - name: node-web-app
        # image must be the same as you built before (name:tag)
        image: banuka/node-web-app
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        imagePullPolicy: Never
      terminationGracePeriodSeconds: 60

How can I expose this deployment which is running a nodejs server to outside world?

  • 1
    Does this answer your question? [Access localhost from the internet](https://stackoverflow.com/questions/5108483/access-localhost-from-the-internet) – Software Engineer Nov 30 '19 at 23:17
  • 1
    Hey, I've voted to close as a duplicate and linked to another question (which was closed). This isn't really a k8s issue, it's about accessing your computer from the internet: https://stackoverflow.com/questions/5108483/access-localhost-from-the-internet. – Software Engineer Nov 30 '19 at 23:18

2 Answers2

-1

You generally can’t. The networking is set up only for the host machine. You could probably use ngrok or something though?

coderanger
  • 52,400
  • 4
  • 52
  • 75
  • This is a commercial tool, not open-source, so this is basically advertising. I'm pretty sure I don't really like that. – Software Engineer Nov 30 '19 at 18:04
  • Ngrok? It used to be open source for sure, I guess in the last rewrite the made it a product? – coderanger Nov 30 '19 at 18:58
  • It says that v1 isn't maintained or even working, and is closed-source in v2. On the github page I just checked: https://github.com/inconshreveable/ngrok – Software Engineer Nov 30 '19 at 19:56
  • Looks like there's a few forks/clones but nothing directly comparable with a hosted server component. Such is the way of things I suppose. – coderanger Nov 30 '19 at 21:21
  • I think Rio from Rancher does something similar but from the cloud rather than your personal laptop. That's probably a lot more secure anyway. – Software Engineer Nov 30 '19 at 21:36
  • No? Rio is a PaaS framework. Ngrok is a service/tool for setting up a reverse tunnel for something on your localhost. FOSS or not, it's the standard tool for the space. – coderanger Nov 30 '19 at 22:53
  • 1
    Standard is a strong word :) I've been in the industry a long time and have always understand ssh-tunnelling to be the standard. – Software Engineer Nov 30 '19 at 23:13
  • https://stackoverflow.com/questions/5108483/access-localhost-from-the-internet – Software Engineer Nov 30 '19 at 23:18
-1

You can use ngrok. For example

ngrok http 8000

This will generate piblicly accessable url.

tefozi
  • 5,390
  • 5
  • 38
  • 52
  • This is a commercial tool, not open-source, so this is basically advertising. I'm pretty sure I don't really like that. – Software Engineer Nov 30 '19 at 18:04
  • This is free tool to certain extend and totally usable in such case. – tefozi Dec 23 '19 at 16:13
  • No, that's definitely a commercial tool, based on a freemium model with a very limited 'free' tier. The standard approach to this problem is to use ssh (to create an ssh-tunnel), a ubiquitous free tool in most operating systems. I'm always open to a learning experience though, so if you wouldn't mind expanding on that @tefozi I'd love to know how it's not commercial? https://ngrok.com/ – Software Engineer Dec 23 '19 at 17:23
  • if that is one time thing and for testing purposes, ngrok will do its job – tefozi Jan 08 '20 at 16:23
  • what does that have to do with advertising commercial tools on stack-overflow when there's a perfectly good free and open solution that is more common? – Software Engineer Jan 16 '20 at 11:58
  • That particular feature that is free. Nobody cares that this tool is commercial. I proposed solution that will definitely work. – tefozi Jan 25 '20 at 21:41