github.com/jonaz/heapster@v1.3.0-beta.0.0.20170208112634-cd3c15ca3d29/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  	"k8s.io/heapster/common/flags"
    23  	genericoptions "k8s.io/kubernetes/pkg/genericapiserver/options"
    24  )
    25  
    26  type HeapsterRunOptions struct {
    27  	*genericoptions.ServerRunOptions
    28  	MetricResolution time.Duration
    29  	EnableAPIServer  bool
    30  	Port             int
    31  	Ip               string
    32  	MaxProcs         int
    33  	TLSCertFile      string
    34  	TLSKeyFile       string
    35  	TLSClientCAFile  string
    36  	AllowedUsers     string
    37  	Sources          flags.Uris
    38  	Sinks            flags.Uris
    39  	HistoricalSource string
    40  	Version          bool
    41  	LabelSeperator   string
    42  }
    43  
    44  func NewHeapsterRunOptions() *HeapsterRunOptions {
    45  	opt := genericoptions.NewServerRunOptions()
    46  	return &HeapsterRunOptions{
    47  		ServerRunOptions: opt,
    48  	}
    49  }
    50  
    51  func (h *HeapsterRunOptions) AddFlags(fs *pflag.FlagSet) {
    52  	h.ServerRunOptions.AddUniversalFlags(pflag.CommandLine)
    53  
    54  	fs.Var(&h.Sources, "source", "source(s) to watch")
    55  	fs.Var(&h.Sinks, "sink", "external sink(s) that receive data")
    56  	fs.DurationVar(&h.MetricResolution, "metric_resolution", 60*time.Second, "The resolution at which heapster will retain metrics.")
    57  
    58  	// TODO: Revise these flags before Heapster v1.3 and Kubernetes v1.5
    59  	fs.BoolVar(&h.EnableAPIServer, "api-server", false, "Enable API server for the Metrics API. "+
    60  		"If set, the Metrics API will be served on --insecure-port (internally) and --secure-port (externally).")
    61  	fs.IntVar(&h.Port, "heapster-port", 8082, "port used by the Heapster-specific APIs")
    62  
    63  	fs.StringVar(&h.Ip, "listen_ip", "", "IP to listen on, defaults to all IPs")
    64  	fs.IntVar(&h.MaxProcs, "max_procs", 0, "max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores)")
    65  	fs.StringVar(&h.TLSCertFile, "tls_cert", "", "file containing TLS certificate")
    66  	fs.StringVar(&h.TLSKeyFile, "tls_key", "", "file containing TLS key")
    67  	fs.StringVar(&h.TLSClientCAFile, "tls_client_ca", "", "file containing TLS client CA for client cert validation")
    68  	fs.StringVar(&h.AllowedUsers, "allowed_users", "", "comma-separated list of allowed users")
    69  	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")
    70  	fs.BoolVar(&h.Version, "version", false, "print version info and exit")
    71  	fs.StringVar(&h.LabelSeperator, "label_seperator", ",", "seperator used for joining labels")
    72  }