Documentation ¶
Index ¶
- Constants
- Variables
- func AllKubectlConfigs(timeout time.Duration) (map[string]*rest.Config, error)
- func DeepCopy(from *rest.Config) *rest.Config
- func DeepCopyInto(from, to *rest.Config)
- func KubeConfigPath() (string, error)
- func NewConfigFlags(config *rest.Config) (*genericclioptions.ConfigFlags, error)
- func NewFromConfigFile(path string) (*rest.Config, error)
- func NewFromInClusterConfig() (*rest.Config, error)
- func NewRestConfig(timeout time.Duration) (*rest.Config, error)
- func UpdateQPS(config *rest.Config)
Constants ¶
const DefaultTimeout = 15 * time.Second
DefaultTimeout is the default REST config timeout.
Variables ¶
var CurrentContextName = currentContextNameFromConfig
CurrentContextName returns the name of the currently active k8s context as a string Can be changed in tests by reassigning this pointer.
Functions ¶
func AllKubectlConfigs ¶
AllKubectlConfigs creates a config for every context available in the kubeconfig. The configs are mapped by context name. There is no way to detect unhealthy clusters specified by a context, so timeout can be used to prevent calls to those clusters from hanging for long periods of time.
func DeepCopy ¶ added in v1.15.1
DeepCopy returns a deep copy of the specified rest.Config. For reference, see rest.CopyConfig: https://github.com/kubernetes/client-go/blob/v0.24.0/rest/config.go#L630
func DeepCopyInto ¶ added in v1.15.1
DeepCopyInto copies one rest.Config into another. For reference, see rest.CopyConfig: https://github.com/kubernetes/client-go/blob/v0.24.0/rest/config.go#L630
func KubeConfigPath ¶ added in v1.17.0
KubeConfigPath returns the path to the kubeconfig: 1. ${KUBECONFIG}, if non-empty 2. ${userCurrentTestHook.HomeDir}/.kube/config, if userCurrentTestHook is set 3. ${HOME}/.kube/config
func NewConfigFlags ¶
func NewConfigFlags(config *rest.Config) (*genericclioptions.ConfigFlags, error)
NewConfigFlags builds ConfigFlags based on an existing rest config. Burst QPS is increased by 3x for discovery. CacheDir is populated from the KUBECACHEDIR env var, if set.
func NewFromConfigFile ¶ added in v1.15.1
NewFromConfigFile returns a REST config built from the kube config file at the specified path.
func NewFromInClusterConfig ¶ added in v1.15.1
NewFromInClusterConfig returns a REST config built from the k8s downward API. This should work from inside a Pod to talk to the cluster the Pod is in.
func NewRestConfig ¶
NewRestConfig will attempt to create a new rest config from all configured options and return the first successfully created configuration. The client-side throttling is only determined by if server-side flow control is enabled or not. If server-side flow control is enabled, then client-side throttling is disabled, vice versa.
func UpdateQPS ¶
UpdateQPS modifies a rest.Config to update the client-side throttling QPS and Burst QPS.
- If Flow Control is enabled on the apiserver, and client-side throttling is not forced to be enabled, client-side throttling is disabled! - If Flow Control is disabled or undetected on the apiserver, client-side throttling QPS will be increased to at least 30 (burst: 60).
Flow Control is enabled by default on Kubernetes v1.20+. https://kubernetes.io/docs/concepts/cluster-administration/flow-control/
Types ¶
This section is empty.