deployer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GatewayParametersError              = errors.New("could not retrieve GatewayParameters")
	GetGatewayParametersForGatewayError = func(err error, gwpNamespace, gwpName, gwNamespace, gwName, resourceType string) error {
		return fmt.Errorf("(%s.%s) for %s (%s.%s): %w",
			gwpNamespace, gwpName, resourceType, gwNamespace, gwName, fmt.Errorf("%s: %w", GatewayParametersError.Error(), err))
	}
	GetGatewayParametersForGatewayClassError = func(err error, gwpNamespace, gwpName, gwcName, resourceType string) error {
		return fmt.Errorf("(%s.%s) for %s (%s): %w",
			gwpNamespace, gwpName, resourceType, gwcName, fmt.Errorf("%s: %w", GatewayParametersError.Error(), err))
	}
	NilDeployerInputsErr = errors.New("nil inputs to NewDeployer")
)
View Source
var (
	// ErrMultipleAddresses is returned when multiple addresses are specified in Gateway.spec.addresses
	ErrMultipleAddresses = errors.New("multiple addresses given, only one address is supported")

	// ErrNoValidIPAddress is returned when no valid IP address is found in Gateway.spec.addresses
	ErrNoValidIPAddress = errors.New("IP address in Gateway.spec.addresses not valid")
)
View Source
var ComponentLogLevelEmptyError = func(key string, value string) error {
	return fmt.Errorf("an empty key or value was provided in componentLogLevels: key=%s, value=%s", key, value)
}
View Source
var ErrListenerPortOutOfRange = fmt.Errorf("port is out of range")
View Source
var ErrListenerPortReserved = fmt.Errorf("port is reserved")

Functions

func ConvertYAMLToObjects

func ConvertYAMLToObjects(scheme *runtime.Scheme, yamlData []byte) ([]client.Object, error)

func GenerateListenerNameFromPort

func GenerateListenerNameFromPort(port gwv1.PortNumber) string

func GetCommonExemptFeatures

func GetCommonExemptFeatures() sets.Set[features.Feature]

GetCommonExemptFeatures returns the set of features that are commonly unsupported across all gateway classes. Exported for use in the conformance test suite.

func GetLoadBalancerIPFromGatewayAddresses

func GetLoadBalancerIPFromGatewayAddresses(gw *gwv1.Gateway) (*string, error)

GetLoadBalancerIPFromGatewayAddresses extracts the IP address from Gateway.spec.addresses. Returns the IP address if exactly one valid IP address is found, nil if no addresses are specified, or an error if more than one address is specified or no valid IP address is found.

func GetSupportedFeaturesForAgentGateway

func GetSupportedFeaturesForAgentGateway() []gwv1.SupportedFeature

GetSupportedFeaturesForAgentGateway returns the supported features for the agent Gateway class. Agent gateways support additional features beyond the standard gateway class.

func JsonConvert

func JsonConvert(in *HelmConfig, out any) error

func SanitizePortName

func SanitizePortName(name string) string

func SetLoadBalancerIPFromGatewayForAgentgateway

func SetLoadBalancerIPFromGatewayForAgentgateway(gw *gwv1.Gateway, svc *AgentgatewayHelmService) error

SetLoadBalancerIPFromGatewayForAgentgateway extracts the IP address from Gateway.spec.addresses and sets it on the AgentgatewayHelmService. Only sets the IP if exactly one valid IP address is found in Gateway.spec.addresses. Returns an error if more than one address is specified or no valid IP address is found. Note: Agentgateway services are always LoadBalancer type, so no service type check is needed.

Types

type AgentgatewayHelmGateway

type AgentgatewayHelmGateway struct {
	agentgateway.AgentgatewayParametersConfigs `json:",inline"`
	// SessionKeySecretName is the Secret name used by the dataplane mount.
	SessionKeySecretName *string `json:"sessionKeySecretName,omitempty"`
	// naming
	Name               *string           `json:"name,omitempty"`
	GatewayClassName   *string           `json:"gatewayClassName,omitempty"`
	GatewayAnnotations map[string]string `json:"gatewayAnnotations,omitempty"`
	GatewayLabels      map[string]string `json:"gatewayLabels,omitempty"`

	// deployment/service values
	Ports   []HelmPort               `json:"ports,omitempty"`
	Service *AgentgatewayHelmService `json:"service,omitempty"`

	// agentgateway xds values
	Xds *HelmXds `json:"xds,omitempty"`
}

type AgentgatewayHelmService

