Home > front end >  How can I proxy an external site through my Kubernetes(OpenShift) Ingress?
How can I proxy an external site through my Kubernetes(OpenShift) Ingress?

Time:09-29

I have a website that needs to be proxied through my web app.
Traditionally we've accomplished it via apache proxy with proxy directives.
The proxy also rewrites some of the headers and adds a couple of new ones.

Now the app has moved to OpenShift (Kubernetes) and I'm trying to avoid deploying another pod with apache.

Can I perform this header rewriting and proxying via K8 ingress? or router?

I've tried this approach, but it didn't work.

I also don't know how to get OpenShift Ingress logs, nothing seems to happen in there.

I tried using an external name, but it doesn't work:

kind: Service
metadata:
    name: es3
spec:
    externalName: google.com
    type: ExternalName
---
kind: Route
apiVersion: route.openshift.io/v1
spec:
  host: host.my-cluster-url.net
  to:
    kind: Service
    name: es3
  port:
    targetPort: es3

I also tried using Endpoints , same result

apiVersion: v1
kind: Service
metadata:
  name: mysvc
spec:
  ports:
  - name: app
    port: 80
    protocol: TCP
    targetPort: 80
  clusterIP: None
  type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
  name: mysvc
subsets:
- addresses:
  - ip:  my.ip.address
  ports:
  - name: app
    port: 80
    protocol: TCP

CodePudding user response:

you want to proxy non kubernetes service, right? if yes, use end point and create service from end point, I have used this with kubernetes will work with openshift too my wild guess

https://kubernetes.io/docs/concepts/services-networking/endpoint-slices/

  • Related