kubernetes

package
v1.101.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SDCheckInterval = flag.Duration("promscrape.kubernetesSDCheckInterval", 30*time.Second, "Interval for checking for changes in Kubernetes API server. "+
	"This works only if kubernetes_sd_configs is configured in '-promscrape.config' file. "+
	"See https://docs.victoriametrics.com/sd_configs/#kubernetes_sd_configs for details")

SDCheckInterval defines interval for targets refresh.

Functions

This section is empty.

Types

type AttachMetadata added in v1.77.0

type AttachMetadata struct {
	Node bool `yaml:"node"`
}

AttachMetadata represents `attach_metadata` option at `kuberentes_sd_config`.

See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config

type AuthInfo added in v1.78.0

type AuthInfo struct {
	ClientCertificate     string `yaml:"client-certificate,omitempty"`
	ClientCertificateData string `yaml:"client-certificate-data,omitempty"`
	ClientKey             string `yaml:"client-key,omitempty"`
	ClientKeyData         string `yaml:"client-key-data,omitempty"`
	// TODO add support for it
	Exec                 *ExecConfig `yaml:"exec,omitempty"`
	Token                string      `yaml:"token,omitempty"`
	TokenFile            string      `yaml:"tokenFile,omitempty"`
	Impersonate          string      `yaml:"act-as,omitempty"`
	ImpersonateUID       string      `yaml:"act-as-uid,omitempty"`
	ImpersonateGroups    []string    `yaml:"act-as-groups,omitempty"`
	ImpersonateUserExtra []string    `yaml:"act-as-user-extra,omitempty"`
	Username             string      `yaml:"username,omitempty"`
	Password             string      `yaml:"password,omitempty"`
}

AuthInfo contains information that describes identity information. This is use to tell the kubernetes cluster who you are.

type Bookmark added in v1.56.0

type Bookmark struct {
	Metadata struct {
		ResourceVersion string
	}
}

Bookmark is a bookmark message from Kubernetes Watch API. See https://kubernetes.io/docs/reference/using-api/api-concepts/#watch-bookmarks

type Cluster added in v1.78.0

type Cluster struct {
	Server                   string     `yaml:"server"`
	TLSServerName            string     `yaml:"tls-server-name,omitempty"`
	InsecureSkipTLSVerify    bool       `yaml:"insecure-skip-tls-verify,omitempty"`
	CertificateAuthority     string     `yaml:"certificate-authority,omitempty"`
	CertificateAuthorityData string     `yaml:"certificate-authority-data,omitempty"`
	ProxyURL                 *proxy.URL `yaml:"proxy-url,omitempty"`
}

Cluster contains information about how to communicate with a kubernetes cluster

type Config added in v1.78.0

type Config struct {
	Kind       string `yaml:"kind,omitempty"`
	APIVersion string `yaml:"apiVersion,omitempty"`
	Clusters   []struct {
		Name    string   `yaml:"name"`
		Cluster *Cluster `yaml:"cluster"`
	} `yaml:"clusters"`
	AuthInfos []struct {
		Name     string    `yaml:"name"`
		AuthInfo *AuthInfo `yaml:"user"`
	} `yaml:"users"`
	Contexts []struct {
		Name    string   `yaml:"name"`
		Context *Context `yaml:"context"`
	} `yaml:"contexts"`
	CurrentContext string `yaml:"current-context"`
}

Config represent configuration file for kubernetes API server connection https://github.com/kubernetes/client-go/blob/master/tools/clientcmd/api/v1/types.go#L28

type Container

type Container struct {
	Name  string
	Image string
	Ports []ContainerPort
}

Container implements k8s container.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#container-v1-core

type ContainerPort

type ContainerPort struct {
	Name          string
	ContainerPort int
	Protocol      string
}

ContainerPort implements k8s container port.

type ContainerState added in v1.97.0

type ContainerState struct {
	Terminated *ContainerStateTerminated
}

ContainerState implements k8s container state.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#containerstatus-v1-core

type ContainerStateTerminated added in v1.97.0

type ContainerStateTerminated struct {
	ExitCode int
}

ContainerStateTerminated implements k8s terminated container state.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#containerstatus-v1-core

