How to I can setup Contour routes in Kubernetes?

4/1/2020

I have service in Kubernetes on port 8804 (Java application in container), it response on URL ends with /dashboards I'm publish this service with Contour HTTPProxy:

---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: demo-dashboards-route
  namespace: demo-dashboards
spec:
  virtualhost:
    fqdn: demos.cuba-labs.com
  routes:
  - services:
    - name: demo-dashboards-app
      port: 8804
    loadBalancerPolicy:
      strategy: Cookie

My application work well with URL http://demos.cuba-labs.com/dashboards:

enter image description here

The next step I want to do is automatically redirect from the URL http://demos.cuba-labs.com to http://demos.cuba-labs.com/dashboards I do this:

 ---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
  name: demo-dashboards-route
  namespace: demo-dashboards
spec:
  virtualhost:
    fqdn: demos.cuba-labs.com
  routes:
  - services:
    - name: demo-dashboards-app
      port: 8804
    loadBalancerPolicy:
      strategy: Cookie
    pathRewritePolicy:
      replacePrefix:
      - prefix: /
        replacement: /dashboards

I go to root URL - http://demos.cuba-labs.com I see the following situation:

enter image description here

URL is being doubled: /dashboardsdashboards

What am I doing wrong?

-- Alexey Nakhimov
contour
kubernetes
kubernetes-ingress
kubernetes-networking

0 Answers