I do have a container that runs an image and exposes the application on a specific path and port (e.g. localhost:8080/app_A).
In K8s, I have set up a service like this:
apiVersion: v1
kind: Service
...
spec:
selector:
application: "{{{APPLICATION}}}"
component: "{{{COMPONENT}}}"
environment: "{{{ENVIRONMENT}}}"
type: ClusterIP
ports:
- protocol: TCP
targetPort: 8080
port: 80
name: http
And the ingress as following:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: "{{{COMPONENT}}}"
namespace: "{{{NAMESPACE}}}"
labels:
application: "{{{APPLICATION}}}"
component: "{{{COMPONENT}}}"
environment: "{{{ENVIRONMENT}}}"
spec:
rules:
- host: "{{{COMPONENT}}}.{{{TARGET_K8S}}}.company.domain"
http:
paths:
- backend:
serviceName: "{{{COMPONENT}}}"
servicePort: 80
path: /app_A
pathType: ImplementationSpecific
With the above setup, I can access the desired path via the following ingress endpoint:
{{{COMPONENT}}}.{{{TARGET_K8S}}}.company.domain/app_A
Is is possible to map the targetPath somehow in Service component so that it exposes the endpoint localhost:8080/app_A from the container directly? This way, I don't need to add app_A in the ingress endpoint when I want to access this application.