type ContainerStatus added in v1.87.0

type ContainerStatus struct {
	Name        string
	ContainerID string
	State       ContainerState
}

ContainerStatus implements k8s container status.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#containerstatus-v1-core

type Context added in v1.78.0

type Context struct {
	Cluster  string `yaml:"cluster"`
	AuthInfo string `yaml:"user"`
}

Context is a tuple of references to a cluster and AuthInfo

type DaemonEndpoint

type DaemonEndpoint struct {
	Port int
}

DaemonEndpoint represents DaemonEndpoint from k8s API.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#daemonendpoint-v1-core

type Endpoint added in v1.41.0

type Endpoint struct {
	Addresses  []string
	Conditions EndpointConditions
	Hostname   string
	TargetRef  ObjectReference
	Topology   map[string]string
}

Endpoint implements kubernetes object endpoint for endpoint slice.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#endpoint-v1-discovery-k8s-io

type EndpointAddress

type EndpointAddress struct {
	Hostname  string
	IP        string
	NodeName  string
	TargetRef ObjectReference
}

EndpointAddress implements k8s endpoint address.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#endpointaddress-v1-core

type EndpointConditions added in v1.41.0

type EndpointConditions struct {
	Ready bool
}

EndpointConditions implements kubernetes endpoint condition.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#endpointconditions-v1-discovery-k8s-io

type EndpointPort

type EndpointPort struct {
	AppProtocol string
	Name        string
	Port        int
	Protocol    string
}

EndpointPort implements k8s endpoint port.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#endpointport-v1-discovery-k8s-io

type EndpointSlice added in v1.41.0

type EndpointSlice struct {
	Metadata    ObjectMeta
	Endpoints   []Endpoint
	AddressType string
	Ports       []EndpointPort
}

EndpointSlice - implements kubernetes endpoint slice.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#endpointslice-v1-discovery-k8s-io

type EndpointSliceList added in v1.41.0

type EndpointSliceList struct {
	Metadata ListMeta
	Items    []*EndpointSlice
}

EndpointSliceList - implements kubernetes endpoint slice list object, that groups service endpoints slices.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#endpointslicelist-v1-discovery-k8s-io

type EndpointSubset

type EndpointSubset struct {
	Addresses         []EndpointAddress
	NotReadyAddresses []EndpointAddress
	Ports             []EndpointPort
}

EndpointSubset implements k8s endpoint subset.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#endpointsubset-v1-core

type Endpoints

type Endpoints struct {
	Metadata ObjectMeta
	Subsets  []EndpointSubset
}

Endpoints implements k8s endpoints.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#endpoints-v1-core

type EndpointsList

type EndpointsList struct {
	Metadata ListMeta
	Items    []*Endpoints
}

EndpointsList implements k8s endpoints list.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#endpointslist-v1-core

type Error added in v1.57.0

type Error struct {
	Code int
}

Error is an error message from Kubernetes Watch API.

type ExecConfig added in v1.78.0

type ExecConfig struct {
	// Command to execute.
	Command string `json:"command"`
	// Arguments to pass to the command when executing it.
	Args []string `json:"args"`
	// Env defines additional environment variables to expose to the process. These
	// are unioned with the host's environment, as well as variables client-go uses
	// to pass argument to the plugin.
	Env []ExecEnvVar `json:"env"`

	// Preferred input version of the ExecInfo. The returned ExecCredentials MUST use
	// the same encoding version as the input.
	APIVersion string `json:"apiVersion,omitempty"`

	// This text is shown to the user when the executable doesn't seem to be
	// present. For example, `brew install foo-cli` might be a good InstallHint for
	// foo-cli on Mac OS systems.
	InstallHint string `json:"installHint,omitempty"`

	// ProvideClusterInfo determines whether or not to provide cluster information,
	// which could potentially contain very large CA data, to this exec plugin as a
	// part of the KUBERNETES_EXEC_INFO environment variable. By default, it is set
	// to false. Package k8s.io/client-go/tools/auth/exec provides helper methods for
	// reading this environment variable.
	ProvideClusterInfo bool `json:"provideClusterInfo"`

	// InteractiveMode determines this plugin's relationship with standard input. Valid
	// values are "Never" (this exec plugin never uses standard input), "IfAvailable" (this
	// exec plugin wants to use standard input if it is available), or "Always" (this exec
	// plugin requires standard input to function). See ExecInteractiveMode values for more
	// details.
	//
	// If APIVersion is client.authentication.k8s.io/v1alpha1 or
	// client.authentication.k8s.io/v1beta1, then this field is optional and defaults
	// to "IfAvailable" when unset. Otherwise, this field is required.
	//+optional
	InteractiveMode string `json:"interactiveMode,omitempty"`
}

