configutils

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(opts ...GetConfigOption) (*rest.Config, error)

GetConfig creates a *rest.Config for talking to a Kubernetes API server. Kubeconfig / the '--kubeconfig' flag instruct to use the kubeconfig file at that location. Otherwise, will assume running in cluster and use the cluster provided kubeconfig.

It also applies saner defaults for QPS and burst based on the Kubernetes controller manager defaults (20 QPS, 30 burst)

Config precedence

* Kubeconfig / --kubeconfig value / flag pointing at a file

* KUBECONFIG environment variable pointing at a file

* In-cluster config if running in cluster

* $HOME/.kube/config if exists.

func GetConfigOrDie

func GetConfigOrDie(opts ...GetConfigOption) *rest.Config

GetConfigOrDie creates a *rest.Config for talking to a Kubernetes apiserver. If Kubeconfig / --kubeconfig is set, will use the kubeconfig file at that location. Otherwise, will assume running in cluster and use the cluster provided kubeconfig.

Will log an error and exit if there is an error creating the rest.Config.

func GetEgressSelectorDial added in v0.15.1

func GetEgressSelectorDial(networkContext egressselector.NetworkContext, egressSelectorConfig string) (utilnet.DialFunc, error)

GetEgressSelectorDial returns a dial function for the given network context and egress selector config path.

func LoadDefaultConfig added in v0.15.1

func LoadDefaultConfig(context string) (*rest.Config, error)

LoadDefaultConfig loads the default Kubernetes configuration for the specified context.

Types

type Burst added in v0.15.1

type Burst int

Burst allows specifying the maximum burst for throttle.

func (Burst) ApplyToGetConfig added in v0.15.1

func (b Burst) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type Context

type Context string

Context allows specifying the context to load.

func (Context) ApplyToGetConfig

func (c Context) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type EgressSelectionName

type EgressSelectionName string

EgressSelectionName is the name of the egress configuration to use.

const (
	// EgressSelectionNameControlPlane instructs to use the controlplane egress selection.
	EgressSelectionNameControlPlane EgressSelectionName = "controlplane"
	// EgressSelectionNameEtcd instructs to use the etcd egress selection.
	EgressSelectionNameEtcd EgressSelectionName = "etcd"
	// EgressSelectionNameCluster instructs to use the cluster egress selection.
	EgressSelectionNameCluster EgressSelectionName = "cluster"
)

func (EgressSelectionName) NetworkContext

NetworkContext returns the corresponding network context of the egress selection.

type EgressSelectorConfig

type EgressSelectorConfig string

EgressSelectorConfig allows specifying the path to an egress selector config to use.

func (EgressSelectorConfig) ApplyToGetConfig

func (c EgressSelectorConfig) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type GetConfigOption

type GetConfigOption interface {
	// ApplyToGetConfig modifies the underlying GetConfigOptions.
	ApplyToGetConfig(o *GetConfigOptions)
}

GetConfigOption are options to a GetConfig call.

type GetConfigOptions

type GetConfigOptions struct {
	// Context is the kubeconfig context to load.
	Context string
	// Kubeconfig is the path to a kubeconfig to load.
	// If unset, the '--kubeconfig' flag is used.
	Kubeconfig *string
	// EgressSelectorConfig is the path to an egress selector config to load.
	EgressSelectorConfig string
	// EgressSelectionName is the name of the egress configuration to use.
	// Defaults to EgressSelectionNameControlPlane.
	EgressSelectionName EgressSelectionName
	// QPS indicates the maximum QPS to the master from this client.
	QPS float32
	// Burst maximum burst for throttle.
	Burst int
}

GetConfigOptions are options to supply for a GetConfig call.

func (*GetConfigOptions) ApplyOptions

func (o *GetConfigOptions) ApplyOptions(opts []GetConfigOption)

ApplyOptions applies all GetConfigOption to this GetConfigOptions.

func (*GetConfigOptions) ApplyToGetConfig

func (o *GetConfigOptions) ApplyToGetConfig(o2 *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type Getter added in v0.15.1

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

Getter is a lightweight config getter that only needs a *rest.Config.

func NewGetter added in v0.15.1

func NewGetter(opts GetterOptions) (*Getter, error)

NewGetter creates a new Getter from the given options.

func NewGetterOrDie added in v0.15.1

func NewGetterOrDie(opts GetterOptions) *Getter

NewGetterOrDie creates a new Getter and logs/exits on error.

func (*Getter) GetConfig added in v0.15.1

func (g *Getter) GetConfig(ctx context.Context, opts ...GetConfigOption) (*rest.Config, error)

GetConfig returns a *rest.Config based on the given options.

func (*Getter) GetConfigOrDie added in v0.15.1

func (g *Getter) GetConfigOrDie(ctx context.Context, opts ...GetConfigOption) *rest.Config

GetConfigOrDie returns a *rest.Config based on the given options, or logs/exits on error.

type GetterOptions added in v0.15.1

type GetterOptions struct {
	Name                string
	LogConstructor      func() logr.Logger
	NetworkContext      egressselector.NetworkContext
	EgressSelectionName EgressSelectionName
}

GetterOptions are options for creating a Getter.

type Kubeconfig

type Kubeconfig string

Kubeconfig allows specifying the path to a kubeconfig file to use.

func (Kubeconfig) ApplyToGetConfig

func (k Kubeconfig) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type QPS added in v0.15.1

type QPS float32

QPS allows specifying the maximum QPS to the master from this client.

func (QPS) ApplyToGetConfig added in v0.15.1

func (q QPS) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type WithBurst added in v0.15.1

type WithBurst int

WithBurst allows specifying the maximum burst for throttle.

func (WithBurst) ApplyToGetConfig added in v0.15.1

func (b WithBurst) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type WithEgressSelectionName

type WithEgressSelectionName EgressSelectionName

WithEgressSelectionName allows specifying the egress selection name to use.

func (WithEgressSelectionName) ApplyToGetConfig

func (w WithEgressSelectionName) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

type WithQPS added in v0.15.1

type WithQPS float32

WithQPS allows specifying the maximum QPS to the master from this client.

func (WithQPS) ApplyToGetConfig added in v0.15.1

func (q WithQPS) ApplyToGetConfig(o *GetConfigOptions)

ApplyToGetConfig implements GetConfigOption.

Jump to

Keyboard shortcuts

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