kubevela.github.io/i18n/zh/docusaurus-plugin-content-docs/version-v1.1/developers/extensions/set-route.md

1.8 KiB

title
Setting Routes

The route section is used to configure the access to your app.

Prerequisite

Make sure route trait controller is installed in your cluster

Install route trait controller with helm

  1. Add helm chart repo for route trait

    helm repo add oam.catalog  http://oam.dev/catalog/
    
  2. Update the chart repo

    helm repo update
    
  3. Install route trait controller

    helm install --create-namespace -n vela-system routetrait oam.catalog/routetrait
    
    
    

Note: route is one of the extension capabilities installed from cap center, please install it if you can't find it in vela traits.

Setting route policy

Add routing config under express-server:

services:
  express-server:
    ...

    route:
      domain: example.com
      rules:
        - path: /testapp
          rewriteTarget: /

The full specification of route could show up by $ vela show route.

Apply again:

$ vela up

Check the status until we see route is ready:

$ vela status testapp
About:

  Name:      	testapp
  Namespace: 	default
  Created at:	2020-11-04 16:34:43.762730145 -0800 PST
  Updated at:	2020-11-11 16:21:37.761158941 -0800 PST

Services:

  - Name: express-server
    Type: webservice
    HEALTHY Ready: 1/1
    Last Deployment:
      Created at: 2020-11-11 16:21:37 -0800 PST
      Updated at: 2020-11-11T16:21:37-08:00
    Routes:
      - route: 	Visiting URL: http://example.com	IP: <ingress-IP-address>

In kind cluster setup, you can visit the service via localhost:

If not in kind cluster, replace 'localhost' with ingress address

$ curl -H "Host:example.com" http://localhost/testapp
Hello World