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
• 18,570 points
2,487 views

1 answer to this question.

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
• 52,360 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,300 points
3,973 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
• 52,360 points
1,101 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
• 18,570 points
2,337 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,167 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,228 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
• 52,360 points
621 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,531 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