Version: v1.3

Gateway for Public Access

The gateway trait exposes a component to public Internet via a valid domain.

Attach a gateway trait to the component you want to expose and deploy.

  1. # vela-app.yaml
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: first-vela-app
  6. spec:
  7. components:
  8. - name: express-server
  9. type: webservice
  10. properties:
  11. image: oamdev/hello-world
  12. port: 8000
  13. traits:
  14. - type: gateway
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. "/": 8000
  1. vela up -f https://raw.githubusercontent.com/kubevela/kubevela/master/docs/examples/vela-app.yaml
  1. application.core.oam.dev/first-vela-app created

Check the status until we see status is running:

  1. vela status first-vela-app
  1. About:
  2. Name: first-vela-app
  3. Namespace: default
  4. Created at: 2022-01-11 22:04:29 +0800 CST
  5. Status: running
  6. Workflow:
  7. mode: DAG
  8. finished: true
  9. Suspend: false
  10. Terminated: false
  11. Steps
  12. - id:gfgwqp6pqh
  13. name:express-server
  14. type:apply-component
  15. phase:succeeded
  16. message:
  17. Services:
  18. - Name: express-server Env:
  19. Type: webservice
  20. healthy Ready:1/1
  21. Traits:
  22. - gateway: Visiting URL: testsvc.example.com, IP: 1.5.1.1

You can also get the endpoint by:

  1. vela status first-vela-app --endpoint
  1. |--------------------------------|----------------------------+
  2. | REF(KIND/NAMESPACE/NAME) | ENDPOINT |
  3. |--------------------------------|----------------------------+
  4. | Ingress/default/express-server | http://testsvc.example.com |
  5. |--------------------------------|----------------------------+

Then you will be able to visit this application via its domain.

  1. curl -H "Host:testsvc.example.com" http://<your ip address>/
  1. <xmp>
  2. Hello World
  3. ## .
  4. ## ## ## ==
  5. ## ## ## ## ## ===
  6. /""""""""""""""""\___/ ===
  7. ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ / ===- ~~~
  8. \______ o _,/
  9. \ \ _,'
  10. `'--.._\..--''
  11. </xmp>

⚠️ This section requires your runtime cluster has a working ingress controller.

Last updated on Nov 1, 2022 by Tianxin Dong