HttpRoute

HTTPRoute defines the route to the service in cluster.

For example, the default configuration for Kalm dashboard would look as follows:

apiVersion: core.kalm.dev/v1alpha1
kind: HttpRoute
metadata:
name: kalm-route
spec:
hosts:
- hello-world.kalm.dev
destinations:
- host: kalm.kalm-system.svc.cluster.local:80
weight: 1
paths:
- /
httpRedirectToHttps: true
schemes:
- https
- http
methods:
- GET
- HEAD
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
- TRACE
- CONNECT

The configuration defines that the traffic to domain: hello-world.kalm.dev will be directed to the in-cluster service: kalm.kalm-system.svc.cluster.local:80. It accepts both HTTP and HTTPS requests, but will auto redirect HTTP to HTTPS.

HttpRoute

FieldTypeDescriptionRequired
hosts[]stringThe destination hosts to which traffic is being sent. Could be a DNS name with wildcard prefix or an IP address.True
paths[]stringURI paths for prefix-based matchTrue
methodsHttpRouteMethod[]HTTP MethodT
schemesHttpRouteScheme[]URI Scheme valuesT
stripPathboolstrip path for URL matchF
conditionsHttpRouteCondition[]conditions for route matchF
destinationsHttpRouteDestination[]targets of upstream servicesT
httpRedirectToHttpsboolredirect HTTP to HTTPSF
timeout*intTimeout for HTTP requests, default is disabled.F
retries*HttpRouteRetriesRetry policy for HTTP requests.F
mirror*HttpRouteMirrorMirror HTTP traffic to a another destination in addition to forwarding the requests to the intended destination.F
fault*HttpRouteFaultFault injection policy to apply on HTTP traffic at the client side.F
delay*HttpRouteDelayDelay requests before forwarding, emulating various failures such as network issues, overloaded upstream service, etc.F
cors*HttpRouteCORSCross-Origin Resource Sharing policy (CORS).F

HttpRouteMethod

Name
GET
HEAD
POST
PUT
PATCH
DELETE
OPTIONS
TRACE
CONNECT

HttpRouteScheme

NameDescription
http
https

HttpRouteCondition

FieldTypeDescriptionRequired
TypeHttpRouteConditionTypecan be query or headerT
NamestringT
ValuestringF
OperatorHttpRouteConditionOperatorcan be equal, withPrefix or matchRegexpT

HttpRouteConditionType

NameDescription
queryQuery parameters in URL for matching.
headerheader in HTTP request for matching.

HttpRouteConditionOperator

NameDescription
equalsame value
withPrefixcondition value is prefix
matchRegexpcondition value should be interpret as regex expression

HttpRouteDestination

FieldTypeDescriptionRequired
hoststringdestination hostT
weightintThe proportion of traffic to be forwarded to the destinationF

HttpRouteRetries

FieldTypeDescriptionRequired
AttemptsintNumber of retries for a given request.F
PerTtyTimeoutSecondsintTimeout per retry attempt for a given request, in seconds. MUST BE >= 1.T
RetryOn[]stringthe conditions under which retry takes place.F

HttpRouteMirror

FieldTypeDescriptionRequired
percentageintPercentage of the traffic to be mirrored.F
destinationHttpRouteDestinationMirror HTTP traffic to this destinationT

HttpRouteFault

FieldTypeDescriptionRequired
PercentageintPercentage of requests to be aborted with the error code provided.F
ErrorStatusintHTTP status code to use to abort the Http request.F

HttpRouteDelay

FieldTypeDescriptionRequired
PercentageintPercentage of requests on which the delay will be injected.F
DelaySecondsintAdd a fixed delay before forwarding the request, in seconds, MUST be >= 1T

HttpRouteCORS

FieldTypeDescriptionRequired
AllowOriginsHttpRouteCondition[]String patterns that match allowed origins. An origin is allowed if any of the string matchers match. If a match is found, then the outgoing Access-Control-Allow-Origin would be set to the origin as provided by the client.F
AllowMethodsAllowMethod[]List of HTTP methods allowed to access the resource.F
AllowCredentialsboolIndicates whether the caller is allowed to send the actual request (not the preflight) using credentials.F
AllowHeadersstring[]List of HTTP headers that can be used when requesting the resource. Serialized to Access-Control-Allow-Headers header.F
MaxAgeSecondsintSpecifies how long the results of a preflight request can be cached. Translates to the Access-Control-Max-Age header.F

AllowMethod

Name
GET
HEAD
POST
PUT
PATCH
DELETE
OPTIONS
TRACE
CONNECT
Last updated on by Liu Mingmin