ExecConfig contains information about os.command, that returns auth token for kubernetes cluster connection

type ExecEnvVar added in v1.78.0

type ExecEnvVar struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

ExecEnvVar is used for setting environment variables when executing an exec-based credential plugin.

type HTTPIngressPath

type HTTPIngressPath struct {
	Path string
}

HTTPIngressPath represents HTTP ingress path in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#httpingresspath-v1-networking-k8s-io

type HTTPIngressRuleValue

type HTTPIngressRuleValue struct {
	Paths []HTTPIngressPath
}

HTTPIngressRuleValue represents HTTP ingress rule value in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#httpingressrulevalue-v1-networking-k8s-io

type IngressList

type IngressList struct {
	Metadata ListMeta
	Items    []*Ingress
}

IngressList represents ingress list in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#ingresslist-v1-networking-k8s-io

type IngressRule

type IngressRule struct {
	Host string
	HTTP HTTPIngressRuleValue `json:"http"`
}

IngressRule represents ingress rule in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#ingressrule-v1-networking-k8s-io

type IngressSpec

type IngressSpec struct {
	TLS              []IngressTLS `json:"tls"`
	Rules            []IngressRule
	IngressClassName string
}

IngressSpec represents ingress spec in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#ingressspec-v1-networking-k8s-io

type IngressTLS

type IngressTLS struct {
	Hosts []string
}

IngressTLS represents ingress TLS spec in k8s.

See https://v1-21.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.21/#ingresstls-v1-networking-k8s-io

type ListMeta added in v1.55.0

type ListMeta struct {
	ResourceVersion string
}

ListMeta is a Kubernetes list metadata https://v1-17.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#listmeta-v1-meta

type Namespaces added in v1.35.0

type Namespaces struct {
	OwnNamespace bool     `yaml:"own_namespace"`
	Names        []string `yaml:"names"`
}

Namespaces represents namespaces for SDConfig

type Node

type Node struct {
	Metadata ObjectMeta
	Status   NodeStatus
	Spec     NodeSpec
}

Node represents Node from k8s API.

See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/

type NodeAddress

type NodeAddress struct {
	Type    string
	Address string
}

NodeAddress represents NodeAddress from k8s API.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#nodeaddress-v1-core

type NodeDaemonEndpoints

type NodeDaemonEndpoints struct {
	KubeletEndpoint DaemonEndpoint
}

NodeDaemonEndpoints represents NodeDaemonEndpoints from k8s API.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#nodedaemonendpoints-v1-core

type NodeList

type NodeList struct {
	Metadata ListMeta
	Items    []*Node
}

NodeList represents NodeList from k8s API.

See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeList

type NodeSpec added in v1.72.0

type NodeSpec struct {
	ProviderID string
}

NodeSpec represents NodeSpec from k8s API.

See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeSpec

type NodeStatus

type NodeStatus struct {
	Addresses       []NodeAddress
	DaemonEndpoints NodeDaemonEndpoints
}

NodeStatus represents NodeStatus from k8s API.

See https://kubernetes.io/docs/reference/kubernetes-api/cluster-resources/node-v1/#NodeStatus

type ObjectMeta

type ObjectMeta struct {
	Name            string
	Namespace       string
	UID             string
	Labels          *promutils.Labels
	Annotations     *promutils.Labels
	OwnerReferences []OwnerReference
}

ObjectMeta represents ObjectMeta from k8s API.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#objectmeta-v1-meta

type ObjectReference

type ObjectReference struct {
	Kind      string
	Name      string
	Namespace string
}

