client package - github.com/fluxcd/pkg/runtime/client - Go Packages

Package client provides runtime configuration options for a Kubernetes client, making it easier to consistently have the same configuration options and flags across GitOps Toolkit components.

This section is empty.

This section is empty.

GetConfigOrDie wraps ctrl.GetConfigOrDie and checks if the Kubernetes apiserver has PriorityAndFairness flow control filter enabled. If true, it returns a rest.Config with client side throttling disabled. Otherwise, it returns a modified rest.Config configured with the provided Options.

KubeConfig sanitises a kubeconfig represented as *rest.Config using KubeConfigOptions to inform the transformation decisions.

NewDynamicRESTMapper creates a new HTTP client using the provided config. It then returns a dynamic RESTMapper created using the HTTP client and the config. The returned RESTMapper dynamically discovers resource types at runtime.

type Impersonator struct {
	
}

Impersonator holds the state for impersonating a Kubernetes account.

NewImpersonator creates an Impersonator from the given arguments.

CanImpersonate checks if the given Kubernetes account can be impersonated.

GetClient creates a controller-runtime client for talking to a Kubernetes API server. If spec.KubeConfig is set, use the kubeconfig bytes from the Kubernetes secret. Otherwise, will assume running in cluster and use the cluster provided kubeconfig. If a --default-service-account is set and no spec.ServiceAccountName, use the provided kubeconfig and impersonate the default SA. If spec.ServiceAccountName is set, use the provided kubeconfig and impersonate the specified SA.

type ImpersonatorOption func(*Impersonator)

ImpersonatorOption is a functional option for configuring the Impersonator.

WithKubeConfig sets the kubeconfig options for the Impersonator.

WithPolling sets the polling options for the Impersonator.

WithScheme sets the scheme for the Impersonator.

func WithServiceAccount(defaultName, name, namespace string) ImpersonatorOption

WithServiceAccount sets the service account options for the Impersonator.

KubeConfigOptions defines options for KubeConfig sanitization.

BindFlags will parse the given pflag.FlagSet for Kubernetes client option flags and set the Options accordingly.

Options contains the runtime configuration for a Kubernetes client.

The struct can be used in the main.go file of your controller by binding it to the main flag set, and then utilizing the configured options later:

func main() {
	var (
		// other controller specific configuration variables
		clientOptions client.Options
	)

	// Bind the options to the main flag set, and parse it
	clientOptions.BindFlags(flag.CommandLine)
	flag.Parse()

	// Get a runtime Kubernetes client configuration with the options set
	restConfig := client.GetConfigOrDie(clientOptions)
}

BindFlags will parse the given pflag.FlagSet for Kubernetes client option flags and set the Options accordingly.

ProviderRESTConfigFetcher is a function that retrieves a *rest.Config for a given KubeConfigReference, a namespace, and a controller-runtime client.