setuputils

package
v1.21.20 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 34 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// FirstSyncTimeoutEnv is a Go duration ("10m") bounding how long a held restart waits for the first sync.
	FirstSyncTimeoutEnv = "GLOO_SETUP_FIRST_SYNC_TIMEOUT"
)
View Source
const (
	PodNamespace = statusutils.PodNamespaceEnvName
)

Variables

This section is empty.

Functions

func HoldRestartsUntilFirstSync added in v1.20.29

func HoldRestartsUntilFirstSync(ctx context.Context) func()

HoldRestartsUntilFirstSync holds settings and namespace restarts of the setup run owning ctx until the returned func is called. Callers in the same run share one release, so the first call frees the hold. Outside a setup run it returns a no-op.

func Main

func Main(opts SetupOpts) error

Main is the main entrypoint for running Gloo Edge components It works by performing the following:

  1. Initialize a SettingsClient backed either by Kubernetes or a File
  2. Run an event loop, watching events on the Settings resource, and executing the opts.SetupFunc whenever settings change

This allows Gloo components to automatically receive updates to Settings and reload their configuration, without needing to restart the container

func SetupLogging added in v1.15.2

func SetupLogging(ctx context.Context, loggerName string)

SetupLogging sets up controller-runtime logging

func SetupNamespaceName added in v1.18.0

func SetupNamespaceName() types.NamespacedName

Types

type SetupFunc

type SetupFunc func(ctx context.Context,
	kubeCache kube.SharedCache,
	inMemoryCache memory.InMemoryResourceCache,
	settings *v1.Settings,
	identity leaderelector.Identity) error

tell us how to setup

type SetupOpts

type SetupOpts struct {
	LoggerName string
	// logged as the version of Gloo currently executing
	Version     string
	SetupFunc   SetupFunc
	ExitOnError bool
	CustomCtx   context.Context

	// optional - if present, add these values in each JSON log line in the gloo pod.
	// By default, we already log the gloo version.
	LoggingPrefixVals []interface{}

	ElectionConfig *leaderelector.ElectionConfig
}

type SetupSyncer

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

func NewSetupSyncer

func NewSetupSyncer(settingsRef *core.ResourceRef, setupFunc SetupFunc, identity leaderelector.Identity) *SetupSyncer

func (*SetupSyncer) ShouldSync added in v1.17.9

func (s *SetupSyncer) ShouldSync(ctx context.Context, oldSnapshot, newSnapshot *v1.SetupSnapshot) bool

ShouldSync compares two snapshots and determines whether a sync is needed based on the following conditions 1. The settings CR has changed 2. A namespace is added / deleted / modified that changes the namespaces to watch

func (*SetupSyncer) Sync

func (s *SetupSyncer) Sync(ctx context.Context, snap *v1.SetupSnapshot) error

Sync runs the setup function. If a component in the run holds restarts (HoldRestartsUntilFirstSync), Sync then waits for it to release them. The setup event loop reads no snapshots while Sync runs, and the setup emitter re-sends a snapshot it could not deliver, so a settings or namespace change made during the wait restarts setup once Sync returns.

Jump to

Keyboard shortcuts

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