api

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package api — common.go

Shared utilities used across all Route Provider implementations.

TLS secret naming:

certSecretName and sanitizeHost are the shared convention between
the Route provider (DomainMapping.Spec.TLS.SecretName / Ingress.Spec.TLS)
and the Domain provider (cert-manager Certificate secretName).
Both sides must produce identical names — this file is the single source
of truth. Never duplicate these functions in a provider file.

Package api — ingress.go

IngressProvider is the Kubernetes Ingress implementation of the routes Provider interface.

IngressProvider materializes a Route as a networking.k8s.io/v1 Ingress resource, routing traffic from the declared host and path to the K8s Service identified by Route.ServiceRef via the nginx ingress controller.

Ingress class:

All BlanketOps Ingress resources use the "nginx" IngressClassName.
Kourier handles all Knative traffic — nginx is strictly for
RuntimeKubernetesContainer routes.

Service port convention:

BlanketOps K8s Services expose port 80 regardless of container port.
The Ingress backend always targets port 80. If a ServiceUnit declares a
non-standard service port in future, domain.Route.ServicePort carries it.

TLS:

When Route.TLSEnabled is true, Ingress.Spec.TLS is populated with the
shared blanketops-tls-{sanitized-host} secret name (see common.go).
The Domain provider provisions the Secret via cert-manager — no ordering
dependency between Route and Domain reconciliation is required; nginx
will serve without TLS until the Secret appears, then upgrade.

Disabled routes:

When Route.Enabled is false the Ingress is deleted. The Route CR is
retained; only the runtime resource is removed. A missing Ingress
(NotFound) is not treated as an error — the disabled state is satisfied.

See also:

  • pkg/route/api/provider.go — Provider interface
  • pkg/route/api/knative.go — Knative DomainMapping provider
  • pkg/route/api/common.go — certSecretName / sanitizeHost
  • pkg/domain/api/knative.go — provisions the TLS Secret
  • pkg/route/application/backend_selector.go — wires IngressProvider for RuntimeKubernetesContainer

This file owns KnativeProvider — the Knative implementation of the routes Provider interface.

KnativeProvider materializes a Route as a Knative DomainMapping (serving.knative.dev/v1beta1). The DomainMapping binds the declared host to the Knative Service identified by Route.ServiceRef, making the workload reachable at that FQDN via Kourier.

API version:

DomainMapping/v1alpha1 was deprecated in Knative v1.11.0. This provider
targets the stable v1beta1 API exclusively.

TLS:

When Route.TLSEnabled is true, the DomainMapping is created with
spec.tls.secretName pointing to the TLS Secret that the Domain provider
(pkg/domain/api/knative.go) provisions via cert-manager. The secret name
follows the blanketops-tls-{sanitized-host} convention defined in common.go
and shared between all providers. Knative serving will wait for the Secret
to exist — no ordering dependency between Route and Domain reconciliation
is required.

Disabled routes:

When Route.Enabled is false the DomainMapping is deleted. The Route CR is
retained; only the runtime resource is removed. A missing DomainMapping
(NotFound) is not treated as an error — the disabled state is satisfied.

See also:

  • pkg/route/api/provider.go — Provider interface
  • pkg/route/api/common.go — certSecretName / sanitizeHost
  • pkg/route/api/ingress.go — Kubernetes Ingress provider
  • pkg/domain/api/knative.go — provisions the TLS Secret this file references
  • pkg/route/application/backend_selector.go — wires KnativeProvider for RuntimeKnativeService

This file owns KourierProvider — the Knative implementation of the routes Provider interface.

KourierProvider materializes a Route as a Knative DomainMapping (serving.knative.dev/v1beta1). The DomainMapping binds the declared host to the Knative Service identified by Route.ServiceRef, making the workload reachable at that FQDN via Kourier.

API version:

DomainMapping/v1alpha1 was deprecated in Knative v1.11.0. This provider
targets the stable v1beta1 API exclusively.

TLS:

When Route.TLSEnabled is true, the DomainMapping is created with
spec.tls.secretName pointing to the TLS Secret that the Domain provider
(pkg/domain/api/knative.go) provisions via cert-manager. The secret name
follows the blanketops-tls-{sanitized-host} convention defined in common.go
and shared between all providers. Knative serving will wait for the Secret
to exist — no ordering dependency between Route and Domain reconciliation
is required.

Disabled routes:

