Version: v1.1

配置网关

开始之前

⚠️ 需要你的集群已安装 Ingress 控制器

字段说明

  1. vela show ingress
  1. # Properties
  2. +--------+------------------------------------------------------------------------------+----------------+----------+---------+
  3. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  4. +--------+------------------------------------------------------------------------------+----------------+----------+---------+
  5. | http | Specify the mapping relationship between the http path and the workload port | map[string]int | true | |
  6. | domain | Specify the domain you want to expose | string | true | |
  7. +--------+------------------------------------------------------------------------------+----------------+----------+---------+

如何使用

  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: crccheck/hello-world
  12. port: 8000
  13. traits:
  14. - type: ingress
  15. properties:
  16. domain: testsvc.example.com
  17. http:
  18. "/": 8000

部署到集群后,检查应用状态为 running,并且状态是 healthy:

  1. kubectl get application first-vela-app -w
  1. NAME COMPONENT TYPE PHASE HEALTHY STATUS AGE
  2. first-vela-app express-server webservice healthChecking 14s
  3. first-vela-app express-server webservice running true 42s

如果你的集群带有云厂商的负载均衡机制可以通过 Application 查看到访问的 IP:

  1. kubectl get application first-vela-app -o yaml
  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: first-vela-app
  5. namespace: default
  6. spec:
  7. ...
  8. services:
  9. - healthy: true
  10. name: express-server
  11. traits:
  12. - healthy: true
  13. message: 'Visiting URL: testsvc.example.com, IP: 47.111.233.220'
  14. type: ingress
  15. status: running
  16. ...

然后就能够通过这个 IP,来访问该应用程序了。

  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>