options

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: Apache-2.0 Imports: 11 Imported by: 10

Documentation

Index

Constants

View Source
const LabelWildcard = "*"

LabelWildcard allowlists any label

Variables

View Source
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{}{},
	}
)
View Source
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]

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.

func (*MetricSet) Set

func (ms *MetricSet) Set(value string) error

Set converts a comma-separated string of metrics into a slice and appends it to the MetricSet.

func (*MetricSet) String

func (ms *MetricSet) String() string

func (*MetricSet) Type

func (ms *MetricSet) Type() string

Type returns a descriptive string about the MetricSet type.

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

func (n *NodeType) GetNodeFieldSelector() string

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 NewOptions

func NewOptions() *Options

NewOptions returns a new instance of `Options`.

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.

func (*Options) Usage

func (o *Options) Usage()

Usage is the function called when an error occurs while parsing flags.

func (*Options) Validate added in v2.7.0

func (o *Options) Validate() error

Validate validates arguments

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.

Jump to

Keyboard shortcuts

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