Setting up Ingress for addtional Port and endpoint

5/13/2019

i set up a testservice in Kubernetes in my default namespace. Following this Kubernetes Tutorial

NAMESPACE     NAME                            TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
default       example-service                 NodePort       10.102.218.101   <none>        8080:30242/TCP               3h38m

A Curl to curl http://my.server.com:30242 returns the correct output ==> Hello Kubernetes! Now i want to setup an ingress which makes the application available on a different endpoint and without using the 30242 port. So i set up an ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: 5ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - host: my.server.com
    http:
      paths:
        - path: /testing
          backend:
            serviceName: example-service
            servicePort: 80

The Ingress is deployed but the new path is not working. kubectl get ingress --all-namespaces

kube-system   5ingress            my.server.com             80, 443   16m

A Curl to curl curl http://my.server.com/testing returns

<html>
<head><title>308 Permanent Redirect</title></head>
<body>
<center><h1>308 Permanent Redirect</h1></center>
<hr><center>nginx/1.15.10</center>
</body>
</html

>

My expected output would be that curl http://my.server.com/testing returns Hello Kubernetes! What do i miss and how can i solve it ?

-- Mchoeti
kubernetes
kubernetes-ingress
nginx-ingress

2 Answers

5/13/2019

If you use Nginx Ingress then you must add this annotations:

nginx.ingress.kubernetes.io/ssl-redirect: "false"
-- Vasily Angapov
Source: StackOverflow

5/14/2019

The first step will be correcting servicePort in your ingress spec.

Your example-service is exposed on port 8080 while servicePort in the ingress definition is 80 .

Would be also good to see your ingress controller description if there's any

-- A_Suh
Source: StackOverflow