Documentation ¶
Index ¶
- Constants
- Variables
- func EmptyFieldSelector() string
- func FetchLoadInstructions(shell string) string
- func GetConfigFile(opt Options) string
- func MergeFieldSelectors(selectors []string) (string, error)
- func MergeTwoFieldSelectors(s1 string, s2 string) (string, error)
- type LabelsAllowList
- type MetricSet
- type NamespaceList
- func (n *NamespaceList) GetExcludeNSFieldSelector(nsDenylist []string) string
- func (n *NamespaceList) GetNamespaces() NamespaceList
- func (n *NamespaceList) IsAllNamespaces() bool
- func (n *NamespaceList) Set(value string) error
- func (n *NamespaceList) String() string
- func (n *NamespaceList) Type() string
- type NodeType
- type Options
- type ResourceSet
Constants ¶
const LabelWildcard = "*"
LabelWildcard allowlists any label
Variables ¶
var ( // DefaultNamespaces is the default namespace selector for selecting and filtering across all namespaces. DefaultNamespaces = NamespaceList{metav1.NamespaceAll} // DefaultResources represents the default set of resources in kube-state-metrics. DefaultResources = ResourceSet{ "certificatesigningrequests": struct{}{}, "configmaps": struct{}{}, "cronjobs": struct{}{}, "daemonsets": struct{}{}, "deployments": struct{}{}, "endpoints": struct{}{}, "horizontalpodautoscalers": struct{}{}, "ingresses": struct{}{}, "jobs": struct{}{}, "leases": struct{}{}, "limitranges": struct{}{}, "mutatingwebhookconfigurations": struct{}{}, "namespaces": struct{}{}, "networkpolicies": struct{}{}, "nodes": struct{}{}, "persistentvolumes": struct{}{}, "persistentvolumeclaims": struct{}{}, "poddisruptionbudgets": struct{}{}, "pods": struct{}{}, "replicasets": struct{}{}, "replicationcontrollers": struct{}{}, "resourcequotas": struct{}{}, "secrets": struct{}{}, "services": struct{}{}, "statefulsets": struct{}{}, "storageclasses": struct{}{}, "validatingwebhookconfigurations": struct{}{}, "volumeattachments": struct{}{}, } )
var InitCommand = &cobra.Command{ Use: "kube-state-metrics", Short: "Add-on agent to generate and expose cluster-level metrics.", Long: "kube-state-metrics is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects.", Args: cobra.NoArgs, }
InitCommand defines the root command that others will latch onto.
Functions ¶
func EmptyFieldSelector ¶ added in v2.7.0
func EmptyFieldSelector() string
EmptyFieldSelector returns an empty field selector.
func FetchLoadInstructions ¶ added in v2.7.0
FetchLoadInstructions returns instructions for enabling autocompletion for a particular shell.
func GetConfigFile ¶ added in v2.8.0
GetConfigFile is the getter for --config value.
func MergeFieldSelectors ¶ added in v2.7.0
MergeFieldSelectors returns AND of a list of field selectors.
Types ¶
type LabelsAllowList ¶
LabelsAllowList represents a list of allowed labels for metrics.
func (*LabelsAllowList) Set ¶
func (l *LabelsAllowList) Set(value string) error
Set converts a comma-separated string of resources and their allowed Kubernetes labels and appends to the LabelsAllowList. Value is in the following format: resource=[k8s-label-name,another-k8s-label],another-resource[k8s-label] Example: pods=[app.kubernetes.io/component,app],resource=[blah]
func (*LabelsAllowList) String ¶
func (l *LabelsAllowList) String() string
func (*LabelsAllowList) Type ¶
func (l *LabelsAllowList) Type() string
Type returns a descriptive string about the LabelsAllowList type.
type MetricSet ¶
type MetricSet map[string]struct{}
MetricSet represents a collection which has a unique set of metrics.
type NamespaceList ¶
type NamespaceList []string
NamespaceList represents a list of namespaces to query from.
func (*NamespaceList) GetExcludeNSFieldSelector ¶ added in v2.3.0
func (n *NamespaceList) GetExcludeNSFieldSelector(nsDenylist []string) string
GetExcludeNSFieldSelector will return excluded namespace field selector if nsDenylist = {case1,case2}, the result will be "metadata.namespace!=case1,metadata.namespace!=case2".
func (*NamespaceList) GetNamespaces ¶ added in v2.3.0
func (n *NamespaceList) GetNamespaces() NamespaceList
GetNamespaces is a helper function to get namespaces from opts.Namespaces
func (*NamespaceList) IsAllNamespaces ¶
func (n *NamespaceList) IsAllNamespaces() bool
IsAllNamespaces checks if the Namespace selector is that of `NamespaceAll` which is used for selecting or filtering across all namespaces.
func (*NamespaceList) Set ¶
func (n *NamespaceList) Set(value string) error
Set converts a comma-separated string of namespaces into a slice and appends it to the NamespaceList
func (*NamespaceList) String ¶
func (n *NamespaceList) String() string
func (*NamespaceList) Type ¶
func (n *NamespaceList) Type() string
Type returns a descriptive string about the NamespaceList type.
type NodeType ¶ added in v2.7.0
type NodeType string
NodeType represents a nodeName to query from.
func (*NodeType) GetNodeFieldSelector ¶ added in v2.7.0
GetNodeFieldSelector returns a nodename field selector.
type Options ¶
type Options struct { AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"` Apiserver string `yaml:"apiserver"` CustomResourceConfig string `yaml:"custom_resource_config"` CustomResourceConfigFile string `yaml:"custom_resource_config_file"` CustomResourcesOnly bool `yaml:"custom_resources_only"` EnableGZIPEncoding bool `yaml:"enable_gzip_encoding"` Help bool `yaml:"help"` Host string `yaml:"host"` Kubeconfig string `yaml:"kubeconfig"` LabelsAllowList LabelsAllowList `yaml:"labels_allow_list"` MetricAllowlist MetricSet `yaml:"metric_allowlist"` MetricDenylist MetricSet `yaml:"metric_denylist"` MetricOptInList MetricSet `yaml:"metric_opt_in_list"` Namespace string `yaml:"namespace"` Namespaces NamespaceList `yaml:"namespaces"` NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"` Node NodeType `yaml:"node"` Pod string `yaml:"pod"` Port int `yaml:"port"` Resources ResourceSet `yaml:"resources"` Shard int32 `yaml:"shard"` TLSConfig string `yaml:"tls_config"` TelemetryHost string `yaml:"telemetry_host"` TelemetryPort int `yaml:"telemetry_port"` TotalShards int `yaml:"total_shards"` UseAPIServerCache bool `yaml:"use_api_server_cache"` Config string // contains filtered or unexported fields }
Options are the configurable parameters for kube-state-metrics.
func (*Options) AddFlags ¶
AddFlags populated the Options struct from the command line arguments passed.
type ResourceSet ¶
type ResourceSet map[string]struct{}
ResourceSet represents a collection which has a unique set of resources.
func (ResourceSet) AsSlice ¶
func (r ResourceSet) AsSlice() []string
AsSlice returns the Resource in the form of a plain string slice.
func (*ResourceSet) Set ¶
func (r *ResourceSet) Set(value string) error
Set converts a comma-separated string of resources into a slice and appends it to the ResourceSet.
func (*ResourceSet) String ¶
func (r *ResourceSet) String() string
func (*ResourceSet) Type ¶
func (r *ResourceSet) Type() string
Type returns a descriptive string about the ResourceSet type.