When Route.Enabled is false the DomainMapping is deleted. The Route CR is
retained; only the runtime resource is removed. A missing DomainMapping
(NotFound) is not treated as an error — the disabled state is satisfied.

See also:

  • pkg/route/api/provider.go — Provider interface
  • pkg/route/api/common.go — certSecretName / sanitizeHost
  • pkg/route/api/ingress.go — Kubernetes Ingress provider
  • pkg/domain/api/knative.go — provisions the TLS Secret this file references
  • pkg/route/application/backend_selector.go — wires KourierProvider for RuntimeKnativeService

This file owns the Provider interface for the routes domain — the contract that all route backend implementations must satisfy.

A Provider is responsible for materializing or removing the runtime resource (DomainMapping, Ingress, HTTPRoute) that exposes a workload at the declared host and path. Ensure is idempotent — calling it multiple times for the same Route CR must produce the same result with no unintended side effects.

The concrete implementation for the Knative runtime lives in knative.go. Additional runtimes (Kubernetes Ingress, Gateway API HTTPRoute) are registered alongside it as new files in this package.

Provider is pure in the sense that it never writes to the Route CR status — that responsibility belongs to pkg/routes/application/status.go.

See also:

  • pkg/routes/api/knative.go — Knative DomainMapping implementation
  • pkg/routes/application/backend_selector.go — selects Provider by Runtime
  • pkg/routes/application/service.go — calls Provider.Ensure and handles result

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IngressProvider

type IngressProvider struct {
	// contains filtered or unexported fields
}

IngressProvider implements Provider for the Kubernetes Ingress runtime. Materializes Route as a networking.k8s.io/v1 Ingress resource.

func NewIngressProvider

func NewIngressProvider(c client.Client, log logr.Logger) *IngressProvider

NewIngressProvider constructs an IngressProvider with the given client and logger.

func (*IngressProvider) Ensure

Ensure creates or reconciles the Kubernetes Ingress for the given Route. When Route.Enabled is false the Ingress is removed instead.

func (*IngressProvider) Teardown

func (p *IngressProvider) Teardown(ctx context.Context, route domain.Route) error

Teardown deletes the Ingress for the route's host, if one exists.

type KnativeProvider

type KnativeProvider struct {
	// contains filtered or unexported fields
}

KnativeProvider implements Provider for the Knative serving runtime. Materializes Route as a serving.knative.dev/v1beta1 DomainMapping.

func NewKnativeProvider

func NewKnativeProvider(c client.Client, log logr.Logger) *KnativeProvider

NewKnativeProvider constructs a KnativeProvider with the given client and logger.

func (*KnativeProvider) Ensure

Ensure creates or reconciles the Knative DomainMapping for the given Route. When Route.Enabled is false the DomainMapping is removed instead.

func (*KnativeProvider) Teardown

func (p *KnativeProvider) Teardown(ctx context.Context, route domain.Route) error

Teardown deletes the DomainMapping for the route's host, if one exists.

type KourierProvider

type KourierProvider struct {
	// contains filtered or unexported fields
}

KourierProvider implements Provider for the Knative serving runtime. Materializes Route as a serving.knative.dev/v1beta1 DomainMapping.

func NewKourierProvider

func NewKourierProvider(c client.Client, log logr.Logger) *KourierProvider

NewKourierProvider constructs a KourierProvider with the given client and logger.

func (*KourierProvider) Ensure

Ensure creates or reconciles the Knative DomainMapping for the given Route. When Route.Enabled is false the DomainMapping is removed instead.

func (*KourierProvider) Teardown

func (p *KourierProvider) Teardown(ctx context.Context, route domain.Route) error

Teardown deletes the DomainMapping for the route's host, if one exists.

type Provider

type Provider interface {
	// Ensure creates or reconciles the runtime resource (DomainMapping, Ingress,
	// or HTTPRoute) for the given Route. Returns PhaseReady on success and
	// PhaseFailed on terminal failure. Non-terminal errors (e.g. transient API
	// failures) are returned as Go errors for the controller to requeue.
	Ensure(ctx context.Context, resolved *routeResolution.ResolvedRoute, route domain.Route) (domain.RouteResult, error)

	// Teardown deletes the runtime resource Ensure created for route.
	// Idempotent — a missing resource is not an error.
	Teardown(ctx context.Context, route domain.Route) error
}

Provider materializes and maintains the runtime resource for a Route CR. Implementations must be idempotent and must not mutate the Route CR directly.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL