Kubernetes question:
So far I've created two pods, mongo & Go
Exposed those pods using services

Their IP is 10.x.x.x and accessible from my machine only (virtual lan I'm guessing only known to host), but my machine's network ip is 192.x.x.x therefore, not accessible from outside world and to do so I need to put nginx in front to receive requests and route them internally.

Is there a way in kubernetes to make it work like nginx in terms of:

Kubernetes listen to port 80 (for example) route based on received url. As you know in enginx we define a server block with server domain_name.tld

Anything similar in kubernetes? I've cheked ingress-nginx controller, and also saw LoadBalancer but that requires a cloud provider.

If anyone can also give an example it would be great, so far examples I checked ended up screwing my setup and had to reset kubectl to get things back working

  • 1
    Never mind me, it worked, basically it was listening to which means no response to requests from outside, once I set it to it worked
  • 1
    I am huge fan of openresty since I watched the presentation how cloudflare use it internally for their services that power lots of traffic.

    There is some simple openresty ingres controller on github but never had a chance to use it.

    openresty is nginx on steroids ( lua scripting engine built in )
  • 3
    Nginx ingress controller with NodePort ?
  • 1
    Yep, is "all", is loopback.
  • 1
    For testing you can continue to use your setup. Pretty sure you are using microk8s, or similar.

    For production, look at ngnix ingress controller + ssl cert.
  • 2
    @magicMirror Ya I'm using microk8s with nginx ingress controller, I'm now looking at using letsencrypt with it, found a good tutorial on Digital Ocean, anything else you recommend?

    @netikras Yup

    @vane never heard of openresty, will give it a try for sure :D
  • 1
    @gitpush simplest example is dynamic service creation and routing using redis ex. you create microservice on specific host and port and you want to expose it using particular domain name you can on creation write to redis dns name as a key and host port as a value and when someone asks for page in browser openresty will check in redis for key and get reqest from service.

    It’s like 20 lines lua script and one openresty server in front cool stuff.

  • 1
    @vane But I first need to learn Lua, how hard is it?
  • 1
    @gitpush It’s simple language very easy to write something in it if you wrote anything in python or javascript before.
    There are plenty of openresty github repos woth lua scripts so probably you need to glue code to make what you want.
  • 1
    @vane cool I'll get started with it, let's hope I get it right. took me two weeks banging my head against the wall to get micro8ks working lol
  • 1
    @gitpush lua is straightforward took me something like 4 hours to install openresty, redis and learn how to include lua script in it with what I want.

    You just have generic nginx config and then you manipulate request and response using lua.

    Much more easier then kubernetes. There is no magic behind it.

    Link I included in previous comments to openresty website is probably easiest way to start.
  • 1
    @vane So you are saying I ditch kubernetes?

    I usually go with nginx routing to docker, I'm learning kubernetes to see what it has to offer for small solutions or at least if I had to work GCloud or AWS I can know how to start.

    For now I rent servers and install everything from scratch.

    Anyhow; my main point is: what you are recommending is an alternative to nginx or I understood it wrong?
  • 1
    @gitpush yeah probably you have many nginx configurations with ex. proxy or static websites etc and you can make generic configuration and use key value store to read some dynamic data on every request.

    For deployments I would start from ansible.

    As for cloud kubernetes is for cloud agnostic deployments I think cause probably AWS provided all features of kubernetes before it was a thing.

    So depends what you want to touch, what way you want to go and how deep is your pocket there are plenty of solutions right now :)

    Maybe read how to optimize costs and/or time and chose right thing for you before doing anything.

    My personal opinion is that kubernetes is just way to connect bunch of machines together for heavy workloads and scale them dynamically as services using swagger. It’s nothing special if you already use ex. AWS elastic beanstalk.
  • 1
    @vane Totally agree about kubernetes but where I work they use it, and I just want to get a clue about it, after all I'm a developer not DevOps/IT/whoever needs to deal with it

    Just out of curiosity tbh
  • 1
    @gitpush cool I found something like this some time ago


    this guy goes hard way to install everything from scratch one by one on gcp.

    I didn’t find any setup tutorial from sources.
  • 1
    @vane I prefer to stick with microk8s lol and let devops handle the headache of installing it the hard way XD Thanks tho :D
  • 1
    @gitpush There is also free edx course “introduction to kubernetes” and website katacoda.com with free labs so you can learn everything that developer needs to know.
  • 0
    @vane Interesting, thank you so much, much appreciated :D
Add Comment