type AgentgatewayHelmService struct {
	LoadBalancerIP *string `json:"loadBalancerIP,omitempty"`
}

type ControlPlaneInfo

type ControlPlaneInfo struct {
	XdsHost      string
	AgwXdsPort   uint32
	XdsTLS       bool
	XdsTlsCaPath string
}

type Deployer

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

A Deployer is responsible for deploying proxies and inference extensions.

func NewDeployerWithMultipleCharts

func NewDeployerWithMultipleCharts(
	agwControllerName, agwGatewayClassName string,
	scheme *runtime.Scheme,
	client apiclient.Client,
	agentgatewayChart *chart.Chart,
	hvg HelmValuesGenerator,
	helmReleaseNameAndNamespaceGenerator func(obj client.Object) (string, string),
	opts ...Option,
) *Deployer

NewDeployerWithMultipleCharts creates a new gateway deployer that supports both envoy and agentgateway charts

func (*Deployer) DeployObjs

func (d *Deployer) DeployObjs(ctx context.Context, objs []client.Object) error

func (*Deployer) DeployObjsWithSource

func (d *Deployer) DeployObjsWithSource(ctx context.Context, objs []client.Object, sourceObj client.Object) error

func (*Deployer) GetGvksToWatch

func (d *Deployer) GetGvksToWatch(ctx context.Context, vals map[string]any) ([]schema.GroupVersionKind, error)

func (*Deployer) GetObjsToDeploy

func (d *Deployer) GetObjsToDeploy(ctx context.Context, obj client.Object) ([]client.Object, error)

GetObjsToDeploy does the following:

* uses HelmValuesGenerator to perform lookup/merging etc to get a final set of helm values

* use those helm values to render the helm chart the deployer was instantiated with into k8s objects

* sets ownerRefs on all generated objects

* returns the objects to be deployed by the caller

