A machine-readable index of this documentation for AI agents is available at https://kubevela.io/llms.txt. Markdown versions of documentation pages are available by appending .md to their URLs.
Skip to main content
Version: v1.10

Traefik

Traefik is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. you can use this addon as a cluster gateway or a microservices gateway.

Install​

caution

The addon installs Traefik's Helm chart from https://charts.kubevela.net/community, and that host no longer resolves. Until the catalog publishes a version of the addon that pulls the chart from elsewhere, vela addon enable traefik creates the addon's Application but the chart is never fetched, so Traefik doesn't start.

vela addon enable traefik

Visit Traefik dashboard by port-forward​

Port forward will work as a proxy to allow visiting Traefik dashboard by local port.

vela port-forward -n vela-system addon-traefik

expected output:

Forwarding from 127.0.0.1:9000 -> 9000
Forwarding from [::1]:9000 -> 9000

Forward successfully! Opening browser ...
Handling connection for 9000

You can visiting Traefik dashboard with address http://127.0.0.1:9000/dashboard/.

Setup with Specified Service Type​

If your cluster has cloud LoadBalancer available:

vela addon enable traefik serviceType=LoadBalancer

How to use​

  1. Configure a HTTP domain for a component.
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: example
namespace: default
spec:
components:
- name: express-server
type: webservice
properties:
image: oamdev/hello-world
ports:
- port: 8000
expose: true
traits:
- properties:
domains:
- example.domain.com
rules:
- path:
type: PathPrefix
value: /
port: 8000
type: http-route
  1. Configure a HTTPS domain for a component.

Create the Secret that holds the certificate with the addon's tls-certificate config template, passing the certificate and private key base64-encoded:

vela config create example -t tls-certificate -n default cert=<CERT_BASE64> key=<KEY_BASE64>

This writes the Secret default/example with the keys tls.crt and tls.key, which the trait's secrets names.

The example application configuration:

apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: example-https
namespace: default
spec:
components:
- name: express-server
type: webservice
properties:
image: oamdev/hello-world
ports:
- port: 8000
expose: true
traits:
- properties:
domains:
- example.domain.com
rules:
- path:
type: PathPrefix
value: /
port: 8000
secrets:
- name: example
type: https-route

Definitions​

http-route(trait)​

defines HTTP rules for mapping requests from a Gateway to Application.

Properties​

NameDescriptionTypeRequiredDefault
gatewayNameSpecify the gateway namestringfalsetraefik-gateway
listenerNameSpecify the listener name of the gatewaystringfalseweb
domainsSpecify some domains, the domain may be prefixed with a wildcard label (*.)[]stringtrue
rulesSpecify some HTTP matchers, filters and actions.[]rulestrue
rules​
NameDescriptionTypeRequiredDefault
pathAn HTTP request path matcher. If this field is not specified, a default prefix match on the "/" path is provided.pathfalse
headersConditions to select a HTTP route by matching HTTP request headers.[]headersfalse
serviceNameSpecify the service name of component, the default is component name.stringfalse
portSpecify the service port of component.inttrue
headers​
NameDescriptionTypeRequiredDefault
namestringtrue
typestringtrue
valuestringtrue
path​
NameDescriptionTypeRequiredDefault
typestringtruePathPrefix
valuestringtrue/

https-route(trait)​

defines HTTPS rules for mapping requests from a Gateway to Application.

Properties​

NameDescriptionTypeRequiredDefault
secretsSpecify the TLS secrets[]secretstrue
TLSPortThe gateway's HTTPS listener port.intfalse8443
domainsSpecify some domains, the domain may be prefixed with a wildcard label (*.)[]stringtrue
rulesSpecify some HTTP matchers, filters and actions.[]rulestrue
rules​
NameDescriptionTypeRequiredDefault
pathAn HTTP request path matcher. If this field is not specified, a default prefix match on the "/" path is provided.pathfalse
portSpecify the service port of component.inttrue
headersConditions to select a HTTP route by matching HTTP request headers.[]headersfalse
serviceNameSpecify the service name of component, the default is component name.stringfalse
headers​
NameDescriptionTypeRequiredDefault
namestringtrue
typestringtrue
valuestringtrue
path​
NameDescriptionTypeRequiredDefault
typestringtruePathPrefix
valuestringtrue/
secrets​
NameDescriptionTypeRequiredDefault
namestringtrue
namespacestringfalse

tcp-route(trait)​

defines TCP rules for mapping requests from a Gateway to Application.

Properties​

NameDescriptionTypeRequiredDefault
rulesSpecify the TCP matchers[]rulestrue
rules​
NameDescriptionTypeRequiredDefault
gatewayPortSpecify the gateway listener portinttrue
portSpecify the service port of component.inttrue
serviceNameSpecify the service name of component, the default is component name.stringfalse

tls-certificate (config template)​

Manages a TLS certificate as a Secret with the keys tls.crt and tls.key. Create one with vela config create <name> -t tls-certificate cert=<CERT_BASE64> key=<KEY_BASE64>.

Properties​

NameDescriptionTypeRequiredDefault
certThe certificate, base64-encoded.stringtrue
keyThe certificate's private key, base64-encoded.stringtrue