ObjectReference implements k8s object reference.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#objectreference-v1-core

type OwnerReference

type OwnerReference struct {
	Name       string
	Controller bool
	Kind       string
}

OwnerReference represents OwnerReferense from k8s API.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#ownerreference-v1-meta

type Pod

type Pod struct {
	Metadata ObjectMeta
	Spec     PodSpec
	Status   PodStatus
}

Pod implements k8s pod.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#pod-v1-core

type PodCondition

type PodCondition struct {
	Type   string
	Status string
}

PodCondition implements k8s pod condition.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podcondition-v1-core

type PodList

type PodList struct {
	Metadata ListMeta
	Items    []*Pod
}

PodList implements k8s pod list.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podlist-v1-core

type PodSpec

type PodSpec struct {
	NodeName       string
	Containers     []Container
	InitContainers []Container
}

PodSpec implements k8s pod spec.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podspec-v1-core

type PodStatus

type PodStatus struct {
	Phase                 string
	PodIP                 string
	HostIP                string
	Conditions            []PodCondition
	ContainerStatuses     []ContainerStatus
	InitContainerStatuses []ContainerStatus
}

PodStatus implements k8s pod status.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#podstatus-v1-core

type SDConfig added in v1.35.0

type SDConfig struct {
	APIServer string `yaml:"api_server,omitempty"`

	// Use role() function for accessing the Role field
	Role string `yaml:"role"`
	// The filepath to kube config.
	// If defined any cluster connection information from HTTPClientConfig is ignored.
	KubeConfigFile string `yaml:"kubeconfig_file,omitempty"`

	HTTPClientConfig promauth.HTTPClientConfig `yaml:",inline"`
	ProxyURL         *proxy.URL                `yaml:"proxy_url,omitempty"`
	Namespaces       Namespaces                `yaml:"namespaces,omitempty"`
	Selectors        []Selector                `yaml:"selectors,omitempty"`
	AttachMetadata   *AttachMetadata           `yaml:"attach_metadata,omitempty"`
	// contains filtered or unexported fields
}

SDConfig represents kubernetes-based service discovery config.

See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config

func (*SDConfig) GetScrapeWorkObjects added in v1.55.0

func (sdc *SDConfig) GetScrapeWorkObjects() ([]interface{}, error)

GetScrapeWorkObjects returns ScrapeWork objects for the given sdc.

This function must be called after MustStart call.

func (*SDConfig) MustStart added in v1.58.0

func (sdc *SDConfig) MustStart(baseDir string, swcFunc ScrapeWorkConstructorFunc)

MustStart initializes sdc before its usage.

swcFunc is used for constructing ScrapeWork objects from the given metadata.

func (*SDConfig) MustStop added in v1.55.0

func (sdc *SDConfig) MustStop()

MustStop stops further usage for sdc.

type ScrapeWorkConstructorFunc added in v1.55.0

type ScrapeWorkConstructorFunc func(metaLabels *promutils.Labels) interface{}

ScrapeWorkConstructorFunc must construct ScrapeWork object for the given metaLabels.

type Selector

type Selector struct {
	Role  string `yaml:"role"`
	Label string `yaml:"label"`
	Field string `yaml:"field"`
}

Selector represents kubernetes selector.

See https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/ and https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/

type Service

type Service struct {
	Metadata ObjectMeta
	Spec     ServiceSpec
}

Service is k8s service.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#service-v1-core

type ServiceList

type ServiceList struct {
	Metadata ListMeta
	Items    []*Service
}

ServiceList is k8s service list.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#servicelist-v1-core

type ServicePort

type ServicePort struct {
	Name     string
	Protocol string
	Port     int
}

ServicePort is k8s service port.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#serviceport-v1-core

type ServiceSpec

type ServiceSpec struct {
	ClusterIP    string
	ExternalName string
	Type         string
	Ports        []ServicePort
}

ServiceSpec is k8s service spec.

See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#servicespec-v1-core

type WatchEvent added in v1.55.0

type WatchEvent struct {
	Type   string
	Object json.RawMessage
}

WatchEvent is a watch event returned from API server endpoints if `watch=1` query arg is set.

See https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes

Jump to

Keyboard shortcuts

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