I have a service in Kubernetes which I have to expose on multiple ports over HTTP.
I use Nginx-Ingress and was able to expose my service over Port 80 successfully.(http://serviceA.example.com --> service-a:80
)
However I am not able to use a diffrent port for Http then Port 80. How can I tell nginx-ingress to listen on Port 7049 aswell.
I've already tried to expose Port 7049 on the nginx Service and added the annotation nginx.org/listen-ports: "80,7049"
to the nginx controller. Neither worked for me.
I expect the following output:
http://serviceA.example.com --> service-a:80
http://serviceA.example.com:7049 --> service-a:7049
ingress-service.yml
apiVersion: v1
kind: Service
metadata:
name: nginx-ingress
namespace: nginx-ingress
spec:
externalTrafficPolicy: Local
type: LoadBalancer
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
selector:
app: nginx-ingress
my-service.yml
apiVersion: v1
kind: Service
metadata:
name: my-service
labels:
app: my-service
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
- port: 443
targetPort: 443
protocol: TCP
name: https
- port: 7049
targetPort: 7049
name: symbols
selector:
app: my-service
my-service-ingress.yml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: my-service
spec:
rules:
- host: myservice.example.com
http:
paths:
- path: /
backend:
serviceName: my-service
servicePort: 80