package config
import "sigs.k8s.io/controller-runtime/pkg/client/config"
Package config contains libraries for initializing REST configs for talking to the Kubernetes API
Index ¶
- Constants
- func GetConfig() (*rest.Config, error)
- func GetConfigOrDie() *rest.Config
- func GetConfigWithContext(context string) (*rest.Config, error)
- func RegisterFlags(fs *flag.FlagSet)
Constants ¶
const KubeconfigFlagName = "kubeconfig"
KubeconfigFlagName is the name of the kubeconfig flag
Functions ¶
func GetConfig ¶
GetConfig creates a *rest.Config for talking to a Kubernetes API server. If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running in cluster and use the cluster provided kubeconfig.
The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
It also applies saner defaults for QPS and burst based on the Kubernetes controller manager defaults (20 QPS, 30 burst)
Config precedence:
* --kubeconfig 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 ¶
GetConfigOrDie creates a *rest.Config for talking to a Kubernetes apiserver. If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running in cluster and use the cluster provided kubeconfig.
The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
Will log an error and exit if there is an error creating the rest.Config.
func GetConfigWithContext ¶
GetConfigWithContext creates a *rest.Config for talking to a Kubernetes API server with a specific context. If --kubeconfig is set, will use the kubeconfig file at that location. Otherwise will assume running in cluster and use the cluster provided kubeconfig.
The returned `*rest.Config` has client-side ratelimting disabled as we can rely on API priority and fairness. Set its QPS to a value equal or bigger than 0 to re-enable it.
It also applies saner defaults for QPS and burst based on the Kubernetes controller manager defaults (20 QPS, 30 burst)
Config precedence:
* --kubeconfig 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 RegisterFlags ¶
RegisterFlags registers flag variables to the given FlagSet if not already registered. It uses the default command line FlagSet, if none is provided. Currently, it only registers the kubeconfig flag.
Source Files ¶
config.go doc.go
- Version
- v0.21.0 (latest)
- Published
- May 20, 2025
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 26 minutes ago –
Tools for package owners.