kubeconfig

package
v0.0.0-...-1d3370d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	KubeConfig = 1 << iota
	DynamicCluster
	InCluster
)
View Source
const InClusterContextName = "main"

TODO: Use a different way to avoid name clashes with other clusters.

Variables

This section is empty.

Functions

func LoadAndStoreKubeConfigs

func LoadAndStoreKubeConfigs(kubeConfigStore ContextStore, kubeConfigs string, source int) error

LoadAndStoreKubeConfigs loads contexts from the given kubeconfig files and stores them in the given context store. Note: No need to remove contexts from the store, since adding a context with the same name will overwrite the old one.

func LoadAndWatchFiles

func LoadAndWatchFiles(kubeConfigStore ContextStore, paths string, source int)

LoadAndWatchFiles loads kubeconfig files and watches them for changes.

func RemoveContextFromFile

func RemoveContextFromFile(context string, path string) error

RemoveContextFromFile removes the given context and its related cluster and user from the kubeconfig file.

func WriteToFile

func WriteToFile(config clientcmdapi.Config, path string) error

WriteToFile writes the given config to the kubeconfig file.

Types

type Context

type Context struct {
	Name        string        `json:"name"`
	KubeContext *api.Context  `json:"kubeContext"`
	Cluster     *api.Cluster  `json:"cluster"`
	AuthInfo    *api.AuthInfo `json:"authInfo"`
	Source      int           `json:"source"`
	OidcConf    *OidcConfig   `json:"oidcConfig"`

	Internal bool `json:"internal"`
	// contains filtered or unexported fields
}

Context contains all information related to a kubernetes context.

func GetInClusterContext

func GetInClusterContext(oidcIssuerURL string,
	oidcClientID string, oidcClientSecret string,
	oidcScopes string,
) (*Context, error)

GetInClusterContext returns the in-cluster context.

func LoadContextsFromAPIConfig

func LoadContextsFromAPIConfig(config *api.Config, skipProxySetup bool) ([]Context, []error)

LoadContextsFromAPIConfig loads contexts from the given api.Config.

func LoadContextsFromBase64String

func LoadContextsFromBase64String(kubeConfig string, source int) ([]Context, error)

LoadContextsFromBase64String loads contexts from the given kubeconfig string.

func LoadContextsFromFile

func LoadContextsFromFile(kubeConfigPath string, source int) ([]Context, error)

LoadContextsFromFile loads contexts from the given kubeconfig file.

func LoadContextsFromMultipleFiles

func LoadContextsFromMultipleFiles(kubeConfigs string, source int) ([]Context, error)

LoadContextsFromMultipleFiles loads contexts from the given kubeconfig files.

func (*Context) AuthType

func (c *Context) AuthType() string

AuthType returns the authentication type for the context.

func (*Context) ClientConfig

func (c *Context) ClientConfig() clientcmd.ClientConfig

ClientConfig returns a clientcmd.ClientConfig for the context.

func (*Context) ClientSetWithToken

func (c *Context) ClientSetWithToken(token string) (*kubernetes.Clientset, error)

ClientSetWithToken returns a kubernetes clientset for the context.

func (*Context) OidcConfig

func (c *Context) OidcConfig() (*OidcConfig, error)

OidcConfig returns the oidc config for the context.

func (*Context) ProxyRequest

func (c *Context) ProxyRequest(writer http.ResponseWriter, request *http.Request) error

ProxyRequest proxies the given request to the cluster.

func (*Context) RESTConfig

func (c *Context) RESTConfig() (*rest.Config, error)

RESTConfig returns a rest.Config for the context.

func (*Context) SetupProxy

func (c *Context) SetupProxy() error

SetupProxy sets up a reverse proxy for the context.

func (*Context) SourceStr

func (c *Context) SourceStr() string

SourceStr returns the source from which the context was loaded.

type ContextStore

type ContextStore interface {
	AddContext(headlampContext *Context) error
	GetContexts() ([]*Context, error)
	GetContext(name string) (*Context, error)
	RemoveContext(name string) error
	AddContextWithKeyAndTTL(headlampContext *Context, key string, ttl time.Duration) error
	UpdateTTL(key string, ttl time.Duration) error
}

ContextStore is an interface for storing and retrieving contexts.

func NewContextStore

func NewContextStore() ContextStore

NewContextStore creates a new ContextStore.

type OidcConfig

type OidcConfig struct {
	ClientID     string
	ClientSecret string
	IdpIssuerURL string
	Scopes       []string
}

Jump to

Keyboard shortcuts

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