How to forward TCP traffic to pod from the outside world

Nikola Radovanovic 31 Reputation points
2021-04-02T16:33:23.887+00:00

Hi,
First of all, I am new to Kubernetes and for past couple of days I am struggling with something I would expect to be a simple task.

I want to forward TCP on specific port(s) to a running pod. As a reference I take a look here. With minikube locally, it works as expected (apart wrong namespace in tutorial document: should be kube-system).

However, after 3 days of trying to achieve the same on AKS my frustration only get bigger and bigger and I am on the verge of hating Kubernetes before I even starting to use it. Can someone please explain me in plain English how to expose TCP ports using Nginx ingress to outside world.

What I try so far is basically as follows:

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/cloud/deploy.yaml
kubectl apply -f redis-deployment.yaml
kubectl apply -f redis-service.yaml
kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"6379":"default/redis-service:6379"}}'
kubectl -n ingress-nginx patch service ingress-nginx-controller -p '{"spec": {"ports": [{"name":"http","port":80,"protocol":"TCP","targetPort":"http"},{"name":"https","port":443,"protocol":"TCP","targetPort":"https"},{"name":"redis","port":6379,"protocol":"TCP","targetPort": 6379}]}}'

But I can't access from the outside and I don't see 6379 port in ingress-nginx-controller listed. Looks I am missing something, but I cant see what.

I find Kubernetes extremely complicated so far. Docker & compose are much cleaner and their docs are way much better.

Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,127 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.