obj can currently be a pointer to a Gateway (https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1/gateway_types.go#L35) or

a pointer to an InferencePool (https://github.com/kubernetes-sigs/gateway-api-inference-extension/blob/main/api/v1alpha2/inferencepool_types.go#L30)

func (*Deployer) PruneRemovedResources

func (d *Deployer) PruneRemovedResources(ctx context.Context, owner client.Object, desiredObjs []client.Object) error

PruneRemovedResources deletes PDB/HPA/VPA resources that are owned by the owner but are no longer in the desired set of objects. This prevents stale autoscaling resources from persisting when configuration changes.

func (*Deployer) RenderChartToObjects

func (d *Deployer) RenderChartToObjects(ns, name string, vals map[string]any) ([]client.Object, error)

func (*Deployer) RenderManifest

func (d *Deployer) RenderManifest(ns, name string, vals map[string]any) ([]byte, error)

func (*Deployer) RenderToObjects

func (d *Deployer) RenderToObjects(ns, name string, vals map[string]any) ([]client.Object, error)

RenderToObjects relies on a `helm install` to render the Chart with the injected values It returns the list of Objects that are rendered, and an optional error if rendering failed, or converting the rendered manifests to objects failed.

func (*Deployer) SetNamespaceAndOwner deprecated

func (d *Deployer) SetNamespaceAndOwner(owner client.Object, objs []client.Object) []client.Object

Deprecated: use SetNamespaceAndOwnerWithGVK Using this without specifying the GVK breaks with client-go clients which do not set the GVK in the TypeMeta after the initial List()

func (*Deployer) SetNamespaceAndOwnerWithGVK

func (d *Deployer) SetNamespaceAndOwnerWithGVK(owner client.Object, ownerGVK schema.GroupVersionKind, objs []client.Object) []client.Object

SetNamespaceAndOwnerWithGVK sets namespace and ownerRef for rendered objects using the owner GVK

type GatewayClassInfo

type GatewayClassInfo struct {
	// Description is a human-readable description of the GatewayClass.
	Description string
	// Labels are the labels to be added to the GatewayClass.
	Labels map[string]string
	// Annotations are the annotations to be added to the GatewayClass.
	Annotations map[string]string
	// ParametersRef is the reference to the GatewayParameters object.
	ParametersRef *gwv1.ParametersReference
	// ControllerName is the name of the controller that is managing the GatewayClass.
	ControllerName string
	// SupportedFeatures is the list of Gateway API features supported by this GatewayClass.
	// This will be populated in the GatewayClass status.supportedFeatures field.
	SupportedFeatures []gwv1.SupportedFeature
}

GatewayClassInfo describes the desired configuration for a GatewayClass.

type HelmConfig

type HelmConfig struct {
	Agentgateway       *AgentgatewayHelmGateway `json:"agentgateway,omitempty"`
	InferenceExtension *HelmInferenceExtension  `json:"inferenceExtension,omitempty"`
}

helmConfig stores the top-level helm values used by the deployer.

type HelmEndpointPickerExtension

type HelmEndpointPickerExtension struct {
	PoolName      string `json:"poolName"`
	PoolNamespace string `json:"poolNamespace"`
}

type HelmInferenceExtension

type HelmInferenceExtension struct {
	EndpointPicker *HelmEndpointPickerExtension `json:"endpointPicker,omitempty"`
}

type HelmPort

type HelmPort struct {
	Port       *int32  `json:"port,omitempty"`
	Protocol   *string `json:"protocol,omitempty"`
	Name       *string `json:"name,omitempty"`
	TargetPort *int32  `json:"targetPort,omitempty"`
	NodePort   *int32  `json:"nodePort,omitempty"`
}

helmPort represents a Gateway Listener port

func AppendPortValue

func AppendPortValue(gwPorts []HelmPort, port int32, name string) []HelmPort

func GetPortsValues

func GetPortsValues(gw *collections.GatewayForDeployer, noListenersDummyPort int32) []HelmPort

Extract the listener ports from a Gateway and corresponding listener sets. These will be used to populate: 1. the ports exposed on the envoy container 2. the ports exposed on the proxy service

type HelmValuesGenerator

type HelmValuesGenerator interface {
	// GetValues returns the helm values used to render the dynamically provisioned resources
	// for the given object (e.g. Gateway). If the values returned are nil, it indicates that
	// the object is self-managed and no resources should be provisioned.
	GetValues(ctx context.Context, obj client.Object) (map[string]any, error)

	// GetCacheSyncHandlers returns the cache sync handlers for the HelmValuesGenerator controller
	GetCacheSyncHandlers() []cache.InformerSynced
}

Deployer uses HelmValueGenerator implementation to generate a set of helm values when rendering a Helm chart

type HelmXds

type HelmXds struct {
	Host *string     `json:"host,omitempty"`
	Port *uint32     `json:"port,omitempty"`
	Tls  *HelmXdsTls `json:"tls,omitempty"`
}

helmXds represents the xds host and port to which envoy will connect to receive xds config updates

type HelmXdsTls

type HelmXdsTls struct {
	Enabled *bool   `json:"enabled,omitempty"`
	CaCert  *string `json:"caCert,omitempty"`
}

type ImageInfo

type ImageInfo struct {
	Registry   string
	Tag        string
	PullPolicy string
}

type InMemoryGatewayParametersConfig

type InMemoryGatewayParametersConfig struct {
	ClassName                  string
	ImageInfo                  *ImageInfo
	AgwControllerName          string
	OmitDefaultSecurityContext bool
}

InMemoryGatewayParametersConfig holds the configuration for creating in-memory GatewayParameters.

type InferenceExtInfo

type InferenceExtInfo struct{}

InferenceExtInfo defines the runtime state of Gateway API inference extensions.

type Inputs

type Inputs struct {
	Dev                        bool
	ImageDefaults              *agentgateway.Image
	ControlPlane               ControlPlaneInfo
	NoListenersDummyPort       uint16
	ImageInfo                  *ImageInfo
	CommonCollections          *collections.CommonCollections
	AgentgatewayClassName      string
	AgentgatewayControllerName string
}

Inputs is the set of options used to configure gateway/inference pool deployment.

type ObjectPostProcessor

type ObjectPostProcessor interface {
	// PostProcessObjects applies any post-processing to the rendered objects.
	// This is called after helm rendering but before deployment.
	// It returns the (potentially modified) slice of objects, as new objects may be added
	// (e.g., PodDisruptionBudget, HorizontalPodAutoscaler).
	PostProcessObjects(ctx context.Context, obj client.Object, rendered []client.Object) ([]client.Object, error)
}

ObjectPostProcessor is an optional interface that can be implemented by HelmValuesGenerator to post-process rendered objects before they are deployed. This is used for applying strategic merge patch overlays from AgentgatewayParameters.

type Option

type Option func(*Deployer)

func WithPatcher

func WithPatcher(p Patcher) Option

type Patcher

type Patcher func(client apiclient.Client, fieldManager string, gvr schema.GroupVersionResource, name string, namespace string, data []byte, subresources ...string) error

Custom patcher; used for testing since SSA does not work with Dynamic fake client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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