controllers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidServiceNameTemplate added in v0.9.4

func IsValidServiceNameTemplate(serviceNameTemplate string) bool

Validates the given serviceNameTemplate A template should only contain {namespace}, {name}, {port} or {hash} separated by hyphens

func ReconcileStatus

func ReconcileStatus(project string, actual AutonegStatus, intended AutonegStatus) (removes, upserts map[string]map[string]Backends)

ReconcileStatus takes the actual and intended AutonegStatus and returns sets of backends to remove, and to upsert

func TrimFieldsEvenly added in v0.9.4

func TrimFieldsEvenly(max int, fields ...string) []string

This function is mostly copied from: https://github.com/kubernetes/ingress-gce/blob/4cb04408a6266b5ea00d9567c6165b9235392972/pkg/utils/namer/utils.go#L27..L62 TrimFieldsEvenly trims the fields evenly and keeps the total length <= max. Truncation is spread in ratio with their original length, meaning smaller fields will be truncated less than longer ones.

Types

type AutonegConfig

type AutonegConfig struct {
	BackendServices map[string]map[string]AutonegNEGConfig `json:"backend_services"`
}

AutonegConfig specifies the intended configuration of autoneg stored in the controller.autoneg.dev/neg annotation

type AutonegConfigTemp added in v0.9.4

type AutonegConfigTemp struct {
	BackendServices map[string][]AutonegNEGConfig `json:"backend_services"`
}

type AutonegNEGConfig added in v0.9.4

type AutonegNEGConfig struct {
	Name            string  `json:"name,omitempty"`
	Region          string  `json:"region,omitempty"`
	Rate            float64 `json:"max_rate_per_endpoint,omitempty"`
	Connections     float64 `json:"max_connections_per_endpoint,omitempty"`
	InitialCapacity *int32  `json:"initial_capacity,omitempty"`
	CapacityScaler  *int32  `json:"capacity_scaler,omitempty"`
}

AutonegConfig specifies the intended configuration of autoneg stored in the controller.autoneg.dev/neg annotation

type AutonegStatus

type AutonegStatus struct {
	AutonegConfig
	NEGStatus
	AutonegSyncConfig *AutonegSyncConfig `json:"sync,omitempty"`
}

AutonegStatus specifies the reconciled status of autoneg stored in the controller.autoneg.dev/neg annotation

func (AutonegStatus) Backend

func (s AutonegStatus) Backend(name string, port string, group string) compute.Backend

Backend returns a compute.Backend struct specified with a backend group and the embedded AutonegConfig

type AutonegSyncConfig added in v1.1.0

type AutonegSyncConfig struct {
	CapacityScaler *bool `json:"capacity_scaler,omitempty"`
}

Specifies additional configuration which to sync

type BackendController

type BackendController interface {
	ReconcileBackends(AutonegStatus, AutonegStatus) error
}

type Backends

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

Backends specifies a name and list of compute.Backends

type NEGConfig added in v0.9.4

type NEGConfig struct {
	ExposedPorts map[string]interface{} `json:"exposed_ports"`
}

NEGConfig specifies the configuration stored in in the cloud.google.com/neg annotation

type NEGStatus

type NEGStatus struct {
	NEGs  map[string]string `json:"network_endpoint_groups"`
	Zones []string          `json:"zones"`
}

NEGStatus specifies the output of the GKE NEG controller stored in the cloud.google.com/neg-status annotation

type OldAutonegConfig added in v0.9.4

type OldAutonegConfig struct {
	Name string  `json:"name"`
	Rate float64 `json:"max_rate_per_endpoint"`
}

AutonegConfig specifies the intended configuration of autoneg stored in the anthos.cft.dev/autoneg annotation

type OldAutonegStatus added in v0.9.4

type OldAutonegStatus struct {
	OldAutonegConfig
	NEGStatus
}

AutonegStatus specifies the reconciled status of autoneg stored in the anthos.cft.dev/autoneg-status annotation

type ProdBackendController added in v1.1.0

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

BackendController manages operations on a GCLB backend service

func NewBackendController

func NewBackendController(project string, s *compute.Service) *ProdBackendController

NewBackendController takes the project name and an initialized *compute.Service

func (*ProdBackendController) ReconcileBackends added in v1.1.0

func (b *ProdBackendController) ReconcileBackends(actual, intended AutonegStatus) (err error)

ReconcileBackends takes the actual and intended AutonegStatus and attempts to apply the intended status or return an error

type ServiceReconciler

type ServiceReconciler struct {
	client.Client
	Scheme *runtime.Scheme
	BackendController
	Recorder                         record.EventRecorder
	ServiceNameTemplate              string
	AllowServiceName                 bool
	MaxRatePerEndpointDefault        float64
	MaxConnectionsPerEndpointDefault float64
	AlwaysReconcile                  bool
	ReconcileDuration                *time.Duration
}

ServiceReconciler reconciles a Service object

func (*ServiceReconciler) Reconcile

func (r *ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Service object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.8.3/pkg/reconcile

func (*ServiceReconciler) SetupWithManager

func (r *ServiceReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type Statuses

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

Statuses represents the autoneg-relevant structs fetched from annotations

Jump to

Keyboard shortcuts

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