Skip to main content
Version: 1.50

Endpoints for HTTPRoutes

Okteto serves the Gateway API HTTPRoutes deployed in your Namespaces as HTTPS endpoints. Okteto attaches each HTTPRoute to the Gateway configured in your Okteto instance and generates a hostname for it, so you don't need to know anything about the underlying Gateway.

HTTPRoutes are available in Bring Your Own Cloud (BYOC). In Self-Hosted installations, HTTPRoutes work once your Okteto instance is configured for Gateway API, as described in Migrate to Gateway API.

Creating an HTTPRoute​

Create an HTTPRoute in any Namespace managed by Okteto. You don't need to set parentRefs, hostnames, or any annotation:

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: hello-world
spec:
rules:
- backendRefs:
- name: hello-world
port: 8080

Okteto adds the Gateway configured in your Okteto instance to spec.parentRefs and adds the hostname hello-world-<namespace>.<okteto-subdomain> to spec.hostnames. The endpoint shows up in the Okteto UI.

If your HTTPRoute already defines its own parentRefs or hostnames, Okteto keeps them and adds its own. Your Okteto instance can also be configured with the Helm value endpoints.dev.gatewayAPI.gateway.force to replace them with the configured Gateway and the hostname Okteto generates. To keep your own parentRefs and hostnames untouched, opt out.

The generated hostname must be 63 characters or fewer, not counting the Okteto subdomain. Okteto rejects HTTPRoutes whose generated hostname is longer.

Generated Hostnames​

Okteto generates a hostname for every HTTPRoute by default. Use the dev.okteto.com/generate-host annotation to change it:

ValueHostname
"true" or no annotation<route-name>-<namespace>.<okteto-subdomain>
A custom name, such as "api"api-<namespace>.<okteto-subdomain>
"domain"<namespace>.<okteto-subdomain>
"false"No hostname is generated. The HTTPRoute only serves the hostnames in spec.hostnames.

Opting Out of the Okteto Gateway​

To stop Okteto from attaching an HTTPRoute to its Gateway and generating its hostname, add the dev.okteto.com/gateway: "false" annotation:

metadata:
annotations:
dev.okteto.com/gateway: "false"

Supported Annotations​

AnnotationValuesBehavior
dev.okteto.com/gateway"false"Skips the attachment to the Okteto Gateway and the hostname generation.
dev.okteto.com/generate-host"true" (default), "false", "domain", or a custom nameControls the generated hostname, as described in Generated Hostnames.
dev.okteto.com/endpointsComma-separated URLsReplaces the endpoints shown in the Okteto UI. Supports the ${OKTETO_NAMESPACE} and ${OKTETO_DOMAIN} variables. See Custom Endpoints.
dev.okteto.com/hide-from-ui"true"Hides the endpoints of the HTTPRoute from the Okteto UI.
dev.okteto.com/private"true"Makes the endpoints of the HTTPRoute private. Available in BYOC. Private Endpoints are deprecated in Self-Hosted.

Backends in Other Namespaces​

Okteto doesn't validate the backendRefs of your HTTPRoutes. If an HTTPRoute references a Service in a different namespace, create a ReferenceGrant in the namespace of that Service.

Gateway Variables​

When you reference the Okteto Gateway in your own manifests, use these variables. The Okteto CLI injects them in the deploy, destroy, and test commands of your Okteto Manifest:

  • OKTETO_DEV_GATEWAY_NAME: the name of the Okteto Gateway.
  • OKTETO_DEV_GATEWAY_NAMESPACE: the namespace of the Okteto Gateway.

Most HTTPRoutes don't need them, because Okteto attaches HTTPRoutes to its Gateway automatically.