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
func FetchLoadInstructions(shell string) string
FetchLoadInstructions returns instructions for enabling autocompletion for a particular shell.
func GetConfigFile ¶ added in v2.8.0
func GetConfigFile(opt Options) string
GetConfigFile is the getter for --config value.
func MergeFieldSelectors ¶ added in v2.7.0
func MergeFieldSelectors(selectors []string) (string, error)
MergeFieldSelectors returns AND of a list of field selectors.
func MergeTwoFieldSelectors ¶ added in v2.7.0
func MergeTwoFieldSelectors(s1 string, s2 string) (string, error)
MergeTwoFieldSelectors returns AND of two field selectors.
Types ¶
type LabelsAllowList ¶
type LabelsAllowList map[string][]string
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]
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.
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
func (n *NodeType) GetNodeFieldSelector() string
GetNodeFieldSelector returns a nodename field selector.
type Options ¶
type Options struct {
AnnotationsAllowList LabelsAllowList `yaml:"annotations_allow_list"`
LabelsAllowList LabelsAllowList `yaml:"labels_allow_list"`
MetricAllowlist MetricSet `yaml:"metric_allowlist"`
MetricDenylist MetricSet `yaml:"metric_denylist"`
MetricOptInList MetricSet `yaml:"metric_opt_in_list"`
Resources ResourceSet `yaml:"resources"`
Apiserver string `yaml:"apiserver"`
CustomResourceConfig string `yaml:"custom_resource_config"`
CustomResourceConfigFile string `yaml:"custom_resource_config_file"`
Host string `yaml:"host"`
Kubeconfig string `yaml:"kubeconfig"`
Namespace string `yaml:"namespace"`
Node NodeType `yaml:"node"`
Pod string `yaml:"pod"`
TLSConfig string `yaml:"tls_config"`
TelemetryHost string `yaml:"telemetry_host"`
Config string
Namespaces NamespaceList `yaml:"namespaces"`
NamespacesDenylist NamespaceList `yaml:"namespaces_denylist"`
AutoGoMemlimitRatio float64 `yaml:"auto-gomemlimit-ratio"`
Port int `yaml:"port"`
TelemetryPort int `yaml:"telemetry_port"`
TotalShards int `yaml:"total_shards"`
ServerReadTimeout time.Duration `yaml:"server_read_timeout"`
ServerWriteTimeout time.Duration `yaml:"server_write_timeout"`
ServerIdleTimeout time.Duration `yaml:"server_idle_timeout"`
ServerReadHeaderTimeout time.Duration `yaml:"server_read_header_timeout"`
Shard int32 `yaml:"shard"`
AutoGoMemlimit bool `yaml:"auto-gomemlimit"`
CustomResourcesOnly bool `yaml:"custom_resources_only"`
EnableGZIPEncoding bool `yaml:"enable_gzip_encoding"`
Help bool `yaml:"help"`
TrackUnscheduledPods bool `yaml:"track_unscheduled_pods"`
UseAPIServerCache bool `yaml:"use_api_server_cache"`
// contains filtered or unexported fields
}
Options are the configurable parameters for kube-state-metrics.
func (*Options) AddFlags ¶
func (o *Options) AddFlags(cmd *cobra.Command)
AddFlags populated the Options struct from the command line arguments passed.
func (*Options) Parse ¶
func (o *Options) Parse() error
Parse parses the flag definitions from the argument list.
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.