github.com/galamsiva2020/kubernetes-heapster-monitoring@v0.0.0-20210823134957-3c1baa7c1e70/metrics/options/options.go (about) 1 // Copyright 2016 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package options 16 17 import ( 18 "time" 19 20 "github.com/spf13/pflag" 21 22 genericoptions "k8s.io/apiserver/pkg/server/options" 23 "k8s.io/heapster/common/flags" 24 ) 25 26 type HeapsterRunOptions struct { 27 // genericoptions.ReccomendedOptions - EtcdOptions 28 SecureServing *genericoptions.SecureServingOptions 29 Authentication *genericoptions.DelegatingAuthenticationOptions 30 Authorization *genericoptions.DelegatingAuthorizationOptions 31 Features *genericoptions.FeatureOptions 32 33 // Only to be used to for testing 34 DisableAuthForTesting bool 35 36 MetricResolution time.Duration 37 EnableAPIServer bool 38 Port int 39 Ip string 40 MaxProcs int 41 TLSCertFile string 42 TLSKeyFile string 43 TLSClientCAFile string 44 AllowedUsers string 45 Sources flags.Uris 46 Sinks flags.Uris 47 HistoricalSource string 48 Version bool 49 LabelSeparator string 50 IgnoredLabels []string 51 StoredLabels []string 52 DisableMetricExport bool 53 SinkExportDataTimeout time.Duration 54 DisableMetricSink bool 55 } 56 57 func NewHeapsterRunOptions() *HeapsterRunOptions { 58 return &HeapsterRunOptions{ 59 SecureServing: genericoptions.NewSecureServingOptions(), 60 Authentication: genericoptions.NewDelegatingAuthenticationOptions(), 61 Authorization: genericoptions.NewDelegatingAuthorizationOptions(), 62 Features: genericoptions.NewFeatureOptions(), 63 } 64 } 65 66 func (h *HeapsterRunOptions) AddFlags(fs *pflag.FlagSet) { 67 h.SecureServing.AddFlags(fs) 68 h.Authentication.AddFlags(fs) 69 h.Authorization.AddFlags(fs) 70 h.Features.AddFlags(fs) 71 72 fs.Var(&h.Sources, "source", "source(s) to watch") 73 fs.Var(&h.Sinks, "sink", "external sink(s) that receive data") 74 fs.DurationVar(&h.MetricResolution, "metric_resolution", 60*time.Second, "The resolution at which heapster will retain metrics.") 75 76 // TODO: Revise these flags before Heapster v1.3 and Kubernetes v1.5 77 fs.BoolVar(&h.EnableAPIServer, "api-server", false, "Enable API server for the Metrics API. "+ 78 "If set, the Metrics API will be served on --insecure-port (internally) and --secure-port (externally).") 79 fs.IntVar(&h.Port, "heapster-port", 8082, "port used by the Heapster-specific APIs") 80 81 fs.StringVar(&h.Ip, "listen_ip", "", "IP to listen on, defaults to all IPs") 82 fs.IntVar(&h.MaxProcs, "max_procs", 0, "max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores)") 83 fs.StringVar(&h.TLSCertFile, "tls_cert", "", "file containing TLS certificate") 84 fs.StringVar(&h.TLSKeyFile, "tls_key", "", "file containing TLS key") 85 fs.StringVar(&h.TLSClientCAFile, "tls_client_ca", "", "file containing TLS client CA for client cert validation") 86 fs.StringVar(&h.AllowedUsers, "allowed_users", "", "comma-separated list of allowed users") 87 fs.StringVar(&h.HistoricalSource, "historical_source", "", "which source type to use for the historical API (should be exactly the same as one of the sink URIs), or empty to disable the historical API") 88 fs.BoolVar(&h.Version, "version", false, "print version info and exit") 89 fs.StringVar(&h.LabelSeparator, "label_separator", ",", "separator used for joining labels") 90 fs.StringSliceVar(&h.IgnoredLabels, "ignore_label", []string{}, "ignore this label when joining labels") 91 fs.StringSliceVar(&h.StoredLabels, "store_label", []string{}, "store this label separately from joined labels with the same name (name) or with different name (newName=name)") 92 fs.BoolVar(&h.DisableMetricExport, "disable_export", false, "Disable exporting metrics in api/v1/metric-export") 93 fs.DurationVar(&h.SinkExportDataTimeout, "sink_export_data_timeout", 20*time.Second, "Timeout for exporting data to a sink") 94 fs.BoolVar(&h.DisableMetricSink, "disable_metric_sink", false, "Disable metric sink") 95 }