Documentation
¶
Overview ¶
Package k8s gives a unified interface for k8s information to be retrieved.
Index ¶
Constants ¶
const EnvK8sNamespace = "K8S_NAMESPACE"
EnvK8sNamespace Kubernetes namespace that the application is running inside
const EnvK8sPodName = "K8S_POD_NAME"
EnvK8sPodName Kubernetes pod name the application is running inside
const EnvKubeConfigLocation = "KUBE_CONFIG_LOCATION"
EnvKubeConfigLocation Location of a valid kube config
Variables ¶
This section is empty.
Functions ¶
func GetClient ¶
func GetClient() (*kubernetes.Clientset, error)
GetClient creates a new k8s client to use
func GetConfig ¶
GetConfig returns a k8s config based on the environment detecting if we are on the prometheus pod or running on a machine with a kubeconfig file
If no config is found, an error will be thrown ¶
Optionally, you can set the env variable `KUBE_CONFIG_LOCATION` to set where the function looks for a valid kube config file
func GetNamespace ¶
GetNamespace gets the current kubernetes namespace if running in a pod.
This is parsed from the `K8S_NAMESPACE` environment variable.
This will return an error if the environment variable is not set or the value is empty.
func GetPodName ¶
GetPodName gets the current kubernetes pod name this app is running in
This is parsed from the `K8S_POD_NAME` environment variable.
This will return an error if the environment variable is not set or the value is empty.
func GetProviderID ¶
GetProviderID uses the detected k8s namespace and pod name to query the API to get the cloud provider id.
This function requires setting both environment variables: `K8S_POD_NAME` and `K8S_NAMESPACE`
func GetVersion ¶
GetVersion returns the current kuberentes version when running inside of a pod
Types ¶
This section is empty.