kube

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultKubeConfigSecretKey is the default data key ConfigFromSecret
	// looks at when no data key is provided.
	DefaultKubeConfigSecretKey = "value"
	// DefaultKubeConfigSecretKeyExt is the default data key ConfigFromSecret
	// looks at when no data key is provided, and DefaultKubeConfigSecretKey
	// does not exist.
	DefaultKubeConfigSecretKeyExt = DefaultKubeConfigSecretKey + ".yaml"
)

Variables

View Source
var DefaultServiceAccountName string

DefaultServiceAccountName can be set at runtime to enable a fallback account name when no service account name is provided to SetImpersonationConfig.

Functions

func ConfigFromSecret added in v0.22.0

func ConfigFromSecret(secret *corev1.Secret, key string, opts client.KubeConfigOptions) (*rest.Config, error)

ConfigFromSecret returns the KubeConfig data from the provided key in the given Secret, or attempts to load the data from the default `value` and `value.yaml` keys. If a Secret is provided but no key with data can be found, an error is returned.

func SetImpersonationConfig added in v0.22.0

func SetImpersonationConfig(cfg *rest.Config, namespace, serviceAccount string) string

SetImpersonationConfig configures the provided service account name if given, or the DefaultServiceAccountName as a fallback if set. It returns the configured impersonation username, or an empty string.

Types

type MemoryRESTClientGetter

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

MemoryRESTClientGetter is a resource.RESTClientGetter that uses an in-memory REST config, REST mapper, and discovery client. If configured, the client config, REST mapper, and discovery client are lazily initialized, and cached for subsequent calls.

func NewInClusterMemoryRESTClientGetter added in v0.31.0

func NewInClusterMemoryRESTClientGetter(opts ...Option) (*MemoryRESTClientGetter, error)

NewInClusterMemoryRESTClientGetter returns a new MemoryRESTClientGetter that uses the in-cluster REST config. It returns an error if the in-cluster REST config cannot be obtained.

func NewMemoryRESTClientGetter

func NewMemoryRESTClientGetter(cfg *rest.Config, opts ...Option) *MemoryRESTClientGetter

NewMemoryRESTClientGetter returns a new MemoryRESTClientGetter.

func (*MemoryRESTClientGetter) ToDiscoveryClient

ToDiscoveryClient returns a memory cached discovery client. Calling it multiple times will return the same instance.

func (*MemoryRESTClientGetter) ToRESTConfig

func (c *MemoryRESTClientGetter) ToRESTConfig() (*rest.Config, error)

ToRESTConfig returns the in-memory REST config.

func (*MemoryRESTClientGetter) ToRESTMapper

func (c *MemoryRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

ToRESTMapper returns a meta.RESTMapper using the discovery client. Calling it multiple times will return the same instance.

func (*MemoryRESTClientGetter) ToRawKubeConfigLoader

func (c *MemoryRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig

ToRawKubeConfigLoader returns a clientcmd.ClientConfig using clientcmd.DefaultClientConfig. With clientcmd.ClusterDefaults, namespace, and impersonate configured as overwrites.

type Option added in v0.31.0

type Option func(*MemoryRESTClientGetter)

Option is a function that configures an MemoryRESTClientGetter.

func WithClientOptions added in v0.22.0

func WithClientOptions(opts client.Options) Option

WithClientOptions sets the client options (e.g. QPS and Burst) to use for the client.

func WithImpersonate added in v0.22.0

func WithImpersonate(serviceAccount, namespace string) Option

WithImpersonate sets the service account to impersonate. It configures the REST client to impersonate the service account in the given namespace, and sets the service account name as the username to use in the raw KubeConfig.

func WithNamespace added in v0.31.0

func WithNamespace(namespace string) Option

WithNamespace sets the namespace to use for the client.

func WithPersistent added in v0.32.0

func WithPersistent(persist bool) Option

WithPersistent sets whether the client should persist the underlying client config, REST mapper, and discovery client.

Jump to

Keyboard shortcuts

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