// AddFlags adds flags for a specific KubeletServer to the specified FlagSet
func(s*KubeletServer)AddFlags(fs*pflag.FlagSet){
fs.StringVar(&s.Config,"config",s.Config,"Path to the config file or directory of files")
fs.DurationVar(&s.SyncFrequency,"sync_frequency",s.SyncFrequency,"Max period between synchronizing running containers and config")
fs.DurationVar(&s.FileCheckFrequency,"file_check_frequency",s.FileCheckFrequency,"Duration between checking config files for new data")
fs.DurationVar(&s.HTTPCheckFrequency,"http_check_frequency",s.HTTPCheckFrequency,"Duration between checking http for new data")
fs.StringVar(&s.ManifestURL,"manifest_url",s.ManifestURL,"URL for accessing the container manifest")
fs.BoolVar(&s.EnableServer,"enable_server",s.EnableServer,"Enable the info server")
fs.Var(&s.Address,"address","The IP address for the info server to serve on (set to 0.0.0.0 for all interfaces)")
fs.UintVar(&s.Port,"port",s.Port,"The port for the info server to serve on")
fs.StringVar(&s.HostnameOverride,"hostname_override",s.HostnameOverride,"If non-empty, will use this string as identification instead of the actual hostname.")
fs.StringVar(&s.PodInfraContainerImage,"pod_infra_container_image",s.PodInfraContainerImage,"The image whose network/ipc namespaces containers in each pod will use.")
fs.StringVar(&s.DockerEndpoint,"docker_endpoint",s.DockerEndpoint,"If non-empty, use this for the docker endpoint to communicate with")
fs.Var(&s.EtcdServerList,"etcd_servers","List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with -etcd_config")
fs.StringVar(&s.EtcdConfigFile,"etcd_config",s.EtcdConfigFile,"The config file for the etcd client. Mutually exclusive with -etcd_servers")
fs.StringVar(&s.RootDirectory,"root_dir",s.RootDirectory,"Directory path for managing kubelet files (volume mounts,etc).")
fs.BoolVar(&s.AllowPrivileged,"allow_privileged",s.AllowPrivileged,"If true, allow containers to request privileged mode. [default=false]")
fs.Float64Var(&s.RegistryPullQPS,"registry_qps",s.RegistryPullQPS,"If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0]")
fs.IntVar(&s.RegistryBurst,"registry_burst",s.RegistryBurst,"Maximum size of a bursty pulls, temporarily allows pulls to burst to this number, while still not exceeding registry_qps. Only used if --registry_qps > 0")
fs.BoolVar(&s.RunOnce,"runonce",s.RunOnce,"If true, exit after spawning pods from local manifests or remote urls. Exclusive with --etcd_servers, --api_servers, and --enable-server")
fs.BoolVar(&s.EnableDebuggingHandlers,"enable_debugging_handlers",s.EnableDebuggingHandlers,"Enables server endpoints for log collection and local running of containers and commands")
fs.DurationVar(&s.MinimumGCAge,"minimum_container_ttl_duration",s.MinimumGCAge,"Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'")
fs.IntVar(&s.MaxContainerCount,"maximum_dead_containers_per_container",s.MaxContainerCount,"Maximum number of old instances of a container to retain per container. Each container takes up some disk space. Default: 5.")
fs.StringVar(&s.AuthPath,"auth_path",s.AuthPath,"Path to .kubernetes_auth file, specifying how to authenticate to API server.")
fs.UintVar(&s.CAdvisorPort,"cadvisor_port",s.CAdvisorPort,"The port of the localhost cAdvisor endpoint")
fs.IntVar(&s.OOMScoreAdj,"oom_score_adj",s.OOMScoreAdj,"The oom_score_adj value for kubelet process. Values must be within the range [-1000, 1000]")
fs.Var(&s.APIServerList,"api_servers","List of Kubernetes API servers for publishing events, and reading pods and services. (ip:port), comma separated.")
fs.StringVar(&s.ClusterDomain,"cluster_domain",s.ClusterDomain,"Domain for this cluster. If set, kubelet will configure all containers to search this domain in addition to the host's search domains")
fs.StringVar(&s.MasterServiceNamespace,"master_service_namespace",s.MasterServiceNamespace,"The namespace from which the kubernetes master services should be injected into pods")
fs.Var(&s.ClusterDNS,"cluster_dns","IP address for a cluster DNS server. If set, kubelet will configure all containers to use this for DNS resolution in addition to the host's DNS servers")
fs.BoolVar(&s.ReallyCrashForTesting,"really_crash_for_testing",s.ReallyCrashForTesting,"If true, crash with panics more often.")
}
// Run runs the specified KubeletServer. This should never exit.
func(s*KubeletServer)Run(_[]string)error{
util.ReallyCrash=s.ReallyCrashForTesting
rand.Seed(time.Now().UTC().UnixNano())
// Cluster creation scripts support both kubernetes versions that 1)
// support kublet watching apiserver for pods, and 2) ones that don't. So
// they can set both --etcd_servers and --api_servers. The current code
// will ignore the --etcd_servers flag, while older kubelet code will use
// the --etcd_servers flag for pods, and use --api_servers for event
// publising.
//
// TODO(erictune): convert all cloud provider scripts and Google Container Engine to
// use only --api_servers, then delete --etcd_servers flag and the resulting dead code.