KubeConfig contains configuration related to loading and parsing a Kubeconfig file for instantiating K8s clients. We don't use the built-in clientcmd flag registration utilities because we don't want to expose the full sets of flags as K8s does (eg API server URL, namespace, etc).
type KubeConfig struct { Context string Path string // contains filtered or unexported fields }
func (k *KubeConfig) Client(opts client.Options) (client.Client, error)
Client creates a K8s client from the parsed KubeConfig. This is a helper function for binaries binding kubeconfig flags using this library.
func (k *KubeConfig) DynamicClient() (dynamic.Interface, error)
DynamicClient creates a dynamic client from the parsed KubeConfig.
func (k *KubeConfig) Mapper() (meta.RESTMapper, error)
Mapper instantiates the API resource mapper from the REST config.
func (k *KubeConfig) RESTConfig() (*rest.Config, error)
RESTConfig returns the rest.Config required to create a K8s client.
func (k *KubeConfig) RawConfig() (clientcmdapi.Config, error)
RawConfig returns the raw client configuration file (aka kubeconfig), which can be used to check contexts, cluster names, etc.
func (k *KubeConfig) RegisterFlags(fs *flag.FlagSet)
RegisterFlags binds common flags to an instance of the KubeConfig struct, enabling flag reuse for any binary which needs to build a K8s client and wants to allow users to override defaults via flags.
func (k *KubeConfig) SetupClientConfig() error
SetupClientConfig creates client loading configuration based on the values of bound flags, falling back to bog standard defaults if nothing is provided.