Access Application

After deploying the application, the next station is publishing your service.

There are multiple ways to do this, for testing, such as Port Forward and Node Port. for production, such as LoadBalancer and via cluster gateway. This section focus on the production environment.

This way is only suitable for the cloud environment, such as Aliyun, AWS, and Azure.

For the webservice component, you only need to set the ExposeType to LoadBalancer, it means this component will generate a Kubernetes Service with LoadBalancer type. After deployment, you could get the service endpoints.

For Example:

  1. apiVersion: core.oam.dev/v1beta1
  2. kind: Application
  3. metadata:
  4. name: webservice-app
  5. spec:
  6. components:
  7. - name: frontend
  8. type: webservice
  9. properties:
  10. image: oamdev/testapp:v1
  11. cmd: ["node", "server.js"]
  12. ports:
  13. - port: 8080
  14. expose: true
  15. exposeType: LoadBalancer

For other components, similarly, only need to generate the Kubernetes Service with LoadBalancer type.

This way required installed the ingress controller in the cluster.

Users could bound the gateway trait for the component to generate the Ingress. for example:

  1. traits:
  2. - type: gateway
  3. properties:
  4. domain: testsvc.example.com
  5. http:
  6. "/": 8000
  7. "/manage": 8090

This means accessing the component service by domain testsvc.example.com, there are two rules, the request path begins with /manage will request the component 8090 port. others request path request the component 8000 port.

In VelaUX, you can click the Add Trait button and select the gateway trait type. refer to follow configuration:

gateway trait

This way required installed the traefik addon firstly.

  1. $ vela addon enable traefik

Get more info about this addon, refer to Traefik Addon

This addon provides three traits, including http-route, https-route and tcp-route.

For HTTP, you can click the Add Trait button and select the http-route trait type. refer to follow configuration:

http route trait

  1. traits:
  2. - type: http-route
  3. properties:
  4. domains:
  5. - testsvc.example.com
  6. rules:
  7. - port: 80
  8. gatewayName: traefik-gateway
  9. listenerName: web

There must be one route rule. The port is the same as the service port, the route condition supports the Header and Request Path.

For HTTPS, you must create the TLS certificate firstly. In VelaUX, open the Integrations page, there is a TLS Certificate type. Click the New button, You need to provide the certificate public and private keys and encoded the content by base64.

new tls

This will generate the secret and distribute to managed clusters with the application.

Then open the application configuration page and click the Add Trait button and select the https-route trait type. refer to follow configuration:

https route trait

  1. traits:
  2. - type: https-route
  3. properties:
  4. domains:
  5. - testsvc.example.com
  6. TLSPort: 8443
  7. secrets:
  8. - name: kubevela
  9. rules:
  10. - port: 80

The secret name is the same as the name of the certificate configuration.

This way is suitable for the service with the stream protocol, reusing the same public IP address.

You can click the Add Trait button and select the tcp-route trait type. refer to follow configuration:

tcp route trait

  1. traits:
  2. - type: https-route
  3. properties:
  4. rules:
  5. - gatewayPort: 16379
  6. port: 6379
  7. serviceName: redis-master

Last updated on Aug 4, 2023 by Daniel Higuero