Skip to content

Commit 5888a7e

Browse files
committed
Add --config flag
--config flag defines the path to the kube-state-metrics options config file.
1 parent 53a0dc6 commit 5888a7e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/options/options.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ type Options struct {
4545
TotalShards int
4646
Pod string
4747
Namespace string
48-
MetricDenylist MetricSet
49-
MetricAllowlist MetricSet
48+
MetricDenylist MetricSet `yaml:"metric_denylist"`
49+
MetricAllowlist MetricSet `yaml:"metric_allowlist"`
5050
MetricOptInList MetricSet
5151
Version bool
5252
AnnotationsAllowList LabelsAllowList
@@ -60,6 +60,8 @@ type Options struct {
6060
CustomResourceConfigFile string
6161
CustomResourcesOnly bool
6262

63+
optsConfigFile string
64+
6365
cmd *cobra.Command
6466
}
6567

@@ -133,6 +135,7 @@ func (o *Options) AddFlags(cmd *cobra.Command) {
133135
o.cmd.Flags().StringVar(&o.Pod, "pod", "", "Name of the pod that contains the kube-state-metrics container. "+autoshardingNotice)
134136
o.cmd.Flags().StringVar(&o.TLSConfig, "tls-config", "", "Path to the TLS configuration file")
135137
o.cmd.Flags().StringVar(&o.TelemetryHost, "telemetry-host", "::", `Host to expose kube-state-metrics self metrics on.`)
138+
o.cmd.Flags().StringVar(&o.optsConfigFile, "options-config-file", "", "Path to the kube-state-metrics options config file")
136139
o.cmd.Flags().StringVar((*string)(&o.Node), "node", "", "Name of the node that contains the kube-state-metrics pod. Most likely it should be passed via the downward API. This is used for daemonset sharding. Only available for resources (pod metrics) that support spec.nodeName fieldSelector. This is experimental.")
137140
o.cmd.Flags().Var(&o.AnnotationsAllowList, "metric-annotations-allowlist", "Comma-separated list of Kubernetes annotations keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional annotations provide a list of resource names in their plural form and Kubernetes annotation keys you would like to allow for them (Example: '=namespaces=[kubernetes.io/team,...],pods=[kubernetes.io/team],...)'. A single '*' can be provided per resource instead to allow any annotations, but that has severe performance implications (Example: '=pods=[*]').")
138141
o.cmd.Flags().Var(&o.LabelsAllowList, "metric-labels-allowlist", "Comma-separated list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...)'. A single '*' can be provided per resource instead to allow any labels, but that has severe performance implications (Example: '=pods=[*]'). Additionally, an asterisk (*) can be provided as a key, which will resolve to all resources, i.e., assuming '--resources=deployments,pods', '=*=[*]' will resolve to '=deployments=[*],pods=[*]'.")

0 commit comments

Comments
 (0)