Unable to access pods using nodeIP

0 votes

I'm new to kubernetes

I have created 2 deployments :

kubectl run nginx --image=nginx --port=80
kubectl run echoserver --image=gcr.io/google_containers/echoserver:1.4 --port=8080

I have also created their corresponding services :

kubectl expose deployment nginx --target-port=80 --type=NodePort
kubectl expose deployment echoserver --target-port=8080 --type=NodePort

My svc are :

[root@node1 kubernetes]# kubectl get svc
NAME         TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
echoserver   NodePort   10.233.48.121   <none>        8080:31250/TCP   47m
nginx        NodePort   10.233.44.54    <none>        80:32018/TCP     1h

My NodeIP address is 172.16.16.2 and I can access both pods using

http://172.16.16.2:31250 &
http://172.16.16.2:32018

Now on top of this I want to deploy an Ingress so that I can reach both pods not using 2 IPs and 2 different ports BUT 1 IP address with different paths.

So my Ingress file is :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: fanout-nginx-ingress
spec:
  rules:
  - http:
      paths:
      - path: /nginx
        backend:
          serviceName: nginx
          servicePort: 80
      - path: /echo
        backend:
          serviceName: echoserver
          servicePort: 8080

This yields :

[root@node1 kubernetes]# kubectl describe  ing fanout-nginx-ingress
Name:             fanout-nginx-ingress
Namespace:        development
Address:          
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /nginx   nginx:80 (<none>)
        /echo    echoserver:8080 (<none>)
Annotations:
Events:  <none>

Now when I try accessing the Pods using the NodeIP address (172.16.16.2), I get nothing.

http://172.16.16.2/echo
http://172.16.16.2/nginx

Is there something I have missed?

Sep 7, 2018 in Kubernetes by lina
• 8,220 points
869 views

1 answer to this question.

0 votes

Your kubernetes cluster is missing the ingress controller. Set up an ingress controller. You can use either GCE or nginx for this.

The ingress controller consists of several components that you create during installation. Here is installation part from Nginx Ingress documentation:

curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/namespace.yaml              | kubectl apply -f -
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/default-backend.yaml        | kubectl apply -f -
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/configmap.yaml              | kubectl apply -f -
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/tcp-services-configmap.yaml | kubectl apply -f -
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/udp-services-configmap.yaml | kubectl apply -f -

If you have RBAC authorization configured in your cluster:

curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/rbac.yaml      | kubectl apply -f -
curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/with-rbac.yaml | kubectl apply -f -

If no RBAC configured:

curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/without-rbac.yaml | kubectl apply -f -

In case you create cluster from scratch:

curl https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml | kubectl apply -f -

Verify your installation:

kubectl get pods --all-namespaces -l app=ingress-nginx --watch

You should see something like:

NAMESPACE       NAME                                       READY     STATUS    RESTARTS   AGE
ingress-nginx   nginx-ingress-controller-699cdf846-nj2rw   1/1       Running   0          1h

Check available services and their parameters:

kubectl get services --all-namespaces
answered Sep 7, 2018 by Kalgi
• 52,360 points

Related Questions In Kubernetes

0 votes
1 answer

Is it possible to access GCP resources using api without a user interaction.?

yes that's totally possible. You'd have to create ...READ MORE

answered Sep 19, 2018 in Kubernetes by Kalgi
• 52,360 points
421 views
0 votes
1 answer

unable to start Kubernetes due to so many open files in system

You can try the following steps: You can ...READ MORE

answered May 1, 2018 in Kubernetes by shubham
• 7,340 points
1,808 views
0 votes
1 answer

Is possible to have same k8s service for multiple pods?

Reserve a static IP and then assign ...READ MORE

answered Jul 20, 2018 in Kubernetes by Kalgi
• 52,360 points
2,785 views
0 votes
1 answer

deleting pods using kubernetes replication controller

The pods which are managed by ReplicationController ...READ MORE

answered Jul 24, 2018 in Kubernetes by DareDev
• 6,890 points
863 views
+1 vote
1 answer
0 votes
1 answer

Nginx routing for kubernetes services

Hey, backend is a service running on ...READ MORE

answered Feb 8, 2019 in Kubernetes by Kalgi
• 52,360 points
1,112 views
0 votes
3 answers

Nginx reverse proxy URL getting rewritten

Hey @Gopi, try your ingress probably like ...READ MORE

answered Feb 12, 2019 in Kubernetes by Kalgi
• 52,360 points
4,189 views
+1 vote
1 answer

Unable to access kubernetes dashboard

You’re trying to access a private IP. ...READ MORE

answered Aug 27, 2018 in Kubernetes by Kalgi
• 52,360 points
2,583 views
0 votes
2 answers

Deny access to some specific paths while using kubernetes ingress

Try to create two Ingresses first by default ...READ MORE

answered Sep 21, 2018 in Kubernetes by Nilesh
• 7,050 points
11,477 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP