I want to make an endpoint running at http://12.34.56.78:1234
accessible via https://www.example.com/suffix
, whereas the latter endpoint is configured and exposed via Kubernetes and the former endpoint is standalone.
It is not possible to make changes to http://12.34.56.78:1234
or https://www.example.com/suffix
, the former is directly accessible over the internet and the latter must be exposed via Kubernetes. The only thing which may be changed is the Kubernetes configuration.
Therefore, I created the following ingress:
kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
name: ingress-controller
namespace: ns
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
tls:
- hosts:
- www.example.com
secretName: tls-secret
rules:
- host: www.example.com
http:
paths:
- path: /suffix
pathType: Prefix
backend:
serviceName: proxy
servicePort: 1234
and the following service:
kind: Service
apiVersion: v1
metadata:
name: proxy
namespace: ns
spec:
ports:
- protocol: TCP
port: 1234
targetPort: 1234
type: ExternalName
sessionAffinity: None
externalName: 12.34.56.78
According to https://discuss.kubernetes.io/t/service-externalname-ip/494, using Service
with type: ExternalName
and an IP as externalName seems to work fine in general.
I also experimented with Endpoint but couldn't get it work either:
apiVersion: v1
kind: Endpoints
metadata:
name: proxy
namespace: ns
subsets:
- addresses:
- ip: 12.34.56.78
ports:
- name: proxy
port: 1234
When calling https://www.example.com/suffix
, I am getting 403 Client Error: Forbidden for url: https://www.example.com/suffix
Any ideas how to get it to work?