// UInt creates a new entry in the flag set with UInt value. // The environment value used as a default, if it exists func UInt(flagName, envName string, value uint, usage string) *uint { verifyNames(flagName, envName) envValStr := lookupEnv(envName) if envValStr != "" { ui64, _ := strconv.ParseUint(envValStr, 10, 64) value = uint(ui64) } flag.Uint(flagName, value, usage) return pflag.Uint(flagName, value, usage) }
"k8s.io/contrib/kubelet-to-gcm/monitor/controller" "k8s.io/contrib/kubelet-to-gcm/monitor/kubelet" ) const ( scope = "https://www.googleapis.com/auth/monitoring.write" //testPath = "https://test-monitoring.sandbox.googleapis.com" ) var ( // Flags to identify the Kubelet. zone = pflag.String("zone", "use-gce", "The zone where this kubelet lives.") project = pflag.String("project", "use-gce", "The project where this kubelet's host lives.") cluster = pflag.String("cluster", "use-gce", "The cluster where this kubelet holds membership.") kubeletHost = pflag.String("kubelet-host", "use-gce", "The kubelet's host name.") kubeletPort = pflag.Uint("kubelet-port", 10255, "The kubelet's port.") ctrlPort = pflag.Uint("controller-manager-port", 10252, "The kube-controller's port.") // Flags to control runtime behavior. res = pflag.Uint("resolution", 10, "The time, in seconds, to poll the Kubelet.") gcmEndpoint = pflag.String("gcm-endpoint", "", "The GCM endpoint to hit. Defaults to the default endpoint.") ) func main() { // First log our starting config, and then set up. flag.Set("logtostderr", "true") // This spoofs glog into teeing logs to stderr. defer log.Flush() pflag.Parse() log.Infof("Invoked by %v", os.Args) resolution := time.Second * time.Duration(*res)
"github.com/kismatic/kubernetes-ldap/auth" "net/http" "net/http/httputil" "net/url" "os" "time" flag "github.com/spf13/pflag" ) const ( usage = "kubernetes-ldap <options>" ReadWriteTimeout = time.Minute * 60 ) var flPort = flag.Uint("port", 4000, "Local port this proxy server will run on") var flInsecure = flag.Bool("ldap-insecure", false, "Disable LDAP TLS") var flLdapHost = flag.String("ldap-host", "", "Host or IP of the LDAP server") var flLdapPort = flag.Uint("ldap-port", 389, "LDAP server port") var flBaseDN = flag.String("ldap-base-dn", "", "LDAP user base DN in the form 'dc=example,dc=com'") var flUserLoginAttribute = flag.String("ldap-user-attribute", "uid", "LDAP Username attribute for login") var flSearchUserDN = flag.String("ldap-search-user-dn", "", "Search user DN for this app to find users (e.g.: cn=admin,dc=example,dc=com).") var flSearchUserPassword = flag.String("ldap-search-user-password", "", "Search user password") var flTLSCertFile = flag.String("tls-cert-file", "", "File containing x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert).") var flTLSPrivateKeyFile = flag.String("tls-private-key-file", "", "File containing x509 private key matching --tls-cert-file.") var flCertDirectory = flag.String("cert-dir", "", "The directory where the TLS certs are located (by default /var/run/kubernetes). "+ "If --tls-cert-file and --tls-private-key-file are provided, this flag will be ignored.")
) const ( gceMDEndpoint = "http://169.254.169.254" gceMDPrefix = "/computeMetadata/v1" scope = "https://www.googleapis.com/auth/monitoring.write" //testPath = "https://test-monitoring.sandbox.googleapis.com" ) var ( // Flags to identify the Kubelet. zoneArg = pflag.String("zone", "use-gce", "The zone where this kubelet lives.") projectArg = pflag.String("project", "use-gce", "The project where this kubelet's host lives.") clusterArg = pflag.String("cluster", "use-gce", "The cluster where this kubelet holds membership.") kubeletHostArg = pflag.String("kubelet-host", "use-gce", "The kubelet's host name.") port = pflag.Uint("kubelet-port", 10255, "The kubelet's port.") // Flags to control runtime behavior. resolutionArg = pflag.Uint("resolution", 10, "The time, in seconds, to poll the Kubelet.") gcmEndpoint = pflag.String("gcm-endpoint", "", "The GCM endpoint to hit. Defaults to the default endpoint.") ) // metadataURI returns the full URI for the desired resource func metadataURI(resource string) string { return gceMDEndpoint + gceMDPrefix + resource } // getGCEMetaData hits the instance's MD server. func getGCEMetaData(uri string) ([]byte, error) { client := &http.Client{} req, err := http.NewRequest("GET", uri, nil) if err != nil {
"github.com/golang/glog" flag "github.com/spf13/pflag" ) const defaultRootDir = "/var/lib/kubelet" var ( config = flag.String("config", "", "Path to the config file or directory of files") syncFrequency = flag.Duration("sync_frequency", 10*time.Second, "Max period between synchronizing running containers and config") fileCheckFrequency = flag.Duration("file_check_frequency", 20*time.Second, "Duration between checking config files for new data") httpCheckFrequency = flag.Duration("http_check_frequency", 20*time.Second, "Duration between checking http for new data") manifestURL = flag.String("manifest_url", "", "URL for accessing the container manifest") enableServer = flag.Bool("enable_server", true, "Enable the info server") address = util.IP(net.ParseIP("127.0.0.1")) port = flag.Uint("port", ports.KubeletPort, "The port for the info server to serve on") hostnameOverride = flag.String("hostname_override", "", "If non-empty, will use this string as identification instead of the actual hostname.") networkContainerImage = flag.String("network_container_image", kubelet.NetworkContainerImage, "The image that network containers in each pod will use.") dockerEndpoint = flag.String("docker_endpoint", "", "If non-empty, use this for the docker endpoint to communicate with") etcdServerList util.StringList etcdConfigFile = flag.String("etcd_config", "", "The config file for the etcd client. Mutually exclusive with -etcd_servers") rootDirectory = flag.String("root_dir", defaultRootDir, "Directory path for managing kubelet files (volume mounts,etc).") allowPrivileged = flag.Bool("allow_privileged", false, "If true, allow containers to request privileged mode. [default=false]") registryPullQPS = flag.Float64("registry_qps", 0.0, "If > 0, limit registry pull QPS to this value. If 0, unlimited. [default=0.0]") registryBurst = flag.Int("registry_burst", 10, "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") runonce = flag.Bool("runonce", false, "If true, exit after spawning pods from local manifests or remote urls. Exclusive with --etcd_servers, --api_servers, and --enable-server") enableDebuggingHandlers = flag.Bool("enable_debugging_handlers", true, "Enables server endpoints for log collection and local running of containers and commands") minimumGCAge = flag.Duration("minimum_container_ttl_duration", 1*time.Minute, "Minimum age for a finished container before it is garbage collected. Examples: '300ms', '10s' or '2h45m'") maxContainerCount = flag.Int("maximum_dead_containers_per_container", 5, "Maximum number of old instances of a container to retain per container. Each container takes up some disk space. Default: 5.") authPath = flag.String("auth_path", "", "Path to .kubernetes_auth file, specifying how to authenticate to API server.") cAdvisorPort = flag.Uint("cadvisor_port", 4194, "The port of the localhost cAdvisor endpoint")
v3 "google.golang.org/api/monitoring/v3" "k8s.io/contrib/kubelet-to-gcm/monitor" ) const ( scope = "https://www.googleapis.com/auth/monitoring.write" //testPath = "https://test-monitoring.sandbox.googleapis.com" ) var ( // Flags to identify the Kubelet. zoneArg = pflag.String("zone", "", "The zone where this kubelet lives.") projectArg = pflag.String("project", "", "The project where this kubelet's host lives.") cluster = pflag.String("cluster", "unknown", "The cluster where this kubelet holds membership.") host = pflag.String("host", "localhost", "The kubelet's host name.") port = pflag.Uint("port", 10255, "The kubelet's port.") // Flags to control runtime behavior. resolution = time.Second * time.Duration(*pflag.Uint("resolution", 10, "The time, in seconds, to poll the Kubelet.")) gcmEndpoint = pflag.String("gcm-endpoint", "", "The GCM endpoint to hit. Defaults to the default endpoint.") ) // getGCEMetaData hits the instance's MD server. func getGCEMetaData(uri string) ([]byte, error) { client := &http.Client{} req, err := http.NewRequest("GET", uri, nil) if err != nil { return nil, fmt.Errorf("Failed to create request %q for GCE metadata: %v", uri, err) } req.Header.Add("Metadata-Flavor", "Google") resp, err := client.Do(req) if err != nil {