Getting kubernetes ingress endpoint

+1 vote

I am new to Kubernetes Ingress and am setting up 2 different services, each reachable with its own path.

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 in my configs ?

Sep 21, 2018 in Kubernetes by Hannah
• 14,040 points
341 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Whatever you've done so far is correct @Hannah.

You're missing one very important concept of ingress, Ingress controller

I see you've already created your pod deployment file, service file and the ingress file. 

You need to create an ingress controller, something like this:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-ingress-controller
spec:
replicas: 1
revisionHistoryLimit: 3
template:
metadata:
labels:
k8s-app: nginx-ingress-lb
spec:
containers:
- args:
- /nginx-ingress-controller
- "--default-backend-service=$(POD_NAMESPACE)/default-http-backend"
- "--default-ssl-certificate=$(POD_NAMESPACE)/tls-certificate"
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: "gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.5"
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
timeoutSeconds: 5
name: nginx-ingress-controller
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 443
name: https
protocol: TCP
volumeMounts:
- mountPath: /etc/nginx-ssl/dhparam
name: tls-dhparam-vol
terminationGracePeriodSeconds: 60
volumes:
- name: tls-dhparam-vol
secret:
secretName: tls-dhparam
---
apiVersion: v1
kind: Service
metadata:
name: nginx-ingress
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: http
- name: https
port: 443
targetPort: https
selector:
k8s-app: nginx-ingress-lb
answered Sep 21, 2018 by Kalgi
• 35,640 points

Related Questions In Kubernetes

0 votes
1 answer

Forcing ssl for Kubernetes Ingress on GKE

https://github.com/kubernetes/ingress-gce#frontend-https If you want to block http, you ...READ MORE

answered Sep 6, 2018 in Kubernetes by ajs3033
• 7,000 points
677 views
0 votes
1 answer

Filter source ip in kubernetes ingress in GCE

This feature currently works only with nginx. Example ...READ MORE

answered Sep 7, 2018 in Kubernetes by Kalgi
• 35,640 points
120 views
0 votes
2 answers

single point of entry for multiple services in kubernetes ingress

I tried having something similar too. Deployment apiVersion: extensions/v1beta1 kind: ...READ MORE

answered Sep 7, 2018 in Kubernetes by Hannah
• 14,040 points
42 views
0 votes
1 answer
0 votes
1 answer
0 votes
3 answers

Nginx reverse proxy URL getting rewritten

 take a look at  nginx.ingress.kubernetes.io/app-root and  nginx.ingress.kubernetes.io/rewrite-target annotations(https://kubernetes.github.io/.../nginx.../annotations/). I'm not sure ...READ MORE

answered Mar 6 in Kubernetes by Madhu
262 views
0 votes
1 answer

ingress port getting redirected in kubernetes

Try the following, it worked for me Changed ...READ MORE

answered Sep 10, 2018 in Kubernetes by Kalgi
• 35,640 points
25 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
• 6,900 points
387 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.