├── .gitignore ├── provider ├── mock │ ├── mock_test.go │ └── mock.go ├── README.md ├── doc.go ├── types.go ├── provider.go └── store.go ├── doc.go ├── logrus ├── flags.go └── init.go ├── internal └── commands │ ├── version │ └── version.go │ ├── providers │ └── provider.go │ └── root │ ├── flag.go │ ├── node.go │ ├── http.go │ └── root.go ├── go.mod ├── README.md ├── opencensus ├── flags.go └── init.go ├── manager └── resource.go ├── opts └── opts.go ├── cli.go └── go.sum /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /provider/mock/mock_test.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | // We can guarantee the right interfaces are implemented inside of by putting casts in place. We must do the verification 4 | // that a given type *does not* implement a given interface in this test. 5 | // Cannot implement this due to: https://github.com/virtual-kubelet/virtual-kubelet/issues/632 6 | /* 7 | func TestMockLegacyInterface(t *testing.T) { 8 | var mlp providers.Provider = &MockLegacyProvider{} 9 | _, ok := mlp.(node.PodNotifier) 10 | assert.Assert(t, !ok) 11 | } 12 | */ 13 | -------------------------------------------------------------------------------- /provider/README.md: -------------------------------------------------------------------------------- 1 | Follow these steps to be accepted as a provider within the Virtual Kubelet repo. 2 | 3 | 1. Replicate the life-cycle of a pod for example creation and deletion of a pod and how that maps to your service. 4 | 2. Create a new provider folder with a descriptive name and the necessary code. 5 | 3. When committing your code add a README.md, helm chart, dockerfile and specify a maintainer of the provider. 6 | 4. Within the PR itself add a justification for why the provider should be accepted, as well as customer use cases if applicable. 7 | 8 | Some providers are translations of Virtual Kubelet to allow others to adapt their service or applications that are written in other languages. 9 | 10 | 11 | -------------------------------------------------------------------------------- /provider/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 provider has the interfaces used by the the cli implementing a node 16 | package provider 17 | -------------------------------------------------------------------------------- /provider/types.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | const ( 4 | // OperatingSystemLinux is the configuration value for defining Linux. 5 | OperatingSystemLinux = "Linux" 6 | // OperatingSystemWindows is the configuration value for defining Windows. 7 | OperatingSystemWindows = "Windows" 8 | ) 9 | 10 | type OperatingSystems map[string]bool 11 | 12 | var ( 13 | // ValidOperatingSystems defines the group of operating systems 14 | // that can be used as a kubelet node. 15 | ValidOperatingSystems = OperatingSystems{ 16 | OperatingSystemLinux: true, 17 | OperatingSystemWindows: true, 18 | } 19 | ) 20 | 21 | func (o OperatingSystems) Names() []string { 22 | keys := make([]string, 0, len(o)) 23 | for k := range o { 24 | keys = append(keys, k) 25 | } 26 | return keys 27 | } 28 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 cli contains a reusable implemetation for a daemon that acts as a 16 | // single node on the cluster. 17 | package cli 18 | -------------------------------------------------------------------------------- /logrus/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 logrus 16 | 17 | import ( 18 | "github.com/spf13/pflag" 19 | ) 20 | 21 | // Config is used to configure a logrus logger from CLI flags. 22 | type Config struct { 23 | LogLevel string 24 | } 25 | 26 | // FlagSet creates a new flag set based on the current config 27 | func (c *Config) FlagSet() *pflag.FlagSet { 28 | flags := pflag.NewFlagSet("logrus", pflag.ContinueOnError) 29 | flags.StringVar(&c.LogLevel, "log-level", c.LogLevel, `set the log level, e.g. "debug", "info", "warn", "error"`) 30 | return flags 31 | } 32 | -------------------------------------------------------------------------------- /internal/commands/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 version 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/spf13/cobra" 21 | ) 22 | 23 | // NewCommand creates a new version subcommand command 24 | func NewCommand(version, buildTime string) *cobra.Command { 25 | return &cobra.Command{ 26 | Use: "version", 27 | Short: "Show the version of the program", 28 | Long: `Show the version of the program`, 29 | Run: func(cmd *cobra.Command, args []string) { 30 | fmt.Printf("Version: %s, Built: %s\n", version, buildTime) 31 | }, 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /logrus/init.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 logrus 16 | 17 | import ( 18 | "github.com/pkg/errors" 19 | "github.com/sirupsen/logrus" 20 | "github.com/virtual-kubelet/virtual-kubelet/errdefs" 21 | ) 22 | 23 | // Configure sets up the logrus logger 24 | func Configure(c *Config, logger *logrus.Logger) error { 25 | if c.LogLevel != "" { 26 | lvl, err := logrus.ParseLevel(c.LogLevel) 27 | if err != nil { 28 | return errdefs.AsInvalidInput(errors.Wrap(err, "error parsing log level")) 29 | } 30 | 31 | if logger == nil { 32 | logger = logrus.StandardLogger() 33 | } 34 | logger.SetLevel(lvl) 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/virtual-kubelet/node-cli 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/google/btree v1.0.0 // indirect 7 | github.com/gorilla/mux v1.7.3 // indirect 8 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect 9 | github.com/imdario/mergo v0.3.7 // indirect 10 | github.com/mitchellh/go-homedir v1.1.0 11 | github.com/modern-go/reflect2 v1.0.1 // indirect 12 | github.com/pborman/uuid v1.2.0 // indirect 13 | github.com/peterbourgon/diskv v2.0.1+incompatible // indirect 14 | github.com/pkg/errors v0.8.1 15 | github.com/sirupsen/logrus v1.4.2 16 | github.com/spf13/cobra v0.0.5 17 | github.com/spf13/pflag v1.0.3 18 | github.com/virtual-kubelet/virtual-kubelet v1.2.1-0.20200320212802-3ec3b14e49d0 19 | go.opencensus.io v0.21.0 20 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a // indirect 21 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db // indirect 22 | k8s.io/api v0.0.0 23 | k8s.io/apimachinery v0.0.0 24 | k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421 // indirect 25 | k8s.io/client-go v10.0.0+incompatible 26 | k8s.io/klog v0.3.1 27 | k8s.io/kubernetes v1.15.2 28 | k8s.io/utils v0.0.0-20180801164400-045dc31ee5c4 // indirect 29 | sigs.k8s.io/yaml v1.1.0 // indirect 30 | ) 31 | 32 | replace k8s.io/client-go => k8s.io/client-go v0.0.0-20190521190702-177766529176 33 | 34 | replace k8s.io/api => k8s.io/api v0.0.0-20190222213804-5cb15d344471 35 | 36 | replace k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 37 | 38 | replace k8s.io/kubernetes => k8s.io/kubernetes v1.13.7 39 | -------------------------------------------------------------------------------- /provider/provider.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "context" 5 | "io" 6 | 7 | "github.com/virtual-kubelet/virtual-kubelet/node" 8 | "github.com/virtual-kubelet/virtual-kubelet/node/api" 9 | v1 "k8s.io/api/core/v1" 10 | stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1" 11 | ) 12 | 13 | // Provider contains the methods required to implement a virtual-kubelet provider. 14 | // 15 | // Errors produced by these methods should implement an interface from 16 | // github.com/virtual-kubelet/virtual-kubelet/errdefs package in order for the 17 | // core logic to be able to understand the type of failure. 18 | type Provider interface { 19 | node.PodLifecycleHandler 20 | node.NodeProvider 21 | 22 | // GetContainerLogs retrieves the logs of a container by name from the provider. 23 | GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error) 24 | 25 | // RunInContainer executes a command in a container in the pod, copying data 26 | // between in/out/err and the container's stdin/stdout/stderr. 27 | RunInContainer(ctx context.Context, namespace, podName, containerName string, cmd []string, attach api.AttachIO) error 28 | 29 | // ConfigureNode enables a provider to configure the node object that 30 | // will be used for Kubernetes. 31 | ConfigureNode(context.Context, *v1.Node) 32 | } 33 | 34 | // PodMetricsProvider is an optional interface that providers can implement to expose pod stats 35 | type PodMetricsProvider interface { 36 | GetStatsSummary(context.Context) (*stats.Summary, error) 37 | } 38 | -------------------------------------------------------------------------------- /provider/store.go: -------------------------------------------------------------------------------- 1 | package provider 2 | 3 | import ( 4 | "sync" 5 | 6 | "github.com/virtual-kubelet/node-cli/manager" 7 | ) 8 | 9 | // Store is used for registering/fetching providers 10 | type Store struct { 11 | mu sync.Mutex 12 | ls map[string]InitFunc 13 | } 14 | 15 | func NewStore() *Store { 16 | return &Store{ 17 | ls: make(map[string]InitFunc), 18 | } 19 | } 20 | 21 | // Register registers a providers init func by name 22 | func (s *Store) Register(name string, f InitFunc) { 23 | s.mu.Lock() 24 | s.ls[name] = f 25 | s.mu.Unlock() 26 | } 27 | 28 | // Get gets the registered init func for the given name 29 | // The returned function may be nil if the given name is not registered. 30 | func (s *Store) Get(name string) InitFunc { 31 | s.mu.Lock() 32 | f := s.ls[name] 33 | s.mu.Unlock() 34 | return f 35 | } 36 | 37 | // List lists all the registered providers 38 | func (s *Store) List() []string { 39 | s.mu.Lock() 40 | defer s.mu.Unlock() 41 | 42 | ls := make([]string, 0, len(s.ls)) 43 | for p := range s.ls { 44 | ls = append(ls, p) 45 | } 46 | 47 | return ls 48 | } 49 | 50 | // Exists returns if there is an init function registered under the provided name 51 | func (s *Store) Exists(name string) bool { 52 | s.mu.Lock() 53 | _, ok := s.ls[name] 54 | s.mu.Unlock() 55 | return ok 56 | } 57 | 58 | // InitConfig is the config passed to initialize a registered provider. 59 | type InitConfig struct { 60 | ConfigPath string 61 | NodeName string 62 | OperatingSystem string 63 | InternalIP string 64 | DaemonPort int32 65 | KubeClusterDomain string 66 | ResourceManager *manager.ResourceManager 67 | } 68 | 69 | type InitFunc func(InitConfig) (Provider, error) 70 | -------------------------------------------------------------------------------- /internal/commands/providers/provider.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 providers 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/spf13/cobra" 22 | "github.com/virtual-kubelet/node-cli/provider" 23 | ) 24 | 25 | // NewCommand creates a new providers subcommand 26 | // This subcommand is used to determine which providers are registered. 27 | func NewCommand(s *provider.Store) *cobra.Command { 28 | return &cobra.Command{ 29 | Use: "providers", 30 | Short: "Show the list of supported providers", 31 | Long: "Show the list of supported providers", 32 | Args: cobra.MaximumNArgs(2), 33 | Run: func(cmd *cobra.Command, args []string) { 34 | switch len(args) { 35 | case 0: 36 | for _, p := range s.List() { 37 | fmt.Fprintln(cmd.OutOrStdout(), p) 38 | } 39 | case 1: 40 | if !s.Exists(args[0]) { 41 | fmt.Fprintln(cmd.OutOrStderr(), "no such provider", args[0]) 42 | 43 | // TODO(@cpuuy83): would be nice to not short-circuit the exit here 44 | // But at the momemt this seems to be the only way to exit non-zero and 45 | // handle our own error output 46 | os.Exit(1) 47 | } 48 | fmt.Fprintln(cmd.OutOrStdout(), args[0]) 49 | } 50 | return 51 | }, 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Virtual-Kubelet CLI 2 | ================== 3 | 4 | This project provides a library for rapid prototyping of a virtual-kubelet node. 5 | It is not intended for production use and may have breaking changes, 6 | but takes as much as made sense from the old command line code from 7 | [github.com/virtual-kubelet/virtual-kubelet][vk]. 8 | 9 | [vk]: https://github.com/virtual-kubelet/virtual-kubelet 10 | 11 | 12 | ## Usage 13 | 14 | ```go 15 | package main 16 | 17 | import ( 18 | "context" 19 | "errors" 20 | 21 | "github.com/sirupsen/logrus" 22 | cli "github.com/virtual-kubelet/node-cli" 23 | logruscli "github.com/virtual-kubelet/node-cli/logrus" 24 | "github.com/virtual-kubelet/node-cli/provider" 25 | "github.com/virtual-kubelet/virtual-kubelet/log" 26 | logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus" 27 | ) 28 | 29 | func main() { 30 | ctx := cli.ContextWithCancelOnSignal(context.Background()) 31 | logger := logrus.StandardLogger() 32 | 33 | log.L = logruslogger.FromLogrus(logrus.NewEntry(logger)) 34 | logConfig := &logruscli.Config{LogLevel: "info"} 35 | 36 | node, err := cli.New(ctx, 37 | cli.WithProvider("demo", func(cfg provider.InitConfig) (provider.Provider, error) { 38 | return nil, errors.New("your implementation goes here") 39 | }), 40 | // Adds flags and parsing for using logrus as the configured logger 41 | cli.WithPersistentFlags(logConfig.FlagSet()), 42 | cli.WithPersistentPreRunCallback(func() error { 43 | return logruscli.Configure(logConfig, logger) 44 | }), 45 | ) 46 | 47 | if err != nil { 48 | panic(err) 49 | } 50 | 51 | // Notice that the context is not passed in here, this is due to limitations 52 | // of the underlying CLI library (cobra). 53 | // contexts get passed through from `cli.New()` 54 | // 55 | // Args can be specified here, or os.Args[1:] will be used. 56 | if err := node.Run(); err != nil { 57 | panic(err) 58 | } 59 | } 60 | ``` 61 | -------------------------------------------------------------------------------- /opencensus/flags.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 opencensus 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/spf13/pflag" 22 | ) 23 | 24 | // Config is used to configured a tracer. 25 | type Config struct { 26 | SampleRate string 27 | ServiceName string 28 | Tags map[string]string 29 | Exporters []string 30 | AvailableExporters map[string]ExporterInitFunc 31 | ZpagesAddr string 32 | } 33 | 34 | func FromEnv() *Config { 35 | return &Config{ZpagesAddr: os.Getenv("ZPAGES_ADDR")} 36 | } 37 | 38 | // FlagSet creates a new flag set based on the current config 39 | func (c *Config) FlagSet() *pflag.FlagSet { 40 | if len(c.AvailableExporters) == 0 { 41 | return nil 42 | } 43 | 44 | flags := pflag.NewFlagSet("opencensus", pflag.ContinueOnError) 45 | 46 | exporters := make([]string, 0, len(c.AvailableExporters)) 47 | for e := range c.AvailableExporters { 48 | exporters = append(exporters, e) 49 | } 50 | 51 | flags.StringSliceVar(&c.Exporters, "trace-exporter", c.Exporters, fmt.Sprintf("sets the tracing exporter to use, available exporters: %s", exporters)) 52 | flags.StringVar(&c.ServiceName, "trace-service-name", c.ServiceName, "sets the name of the service used to register with the trace exporter") 53 | flags.StringToStringVar(&c.Tags, "trace-tag", c.Tags, "add tags to include with traces in key=value form") 54 | flags.StringVar(&c.SampleRate, "trace-sample-rate", c.SampleRate, "set probability of tracing samples") 55 | flags.StringVar(&c.ZpagesAddr, "trace-zpages-addr", c.ZpagesAddr, "set the listen address to use for zpages") 56 | 57 | return flags 58 | } 59 | -------------------------------------------------------------------------------- /manager/resource.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 manager 16 | 17 | import ( 18 | v1 "k8s.io/api/core/v1" 19 | "k8s.io/apimachinery/pkg/labels" 20 | corev1listers "k8s.io/client-go/listers/core/v1" 21 | 22 | "github.com/virtual-kubelet/virtual-kubelet/log" 23 | ) 24 | 25 | // ResourceManager acts as a passthrough to a cache (lister) for pods assigned to the current node. 26 | // It is also a passthrough to a cache (lister) for Kubernetes secrets and config maps. 27 | type ResourceManager struct { 28 | podLister corev1listers.PodLister 29 | secretLister corev1listers.SecretLister 30 | configMapLister corev1listers.ConfigMapLister 31 | serviceLister corev1listers.ServiceLister 32 | } 33 | 34 | // NewResourceManager returns a ResourceManager with the internal maps initialized. 35 | func NewResourceManager(podLister corev1listers.PodLister, secretLister corev1listers.SecretLister, configMapLister corev1listers.ConfigMapLister, serviceLister corev1listers.ServiceLister) (*ResourceManager, error) { 36 | rm := ResourceManager{ 37 | podLister: podLister, 38 | secretLister: secretLister, 39 | configMapLister: configMapLister, 40 | serviceLister: serviceLister, 41 | } 42 | return &rm, nil 43 | } 44 | 45 | // GetPods returns a list of all known pods assigned to this virtual node. 46 | func (rm *ResourceManager) GetPods() []*v1.Pod { 47 | l, err := rm.podLister.List(labels.Everything()) 48 | if err == nil { 49 | return l 50 | } 51 | log.L.Errorf("failed to fetch pods from lister: %v", err) 52 | return make([]*v1.Pod, 0) 53 | } 54 | 55 | // GetConfigMap retrieves the specified config map from the cache. 56 | func (rm *ResourceManager) GetConfigMap(name, namespace string) (*v1.ConfigMap, error) { 57 | return rm.configMapLister.ConfigMaps(namespace).Get(name) 58 | } 59 | 60 | // GetSecret retrieves the specified secret from Kubernetes. 61 | func (rm *ResourceManager) GetSecret(name, namespace string) (*v1.Secret, error) { 62 | return rm.secretLister.Secrets(namespace).Get(name) 63 | } 64 | 65 | // ListServices retrieves the list of services from Kubernetes. 66 | func (rm *ResourceManager) ListServices() ([]*v1.Service, error) { 67 | return rm.serviceLister.List(labels.Everything()) 68 | } 69 | 70 | -------------------------------------------------------------------------------- /internal/commands/root/flag.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 root 16 | 17 | import ( 18 | "flag" 19 | "os" 20 | 21 | "github.com/spf13/pflag" 22 | "github.com/virtual-kubelet/node-cli/opts" 23 | "k8s.io/klog" 24 | ) 25 | 26 | func installFlags(flags *pflag.FlagSet, c *opts.Opts) { 27 | flags.StringVar(&c.KubeConfigPath, "kubeconfig", c.KubeConfigPath, "kube config file to use for connecting to the Kubernetes API server") 28 | flags.StringVar(&c.KubeNamespace, "namespace", c.KubeNamespace, "kubernetes namespace (default is 'all')") 29 | flags.StringVar(&c.KubeClusterDomain, "cluster-domain", c.KubeClusterDomain, "kubernetes cluster-domain (default is 'cluster.local')") 30 | flags.StringVar(&c.NodeName, "nodename", c.NodeName, "kubernetes node name") 31 | flags.StringVar(&c.OperatingSystem, "os", c.OperatingSystem, "Operating System (Linux/Windows)") 32 | flags.StringVar(&c.Provider, "provider", c.Provider, "cloud provider") 33 | flags.StringVar(&c.ProviderConfigPath, "provider-config", c.ProviderConfigPath, "cloud provider configuration file") 34 | flags.StringVar(&c.MetricsAddr, "metrics-addr", c.MetricsAddr, "address to listen for metrics/stats requests") 35 | 36 | flags.StringVar(&c.TaintKey, "taint", c.TaintKey, "Set node taint key") 37 | flags.BoolVar(&c.DisableTaint, "disable-taint", c.DisableTaint, "disable the virtual-kubelet node taint") 38 | flags.MarkDeprecated("taint", "Taint key should now be configured using the VK_TAINT_KEY environment variable") 39 | 40 | flags.IntVar(&c.PodSyncWorkers, "pod-sync-workers", c.PodSyncWorkers, `set the number of pod synchronization workers`) 41 | flags.BoolVar(&c.EnableNodeLease, "enable-node-lease", c.EnableNodeLease, `use node leases (1.13) for node heartbeats`) 42 | 43 | flags.DurationVar(&c.InformerResyncPeriod, "full-resync-period", c.InformerResyncPeriod, "how often to perform a full resync of pods between kubernetes and the provider") 44 | flags.DurationVar(&c.StartupTimeout, "startup-timeout", c.StartupTimeout, "How long to wait for the virtual-kubelet to start") 45 | 46 | flagset := flag.NewFlagSet("klog", flag.PanicOnError) 47 | klog.InitFlags(flagset) 48 | flagset.VisitAll(func(f *flag.Flag) { 49 | f.Name = "klog." + f.Name 50 | flags.AddGoFlag(f) 51 | }) 52 | } 53 | 54 | func getEnv(key, defaultValue string) string { 55 | value, found := os.LookupEnv(key) 56 | if found { 57 | return value 58 | } 59 | return defaultValue 60 | } 61 | -------------------------------------------------------------------------------- /internal/commands/root/node.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 root 16 | 17 | import ( 18 | "context" 19 | "strings" 20 | 21 | "github.com/virtual-kubelet/node-cli/opts" 22 | "github.com/virtual-kubelet/node-cli/provider" 23 | "github.com/virtual-kubelet/virtual-kubelet/errdefs" 24 | corev1 "k8s.io/api/core/v1" 25 | v1 "k8s.io/api/core/v1" 26 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 27 | ) 28 | 29 | const osLabel = "beta.kubernetes.io/os" 30 | 31 | // NodeFromProvider builds a kubernetes node object from a provider 32 | // This is a temporary solution until node stuff actually split off from the provider interface itself. 33 | func NodeFromProvider(ctx context.Context, name string, taint *v1.Taint, p provider.Provider, version string) *v1.Node { 34 | taints := make([]v1.Taint, 0) 35 | 36 | if taint != nil { 37 | taints = append(taints, *taint) 38 | } 39 | 40 | node := &v1.Node{ 41 | ObjectMeta: metav1.ObjectMeta{ 42 | Name: name, 43 | Labels: map[string]string{ 44 | "type": "virtual-kubelet", 45 | "kubernetes.io/role": "agent", 46 | "kubernetes.io/hostname": name, 47 | }, 48 | }, 49 | Spec: v1.NodeSpec{ 50 | Taints: taints, 51 | }, 52 | Status: v1.NodeStatus{ 53 | NodeInfo: v1.NodeSystemInfo{ 54 | Architecture: "amd64", 55 | KubeletVersion: version, 56 | }, 57 | }, 58 | } 59 | 60 | p.ConfigureNode(ctx, node) 61 | if _, ok := node.ObjectMeta.Labels[osLabel]; !ok { 62 | node.ObjectMeta.Labels[osLabel] = strings.ToLower(node.Status.NodeInfo.OperatingSystem) 63 | } 64 | return node 65 | } 66 | 67 | // getTaint creates a taint using the provided key/value. 68 | // Taint effect is read from the environment 69 | // The taint key/value may be overwritten by the environment. 70 | func getTaint(o *opts.Opts) (*corev1.Taint, error) { 71 | if o.TaintValue == "" { 72 | o.TaintValue = o.Provider 73 | } 74 | 75 | var effect corev1.TaintEffect 76 | switch o.TaintEffect { 77 | case "NoSchedule": 78 | effect = corev1.TaintEffectNoSchedule 79 | case "NoExecute": 80 | effect = corev1.TaintEffectNoExecute 81 | case "PreferNoSchedule": 82 | effect = corev1.TaintEffectPreferNoSchedule 83 | default: 84 | return nil, errdefs.InvalidInputf("taint effect %q is not supported", o.TaintEffect) 85 | } 86 | 87 | return &corev1.Taint{ 88 | Key: o.TaintKey, 89 | Value: o.TaintValue, 90 | Effect: effect, 91 | }, nil 92 | } 93 | -------------------------------------------------------------------------------- /opencensus/init.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 opencensus 16 | 17 | import ( 18 | "context" 19 | "net" 20 | "net/http" 21 | "strconv" 22 | "strings" 23 | 24 | "github.com/pkg/errors" 25 | "github.com/virtual-kubelet/node-cli/opts" 26 | "github.com/virtual-kubelet/virtual-kubelet/errdefs" 27 | "github.com/virtual-kubelet/virtual-kubelet/log" 28 | "go.opencensus.io/trace" 29 | "go.opencensus.io/zpages" 30 | ) 31 | 32 | // ExporterInitFunc is the function that is called to initialize an exporter. 33 | // This is used when registering an exporter and called when a user specifed they want to use the exporter. 34 | type ExporterInitFunc func(*Config) (trace.Exporter, error) 35 | 36 | func (c *Config) getExporter(name string) (trace.Exporter, error) { 37 | init, ok := c.AvailableExporters[name] 38 | if !ok { 39 | return nil, errdefs.NotFoundf("exporter not found: %s", name) 40 | } 41 | return init(c) 42 | } 43 | 44 | var reservedTagNames = map[string]bool{ 45 | "operatingSystem": true, 46 | "provider": true, 47 | "nodeName": true, 48 | } 49 | 50 | // Configure sets up opecensus from the passed in config 51 | func Configure(ctx context.Context, c *Config, o *opts.Opts) error { 52 | for k := range c.Tags { 53 | if reservedTagNames[k] { 54 | return errdefs.InvalidInputf("invalid trace tag %q, must not use a reserved tag key", k) 55 | } 56 | } 57 | 58 | if c.Tags == nil { 59 | c.Tags = make(map[string]string, 3) 60 | } 61 | 62 | c.Tags["operatingSystem"] = o.OperatingSystem 63 | c.Tags["provider"] = o.Provider 64 | c.Tags["nodeName"] = o.NodeName 65 | 66 | for _, e := range c.Exporters { 67 | if e == "zpages" { 68 | if c.ZpagesAddr == "" { 69 | log.G(ctx).Warn("Zpages trace exporter requested but listen address was not set, sipping") 70 | } 71 | setupZpages(ctx, c.ZpagesAddr) 72 | continue 73 | } 74 | 75 | exporter, err := c.getExporter(e) 76 | if err != nil { 77 | return err 78 | } 79 | 80 | trace.RegisterExporter(exporter) 81 | } 82 | 83 | if len(c.Exporters) == 0 { 84 | return nil 85 | } 86 | 87 | var s trace.Sampler 88 | switch strings.ToLower(c.SampleRate) { 89 | case "": 90 | case "always": 91 | s = trace.AlwaysSample() 92 | case "never": 93 | s = trace.NeverSample() 94 | default: 95 | rate, err := strconv.Atoi(c.SampleRate) 96 | if err != nil { 97 | return errdefs.AsInvalidInput(errors.Wrap(err, "unsupported trace sample rate")) 98 | } 99 | if rate < 0 || rate > 100 { 100 | return errdefs.AsInvalidInput(errors.Wrap(err, "trace sample rate must be between 0 and 100")) 101 | } 102 | s = trace.ProbabilitySampler(float64(rate) / 100) 103 | } 104 | 105 | if s != nil { 106 | trace.ApplyConfig( 107 | trace.Config{ 108 | DefaultSampler: s, 109 | }, 110 | ) 111 | } 112 | 113 | return nil 114 | } 115 | 116 | func setupZpages(ctx context.Context, addr string) { 117 | listener, err := net.Listen("tcp", addr) 118 | if err != nil { 119 | log.G(ctx).WithError(err).Error("Could not bind to specified zpages addr: %s", addr) 120 | return 121 | } 122 | 123 | mux := http.NewServeMux() 124 | zpages.Handle(mux, "/debug") 125 | 126 | go func() { 127 | // This should never terminate, if it does, it will always terminate with an error 128 | e := http.Serve(listener, mux) 129 | if e == http.ErrServerClosed { 130 | return 131 | } 132 | log.G(ctx).WithError(e).Error("Zpages server exited") 133 | }() 134 | } 135 | -------------------------------------------------------------------------------- /opts/opts.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 opts 16 | 17 | import ( 18 | "os" 19 | "path/filepath" 20 | "strconv" 21 | "time" 22 | 23 | "github.com/mitchellh/go-homedir" 24 | "github.com/pkg/errors" 25 | corev1 "k8s.io/api/core/v1" 26 | ) 27 | 28 | // Defaults for root command options 29 | const ( 30 | DefaultNodeName = "virtual-kubelet" 31 | DefaultOperatingSystem = "Linux" 32 | DefaultInformerResyncPeriod = 1 * time.Minute 33 | DefaultMetricsAddr = ":10255" 34 | DefaultListenPort = 10250 // TODO(cpuguy83)(VK1.0): Change this to an addr instead of just a port.. we should not be listening on all interfaces. 35 | DefaultPodSyncWorkers = 10 36 | DefaultKubeNamespace = corev1.NamespaceAll 37 | DefaultKubeClusterDomain = "cluster.local" 38 | 39 | DefaultTaintEffect = string(corev1.TaintEffectNoSchedule) 40 | DefaultTaintKey = "virtual-kubelet.io/provider" 41 | ) 42 | 43 | // Opts stores all the options for configuring the root virtual-kubelet command. 44 | // It is used for setting flag values. 45 | // 46 | // You can set the default options by creating a new `Opts` struct and passing 47 | // it into `SetDefaultOpts` 48 | type Opts struct { 49 | // Path to the kubeconfig to use to connect to the Kubernetes API server. 50 | KubeConfigPath string 51 | // Namespace to watch for pods and other resources 52 | KubeNamespace string 53 | // Domain suffix to append to search domains for the pods created by virtual-kubelet 54 | KubeClusterDomain string 55 | 56 | // Sets the port to listen for requests from the Kubernetes API server 57 | ListenPort int32 58 | 59 | // Node name to use when creating a node in Kubernetes 60 | NodeName string 61 | 62 | // Operating system to run pods for 63 | OperatingSystem string 64 | 65 | Provider string 66 | ProviderConfigPath string 67 | 68 | TaintKey string 69 | TaintEffect string 70 | TaintValue string 71 | DisableTaint bool 72 | 73 | MetricsAddr string 74 | 75 | // Number of workers to use to handle pod notifications 76 | PodSyncWorkers int 77 | InformerResyncPeriod time.Duration 78 | 79 | // Use node leases when supported by Kubernetes (instead of node status updates) 80 | EnableNodeLease bool 81 | 82 | // Startup Timeout is how long to wait for the kubelet to start 83 | StartupTimeout time.Duration 84 | 85 | Version string 86 | } 87 | 88 | // FromEnv sets default options for unset values on the passed in option struct. 89 | // Fields tht are already set will not be modified. 90 | func FromEnv() (*Opts, error) { 91 | o := &Opts{} 92 | setDefaults(o) 93 | 94 | o.NodeName = getEnv("DEFAULTNODE_NAME", o.NodeName) 95 | 96 | if kp := os.Getenv("KUBELET_PORT"); kp != "" { 97 | p, err := strconv.Atoi(kp) 98 | if err != nil { 99 | return o, errors.Wrap(err, "error parsing KUBELET_PORT environment variable") 100 | } 101 | o.ListenPort = int32(p) 102 | } 103 | 104 | o.KubeConfigPath = os.Getenv("KUBECONFIG") 105 | if o.KubeConfigPath == "" { 106 | home, _ := homedir.Dir() 107 | if home != "" { 108 | o.KubeConfigPath = filepath.Join(home, ".kube", "config") 109 | } 110 | } 111 | 112 | o.TaintKey = getEnv("VKUBELET_TAINT_KEY", o.TaintKey) 113 | o.TaintValue = getEnv("VKUBELET_TAINT_VALUE", o.TaintValue) 114 | o.TaintEffect = getEnv("VKUBELET_TAINT_EFFECT", o.TaintEffect) 115 | 116 | return o, nil 117 | } 118 | 119 | func New() *Opts { 120 | o := &Opts{} 121 | setDefaults(o) 122 | return o 123 | } 124 | 125 | func setDefaults(o *Opts) { 126 | o.OperatingSystem = DefaultOperatingSystem 127 | o.NodeName = DefaultNodeName 128 | o.TaintKey = DefaultTaintKey 129 | o.TaintEffect = DefaultTaintEffect 130 | o.KubeNamespace = DefaultKubeNamespace 131 | o.PodSyncWorkers = DefaultPodSyncWorkers 132 | o.ListenPort = DefaultListenPort 133 | o.MetricsAddr = DefaultMetricsAddr 134 | o.InformerResyncPeriod = DefaultInformerResyncPeriod 135 | o.KubeClusterDomain = DefaultKubeClusterDomain 136 | } 137 | 138 | func getEnv(key, defaultValue string) string { 139 | value, found := os.LookupEnv(key) 140 | if found { 141 | return value 142 | } 143 | return defaultValue 144 | } 145 | -------------------------------------------------------------------------------- /internal/commands/root/http.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 root 16 | 17 | import ( 18 | "context" 19 | "crypto/tls" 20 | "fmt" 21 | "io" 22 | "net" 23 | "net/http" 24 | "os" 25 | 26 | "github.com/pkg/errors" 27 | "github.com/virtual-kubelet/node-cli/opts" 28 | "github.com/virtual-kubelet/node-cli/provider" 29 | "github.com/virtual-kubelet/virtual-kubelet/log" 30 | "github.com/virtual-kubelet/virtual-kubelet/node/api" 31 | ) 32 | 33 | // AcceptedCiphers is the list of accepted TLS ciphers, with known weak ciphers elided 34 | // Note this list should be a moving target. 35 | var AcceptedCiphers = []uint16{ 36 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 37 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 38 | tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 39 | tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 40 | 41 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 42 | tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 43 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 44 | tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 45 | } 46 | 47 | func loadTLSConfig(certPath, keyPath string) (*tls.Config, error) { 48 | cert, err := tls.LoadX509KeyPair(certPath, keyPath) 49 | if err != nil { 50 | return nil, errors.Wrap(err, "error loading tls certs") 51 | } 52 | 53 | return &tls.Config{ 54 | Certificates: []tls.Certificate{cert}, 55 | MinVersion: tls.VersionTLS12, 56 | PreferServerCipherSuites: true, 57 | CipherSuites: AcceptedCiphers, 58 | }, nil 59 | } 60 | 61 | func setupHTTPServer(ctx context.Context, p provider.Provider, cfg *apiServerConfig, getPodsFromKubernetes api.PodListerFunc) (_ func(), retErr error) { 62 | var closers []io.Closer 63 | cancel := func() { 64 | for _, c := range closers { 65 | c.Close() 66 | } 67 | } 68 | defer func() { 69 | if retErr != nil { 70 | cancel() 71 | } 72 | }() 73 | 74 | if cfg.CertPath == "" || cfg.KeyPath == "" { 75 | log.G(ctx). 76 | WithField("certPath", cfg.CertPath). 77 | WithField("keyPath", cfg.KeyPath). 78 | Error("TLS certificates not provided, not setting up pod http server") 79 | } else { 80 | tlsCfg, err := loadTLSConfig(cfg.CertPath, cfg.KeyPath) 81 | if err != nil { 82 | return nil, err 83 | } 84 | l, err := tls.Listen("tcp", cfg.Addr, tlsCfg) 85 | if err != nil { 86 | return nil, errors.Wrap(err, "error setting up listener for pod http server") 87 | } 88 | 89 | mux := http.NewServeMux() 90 | 91 | podRoutes := api.PodHandlerConfig{ 92 | RunInContainer: p.RunInContainer, 93 | GetContainerLogs: p.GetContainerLogs, 94 | GetPodsFromKubernetes: getPodsFromKubernetes, 95 | GetPods: p.GetPods, 96 | } 97 | api.AttachPodRoutes(podRoutes, mux, true) 98 | 99 | s := &http.Server{ 100 | Handler: mux, 101 | TLSConfig: tlsCfg, 102 | } 103 | go serveHTTP(ctx, s, l, "pods") 104 | closers = append(closers, s) 105 | } 106 | 107 | if cfg.MetricsAddr == "" { 108 | log.G(ctx).Info("Pod metrics server not setup due to empty metrics address") 109 | } else { 110 | l, err := net.Listen("tcp", cfg.MetricsAddr) 111 | if err != nil { 112 | return nil, errors.Wrap(err, "could not setup listener for pod metrics http server") 113 | } 114 | 115 | mux := http.NewServeMux() 116 | 117 | var summaryHandlerFunc api.PodStatsSummaryHandlerFunc 118 | if mp, ok := p.(provider.PodMetricsProvider); ok { 119 | summaryHandlerFunc = mp.GetStatsSummary 120 | } 121 | podMetricsRoutes := api.PodMetricsConfig{ 122 | GetStatsSummary: summaryHandlerFunc, 123 | } 124 | api.AttachPodMetricsRoutes(podMetricsRoutes, mux) 125 | s := &http.Server{ 126 | Handler: mux, 127 | } 128 | go serveHTTP(ctx, s, l, "pod metrics") 129 | closers = append(closers, s) 130 | } 131 | 132 | return cancel, nil 133 | } 134 | 135 | func serveHTTP(ctx context.Context, s *http.Server, l net.Listener, name string) { 136 | if err := s.Serve(l); err != nil { 137 | select { 138 | case <-ctx.Done(): 139 | default: 140 | log.G(ctx).WithError(err).Errorf("Error setting up %s http server", name) 141 | } 142 | } 143 | l.Close() 144 | } 145 | 146 | type apiServerConfig struct { 147 | CertPath string 148 | KeyPath string 149 | Addr string 150 | MetricsAddr string 151 | } 152 | 153 | func getAPIConfig(c *opts.Opts) (*apiServerConfig, error) { 154 | config := apiServerConfig{ 155 | CertPath: os.Getenv("APISERVER_CERT_LOCATION"), 156 | KeyPath: os.Getenv("APISERVER_KEY_LOCATION"), 157 | } 158 | 159 | config.Addr = fmt.Sprintf(":%d", c.ListenPort) 160 | config.MetricsAddr = c.MetricsAddr 161 | 162 | return &config, nil 163 | } 164 | -------------------------------------------------------------------------------- /cli.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 cli 16 | 17 | import ( 18 | "context" 19 | "os" 20 | "os/signal" 21 | "path/filepath" 22 | "syscall" 23 | 24 | "github.com/spf13/cobra" 25 | "github.com/spf13/pflag" 26 | "github.com/virtual-kubelet/node-cli/internal/commands/providers" 27 | "github.com/virtual-kubelet/node-cli/internal/commands/root" 28 | "github.com/virtual-kubelet/node-cli/internal/commands/version" 29 | "github.com/virtual-kubelet/node-cli/opts" 30 | "github.com/virtual-kubelet/node-cli/provider" 31 | ) 32 | 33 | // Option sets an option on the command. 34 | type Option func(*Command) 35 | 36 | // Command builds the CLI command 37 | type Command struct { 38 | cmd *cobra.Command 39 | s *provider.Store 40 | name string 41 | version string 42 | buildTime string 43 | k8sVersion string 44 | persistentFlags []*pflag.FlagSet 45 | persistentPreRunCb []func() error 46 | opts *opts.Opts 47 | } 48 | 49 | // ContextWithCancelOnSignal returns a context which will be cancelled when 50 | // receiving one of the passed in signals. 51 | // If no signals are passed in, the default signals SIGTERM and SIGINT are used. 52 | func ContextWithCancelOnSignal(ctx context.Context, signals ...os.Signal) context.Context { 53 | ctx, cancel := context.WithCancel(ctx) 54 | sig := make(chan os.Signal, 1) 55 | if signals == nil { 56 | signals = []os.Signal{syscall.SIGINT, syscall.SIGTERM} 57 | } 58 | signal.Notify(sig, signals...) 59 | go func() { 60 | <-sig 61 | cancel() 62 | }() 63 | 64 | return ctx 65 | } 66 | 67 | // WithBaseOpts sets the base options used 68 | func WithBaseOpts(o *opts.Opts) Option { 69 | return func(c *Command) { 70 | c.opts = o 71 | } 72 | } 73 | 74 | // WithPersistentFlagsAllows you to attach custom, persitent flags to the command. 75 | // The flags are added to the main command and all sub commands. 76 | func WithPersistentFlags(flags *pflag.FlagSet) Option { 77 | return func(c *Command) { 78 | c.persistentFlags = append(c.persistentFlags, flags) 79 | } 80 | } 81 | 82 | // WithProvider registers a provider which the cli can be initialized with. 83 | func WithProvider(name string, f provider.InitFunc) Option { 84 | return func(c *Command) { 85 | if c.s == nil { 86 | c.s = provider.NewStore() 87 | } 88 | c.s.Register(name, f) 89 | } 90 | } 91 | 92 | // WithCLIVersion sets the version details for the `version` subcommand. 93 | func WithCLIVersion(version, buildTime string) Option { 94 | return func(c *Command) { 95 | c.version = version 96 | c.buildTime = buildTime 97 | } 98 | } 99 | 100 | // WithCLIBaseName sets the name of the command. 101 | // This is used for things like help output. 102 | // 103 | // If not set, the name is taken from `filepath.Base(os.Args[0])` 104 | func WithCLIBaseName(n string) Option { 105 | return func(c *Command) { 106 | c.name = n 107 | } 108 | } 109 | 110 | // WithKubernetesNodeVersion sets the version of kubernetes this should report 111 | // as to the Kubernetes API server. 112 | func WithKubernetesNodeVersion(v string) Option { 113 | return func(c *Command) { 114 | c.k8sVersion = v 115 | } 116 | } 117 | 118 | // WithPersistentPreRunCallback adds a callback which is called after flags are processed 119 | // but before running the command or any sub-command 120 | func WithPersistentPreRunCallback(f func() error) Option { 121 | return func(c *Command) { 122 | c.persistentPreRunCb = append(c.persistentPreRunCb, f) 123 | } 124 | } 125 | 126 | // New creates a new command. 127 | // Call `Run()` on the returned object to run the command. 128 | func New(ctx context.Context, options ...Option) (*Command, error) { 129 | var c Command 130 | for _, o := range options { 131 | o(&c) 132 | } 133 | 134 | name := c.name 135 | if name == "" { 136 | name = filepath.Base(os.Args[0]) 137 | } 138 | 139 | flagOpts := c.opts 140 | if flagOpts == nil { 141 | flagOpts = opts.New() 142 | } 143 | 144 | if c.k8sVersion != "" { 145 | flagOpts.Version = c.k8sVersion 146 | } 147 | 148 | c.cmd = root.NewCommand(ctx, name, c.s, flagOpts) 149 | for _, f := range c.persistentFlags { 150 | c.cmd.PersistentFlags().AddFlagSet(f) 151 | } 152 | 153 | c.cmd.PersistentPreRunE = func(_ *cobra.Command, _ []string) error { 154 | for _, f := range c.persistentPreRunCb { 155 | if err := f(); err != nil { 156 | return err 157 | } 158 | } 159 | return nil 160 | } 161 | 162 | c.cmd.AddCommand(version.NewCommand(c.version, c.buildTime), providers.NewCommand(c.s)) 163 | return &c, nil 164 | } 165 | 166 | // Run executes the command with the provided args. 167 | // If args is nil then os.Args[1:] is used 168 | func (c *Command) Run(args ...string) error { 169 | c.cmd.SetArgs(args) 170 | return c.cmd.Execute() 171 | } 172 | -------------------------------------------------------------------------------- /internal/commands/root/root.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2017 The virtual-kubelet authors 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 root 16 | 17 | import ( 18 | "context" 19 | "os" 20 | "path" 21 | "time" 22 | 23 | "github.com/pkg/errors" 24 | "github.com/spf13/cobra" 25 | "github.com/virtual-kubelet/node-cli/manager" 26 | "github.com/virtual-kubelet/node-cli/opts" 27 | "github.com/virtual-kubelet/node-cli/provider" 28 | "github.com/virtual-kubelet/virtual-kubelet/errdefs" 29 | "github.com/virtual-kubelet/virtual-kubelet/log" 30 | "github.com/virtual-kubelet/virtual-kubelet/node" 31 | corev1 "k8s.io/api/core/v1" 32 | k8serrors "k8s.io/apimachinery/pkg/api/errors" 33 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 34 | "k8s.io/apimachinery/pkg/fields" 35 | kubeinformers "k8s.io/client-go/informers" 36 | "k8s.io/client-go/kubernetes" 37 | "k8s.io/client-go/kubernetes/scheme" 38 | "k8s.io/client-go/kubernetes/typed/coordination/v1beta1" 39 | corev1client "k8s.io/client-go/kubernetes/typed/core/v1" 40 | "k8s.io/client-go/rest" 41 | "k8s.io/client-go/tools/clientcmd" 42 | "k8s.io/client-go/tools/record" 43 | ) 44 | 45 | // NewCommand creates a new top-level command. 46 | // This command is used to start the virtual-kubelet daemon 47 | func NewCommand(ctx context.Context, name string, s *provider.Store, o *opts.Opts) *cobra.Command { 48 | cmd := &cobra.Command{ 49 | Use: name, 50 | Short: name + " provides a virtual kubelet interface for your kubernetes cluster.", 51 | Long: name + ` implements the Kubelet interface with a pluggable 52 | backend implementation allowing users to create kubernetes nodes without running the kubelet. 53 | This allows users to schedule kubernetes workloads on nodes that aren't running Kubernetes.`, 54 | RunE: func(cmd *cobra.Command, args []string) error { 55 | return runRootCommand(ctx, s, o) 56 | }, 57 | } 58 | 59 | installFlags(cmd.Flags(), o) 60 | return cmd 61 | } 62 | 63 | func runRootCommand(ctx context.Context, s *provider.Store, c *opts.Opts) error { 64 | ctx, cancel := context.WithCancel(ctx) 65 | defer cancel() 66 | 67 | if ok := provider.ValidOperatingSystems[c.OperatingSystem]; !ok { 68 | return errdefs.InvalidInputf("operating system %q is not supported", c.OperatingSystem) 69 | } 70 | 71 | if c.PodSyncWorkers == 0 { 72 | return errdefs.InvalidInput("pod sync workers must be greater than 0") 73 | } 74 | 75 | var taint *corev1.Taint 76 | if !c.DisableTaint { 77 | var err error 78 | taint, err = getTaint(c) 79 | if err != nil { 80 | return err 81 | } 82 | } 83 | 84 | client, err := newClient(c.KubeConfigPath) 85 | if err != nil { 86 | return err 87 | } 88 | 89 | // Create a shared informer factory for Kubernetes pods in the current namespace (if specified) and scheduled to the current node. 90 | podInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions( 91 | client, 92 | c.InformerResyncPeriod, 93 | kubeinformers.WithNamespace(c.KubeNamespace), 94 | kubeinformers.WithTweakListOptions(func(options *metav1.ListOptions) { 95 | options.FieldSelector = fields.OneTermEqualSelector("spec.nodeName", c.NodeName).String() 96 | })) 97 | podInformer := podInformerFactory.Core().V1().Pods() 98 | 99 | // Create another shared informer factory for Kubernetes secrets and configmaps (not subject to any selectors). 100 | scmInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(client, c.InformerResyncPeriod) 101 | // Create a secret informer and a config map informer so we can pass their listers to the resource manager. 102 | secretInformer := scmInformerFactory.Core().V1().Secrets() 103 | configMapInformer := scmInformerFactory.Core().V1().ConfigMaps() 104 | serviceInformer := scmInformerFactory.Core().V1().Services() 105 | 106 | rm, err := manager.NewResourceManager(podInformer.Lister(), secretInformer.Lister(), configMapInformer.Lister(), serviceInformer.Lister()) 107 | if err != nil { 108 | return errors.Wrap(err, "could not create resource manager") 109 | } 110 | 111 | // Start the informers now, so the provider will get a functional resource 112 | // manager. 113 | podInformerFactory.Start(ctx.Done()) 114 | scmInformerFactory.Start(ctx.Done()) 115 | 116 | apiConfig, err := getAPIConfig(c) 117 | if err != nil { 118 | return err 119 | } 120 | 121 | initConfig := provider.InitConfig{ 122 | ConfigPath: c.ProviderConfigPath, 123 | NodeName: c.NodeName, 124 | OperatingSystem: c.OperatingSystem, 125 | ResourceManager: rm, 126 | DaemonPort: int32(c.ListenPort), 127 | InternalIP: os.Getenv("VKUBELET_POD_IP"), 128 | KubeClusterDomain: c.KubeClusterDomain, 129 | } 130 | 131 | pInit := s.Get(c.Provider) 132 | if pInit == nil { 133 | return errors.Errorf("provider %q not found", c.Provider) 134 | } 135 | 136 | p, err := pInit(initConfig) 137 | if err != nil { 138 | return errors.Wrapf(err, "error initializing provider %s", c.Provider) 139 | } 140 | 141 | ctx = log.WithLogger(ctx, log.G(ctx).WithFields(log.Fields{ 142 | "provider": c.Provider, 143 | "operatingSystem": c.OperatingSystem, 144 | "node": c.NodeName, 145 | "watchedNamespace": c.KubeNamespace, 146 | })) 147 | 148 | var leaseClient v1beta1.LeaseInterface 149 | if c.EnableNodeLease { 150 | leaseClient = client.CoordinationV1beta1().Leases(corev1.NamespaceNodeLease) 151 | } 152 | 153 | pNode := NodeFromProvider(ctx, c.NodeName, taint, p, c.Version) 154 | nodeRunner, err := node.NewNodeController( 155 | node.NaiveNodeProvider{}, 156 | pNode, 157 | client.CoreV1().Nodes(), 158 | node.WithNodeEnableLeaseV1Beta1(leaseClient, nil), 159 | node.WithNodeStatusUpdateErrorHandler(func(ctx context.Context, err error) error { 160 | if !k8serrors.IsNotFound(err) { 161 | return err 162 | } 163 | 164 | log.G(ctx).Debug("node not found") 165 | newNode := pNode.DeepCopy() 166 | newNode.ResourceVersion = "" 167 | _, err = client.CoreV1().Nodes().Create(newNode) 168 | if err != nil { 169 | return err 170 | } 171 | log.G(ctx).Debug("created new node") 172 | return nil 173 | }), 174 | ) 175 | if err != nil { 176 | log.G(ctx).Fatal(err) 177 | } 178 | 179 | eb := record.NewBroadcaster() 180 | eb.StartLogging(log.G(ctx).Infof) 181 | eb.StartRecordingToSink(&corev1client.EventSinkImpl{Interface: client.CoreV1().Events(c.KubeNamespace)}) 182 | 183 | pc, err := node.NewPodController(node.PodControllerConfig{ 184 | PodClient: client.CoreV1(), 185 | PodInformer: podInformer, 186 | EventRecorder: eb.NewRecorder(scheme.Scheme, corev1.EventSource{Component: path.Join(pNode.Name, "pod-controller")}), 187 | Provider: p, 188 | SecretInformer: secretInformer, 189 | ConfigMapInformer: configMapInformer, 190 | ServiceInformer: serviceInformer, 191 | }) 192 | if err != nil { 193 | return errors.Wrap(err, "error setting up pod controller") 194 | } 195 | 196 | cancelHTTP, err := setupHTTPServer(ctx, p, apiConfig, func(context.Context) ([]*corev1.Pod, error) { 197 | return rm.GetPods(), nil 198 | }) 199 | if err != nil { 200 | return err 201 | } 202 | defer cancelHTTP() 203 | 204 | go func() { 205 | if err := pc.Run(ctx, c.PodSyncWorkers); err != nil && errors.Cause(err) != context.Canceled { 206 | log.G(ctx).Fatal(err) 207 | } 208 | }() 209 | 210 | if c.StartupTimeout > 0 { 211 | // If there is a startup timeout, it does two things: 212 | // 1. It causes the VK to shutdown if we haven't gotten into an operational state in a time period 213 | // 2. It prevents node advertisement from happening until we're in an operational state 214 | err = waitFor(ctx, c.StartupTimeout, pc.Ready()) 215 | if err != nil { 216 | return err 217 | } 218 | } 219 | 220 | go func() { 221 | if err := nodeRunner.Run(ctx); err != nil { 222 | log.G(ctx).Fatal(err) 223 | } 224 | }() 225 | 226 | log.G(ctx).Info("Initialized") 227 | 228 | <-ctx.Done() 229 | return nil 230 | } 231 | 232 | func waitFor(ctx context.Context, time time.Duration, ready <-chan struct{}) error { 233 | ctx, cancel := context.WithTimeout(ctx, time) 234 | defer cancel() 235 | 236 | // Wait for the VK / PC close the the ready channel, or time out and return 237 | log.G(ctx).Info("Waiting for pod controller / VK to be ready") 238 | 239 | select { 240 | case <-ready: 241 | return nil 242 | case <-ctx.Done(): 243 | return errors.Wrap(ctx.Err(), "Error while starting up VK") 244 | } 245 | } 246 | 247 | func newClient(configPath string) (*kubernetes.Clientset, error) { 248 | var config *rest.Config 249 | 250 | // Check if the kubeConfig file exists. 251 | if _, err := os.Stat(configPath); !os.IsNotExist(err) { 252 | // Get the kubeconfig from the filepath. 253 | config, err = clientcmd.BuildConfigFromFlags("", configPath) 254 | if err != nil { 255 | return nil, errors.Wrap(err, "error building client config") 256 | } 257 | } else { 258 | // Set to in-cluster config. 259 | config, err = rest.InClusterConfig() 260 | if err != nil { 261 | return nil, errors.Wrap(err, "error building in cluster config") 262 | } 263 | } 264 | 265 | if masterURI := os.Getenv("MASTER_URI"); masterURI != "" { 266 | config.Host = masterURI 267 | } 268 | 269 | return kubernetes.NewForConfig(config) 270 | } 271 | -------------------------------------------------------------------------------- /provider/mock/mock.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | "io/ioutil" 9 | "math/rand" 10 | "strings" 11 | "time" 12 | 13 | "github.com/virtual-kubelet/virtual-kubelet/errdefs" 14 | "github.com/virtual-kubelet/virtual-kubelet/log" 15 | "github.com/virtual-kubelet/virtual-kubelet/node/api" 16 | "github.com/virtual-kubelet/virtual-kubelet/trace" 17 | v1 "k8s.io/api/core/v1" 18 | "k8s.io/apimachinery/pkg/api/resource" 19 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 20 | stats "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1" 21 | ) 22 | 23 | const ( 24 | // Provider configuration defaults. 25 | defaultCPUCapacity = "20" 26 | defaultMemoryCapacity = "100Gi" 27 | defaultPodCapacity = "20" 28 | 29 | // Values used in tracing as attribute keys. 30 | namespaceKey = "namespace" 31 | nameKey = "name" 32 | containerNameKey = "containerName" 33 | ) 34 | 35 | // See: https://github.com/virtual-kubelet/virtual-kubelet/issues/632 36 | /* 37 | var ( 38 | _ providers.Provider = (*MockV0Provider)(nil) 39 | _ providers.PodMetricsProvider = (*MockV0Provider)(nil) 40 | _ node.PodNotifier = (*MockProvider)(nil) 41 | ) 42 | */ 43 | 44 | // MockV0Provider implements the virtual-kubelet provider interface and stores pods in memory. 45 | type MockV0Provider struct { 46 | nodeName string 47 | operatingSystem string 48 | internalIP string 49 | daemonEndpointPort int32 50 | pods map[string]*v1.Pod 51 | config MockConfig 52 | startTime time.Time 53 | notifier func(*v1.Pod) 54 | } 55 | 56 | // MockProvider is like MockV0Provider, but implements the PodNotifier interface 57 | type MockProvider struct { 58 | *MockV0Provider 59 | } 60 | 61 | // MockConfig contains a mock virtual-kubelet's configurable parameters. 62 | type MockConfig struct { 63 | CPU string `json:"cpu,omitempty"` 64 | Memory string `json:"memory,omitempty"` 65 | Pods string `json:"pods,omitempty"` 66 | } 67 | 68 | // NewMockProviderMockConfig creates a new MockV0Provider. Mock legacy provider does not implement the new asynchronous podnotifier interface 69 | func NewMockV0ProviderMockConfig(config MockConfig, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*MockV0Provider, error) { 70 | //set defaults 71 | if config.CPU == "" { 72 | config.CPU = defaultCPUCapacity 73 | } 74 | if config.Memory == "" { 75 | config.Memory = defaultMemoryCapacity 76 | } 77 | if config.Pods == "" { 78 | config.Pods = defaultPodCapacity 79 | } 80 | provider := MockV0Provider{ 81 | nodeName: nodeName, 82 | operatingSystem: operatingSystem, 83 | internalIP: internalIP, 84 | daemonEndpointPort: daemonEndpointPort, 85 | pods: make(map[string]*v1.Pod), 86 | config: config, 87 | startTime: time.Now(), 88 | // By default notifier is set to a function which is a no-op. In the event we've implemented the PodNotifier interface, 89 | // it will be set, and then we'll call a real underlying implementation. 90 | // This makes it easier in the sense we don't need to wrap each method. 91 | notifier: func(*v1.Pod) {}, 92 | } 93 | 94 | return &provider, nil 95 | } 96 | 97 | // NewMockV0Provider creates a new MockV0Provider 98 | func NewMockV0Provider(providerConfig, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*MockV0Provider, error) { 99 | config, err := loadConfig(providerConfig, nodeName) 100 | if err != nil { 101 | return nil, err 102 | } 103 | 104 | return NewMockV0ProviderMockConfig(config, nodeName, operatingSystem, internalIP, daemonEndpointPort) 105 | } 106 | 107 | // NewMockProviderMockConfig creates a new MockProvider with the given config 108 | func NewMockProviderMockConfig(config MockConfig, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*MockProvider, error) { 109 | p, err := NewMockV0ProviderMockConfig(config, nodeName, operatingSystem, internalIP, daemonEndpointPort) 110 | 111 | return &MockProvider{MockV0Provider: p}, err 112 | } 113 | 114 | // NewMockProvider creates a new MockProvider, which implements the PodNotifier interface 115 | func NewMockProvider(providerConfig, nodeName, operatingSystem string, internalIP string, daemonEndpointPort int32) (*MockProvider, error) { 116 | config, err := loadConfig(providerConfig, nodeName) 117 | if err != nil { 118 | return nil, err 119 | } 120 | 121 | return NewMockProviderMockConfig(config, nodeName, operatingSystem, internalIP, daemonEndpointPort) 122 | } 123 | 124 | // loadConfig loads the given json configuration files. 125 | func loadConfig(providerConfig, nodeName string) (config MockConfig, err error) { 126 | data, err := ioutil.ReadFile(providerConfig) 127 | if err != nil { 128 | return config, err 129 | } 130 | configMap := map[string]MockConfig{} 131 | err = json.Unmarshal(data, &configMap) 132 | if err != nil { 133 | return config, err 134 | } 135 | if _, exist := configMap[nodeName]; exist { 136 | config = configMap[nodeName] 137 | if config.CPU == "" { 138 | config.CPU = defaultCPUCapacity 139 | } 140 | if config.Memory == "" { 141 | config.Memory = defaultMemoryCapacity 142 | } 143 | if config.Pods == "" { 144 | config.Pods = defaultPodCapacity 145 | } 146 | } 147 | 148 | if _, err = resource.ParseQuantity(config.CPU); err != nil { 149 | return config, fmt.Errorf("Invalid CPU value %v", config.CPU) 150 | } 151 | if _, err = resource.ParseQuantity(config.Memory); err != nil { 152 | return config, fmt.Errorf("Invalid memory value %v", config.Memory) 153 | } 154 | if _, err = resource.ParseQuantity(config.Pods); err != nil { 155 | return config, fmt.Errorf("Invalid pods value %v", config.Pods) 156 | } 157 | return config, nil 158 | } 159 | 160 | // CreatePod accepts a Pod definition and stores it in memory. 161 | func (p *MockV0Provider) CreatePod(ctx context.Context, pod *v1.Pod) error { 162 | ctx, span := trace.StartSpan(ctx, "CreatePod") 163 | defer span.End() 164 | 165 | // Add the pod's coordinates to the current span. 166 | ctx = addAttributes(ctx, span, namespaceKey, pod.Namespace, nameKey, pod.Name) 167 | 168 | log.G(ctx).Infof("receive CreatePod %q", pod.Name) 169 | 170 | key, err := buildKey(pod) 171 | if err != nil { 172 | return err 173 | } 174 | 175 | now := metav1.NewTime(time.Now()) 176 | pod.Status = v1.PodStatus{ 177 | Phase: v1.PodRunning, 178 | HostIP: "1.2.3.4", 179 | PodIP: "5.6.7.8", 180 | StartTime: &now, 181 | Conditions: []v1.PodCondition{ 182 | { 183 | Type: v1.PodInitialized, 184 | Status: v1.ConditionTrue, 185 | }, 186 | { 187 | Type: v1.PodReady, 188 | Status: v1.ConditionTrue, 189 | }, 190 | { 191 | Type: v1.PodScheduled, 192 | Status: v1.ConditionTrue, 193 | }, 194 | }, 195 | } 196 | 197 | for _, container := range pod.Spec.Containers { 198 | pod.Status.ContainerStatuses = append(pod.Status.ContainerStatuses, v1.ContainerStatus{ 199 | Name: container.Name, 200 | Image: container.Image, 201 | Ready: true, 202 | RestartCount: 0, 203 | State: v1.ContainerState{ 204 | Running: &v1.ContainerStateRunning{ 205 | StartedAt: now, 206 | }, 207 | }, 208 | }) 209 | } 210 | 211 | p.pods[key] = pod 212 | p.notifier(pod) 213 | 214 | return nil 215 | } 216 | 217 | // UpdatePod accepts a Pod definition and updates its reference. 218 | func (p *MockV0Provider) UpdatePod(ctx context.Context, pod *v1.Pod) error { 219 | ctx, span := trace.StartSpan(ctx, "UpdatePod") 220 | defer span.End() 221 | 222 | // Add the pod's coordinates to the current span. 223 | ctx = addAttributes(ctx, span, namespaceKey, pod.Namespace, nameKey, pod.Name) 224 | 225 | log.G(ctx).Infof("receive UpdatePod %q", pod.Name) 226 | 227 | key, err := buildKey(pod) 228 | if err != nil { 229 | return err 230 | } 231 | 232 | p.pods[key] = pod 233 | p.notifier(pod) 234 | 235 | return nil 236 | } 237 | 238 | // DeletePod deletes the specified pod out of memory. 239 | func (p *MockV0Provider) DeletePod(ctx context.Context, pod *v1.Pod) (err error) { 240 | ctx, span := trace.StartSpan(ctx, "DeletePod") 241 | defer span.End() 242 | 243 | // Add the pod's coordinates to the current span. 244 | ctx = addAttributes(ctx, span, namespaceKey, pod.Namespace, nameKey, pod.Name) 245 | 246 | log.G(ctx).Infof("receive DeletePod %q", pod.Name) 247 | 248 | key, err := buildKey(pod) 249 | if err != nil { 250 | return err 251 | } 252 | 253 | if _, exists := p.pods[key]; !exists { 254 | return errdefs.NotFound("pod not found") 255 | } 256 | 257 | now := metav1.Now() 258 | delete(p.pods, key) 259 | pod.Status.Phase = v1.PodSucceeded 260 | pod.Status.Reason = "MockProviderPodDeleted" 261 | 262 | for idx := range pod.Status.ContainerStatuses { 263 | pod.Status.ContainerStatuses[idx].Ready = false 264 | pod.Status.ContainerStatuses[idx].State = v1.ContainerState{ 265 | Terminated: &v1.ContainerStateTerminated{ 266 | Message: "Mock provider terminated container upon deletion", 267 | FinishedAt: now, 268 | Reason: "MockProviderPodContainerDeleted", 269 | StartedAt: pod.Status.ContainerStatuses[idx].State.Running.StartedAt, 270 | }, 271 | } 272 | } 273 | 274 | p.notifier(pod) 275 | 276 | return nil 277 | } 278 | 279 | // GetPod returns a pod by name that is stored in memory. 280 | func (p *MockV0Provider) GetPod(ctx context.Context, namespace, name string) (pod *v1.Pod, err error) { 281 | ctx, span := trace.StartSpan(ctx, "GetPod") 282 | defer func() { 283 | span.SetStatus(err) 284 | span.End() 285 | }() 286 | 287 | // Add the pod's coordinates to the current span. 288 | ctx = addAttributes(ctx, span, namespaceKey, namespace, nameKey, name) 289 | 290 | log.G(ctx).Infof("receive GetPod %q", name) 291 | 292 | key, err := buildKeyFromNames(namespace, name) 293 | if err != nil { 294 | return nil, err 295 | } 296 | 297 | if pod, ok := p.pods[key]; ok { 298 | return pod, nil 299 | } 300 | return nil, errdefs.NotFoundf("pod \"%s/%s\" is not known to the provider", namespace, name) 301 | } 302 | 303 | // GetContainerLogs retrieves the logs of a container by name from the provider. 304 | func (p *MockV0Provider) GetContainerLogs(ctx context.Context, namespace, podName, containerName string, opts api.ContainerLogOpts) (io.ReadCloser, error) { 305 | ctx, span := trace.StartSpan(ctx, "GetContainerLogs") 306 | defer span.End() 307 | 308 | // Add pod and container attributes to the current span. 309 | ctx = addAttributes(ctx, span, namespaceKey, namespace, nameKey, podName, containerNameKey, containerName) 310 | 311 | log.G(ctx).Info("receive GetContainerLogs %q", podName) 312 | return ioutil.NopCloser(strings.NewReader("")), nil 313 | } 314 | 315 | // RunInContainer executes a command in a container in the pod, copying data 316 | // between in/out/err and the container's stdin/stdout/stderr. 317 | func (p *MockV0Provider) RunInContainer(ctx context.Context, namespace, name, container string, cmd []string, attach api.AttachIO) error { 318 | log.G(context.TODO()).Infof("receive ExecInContainer %q", container) 319 | return nil 320 | } 321 | 322 | // GetPodStatus returns the status of a pod by name that is "running". 323 | // returns nil if a pod by that name is not found. 324 | func (p *MockV0Provider) GetPodStatus(ctx context.Context, namespace, name string) (*v1.PodStatus, error) { 325 | ctx, span := trace.StartSpan(ctx, "GetPodStatus") 326 | defer span.End() 327 | 328 | // Add namespace and name as attributes to the current span. 329 | ctx = addAttributes(ctx, span, namespaceKey, namespace, nameKey, name) 330 | 331 | log.G(ctx).Infof("receive GetPodStatus %q", name) 332 | 333 | pod, err := p.GetPod(ctx, namespace, name) 334 | if err != nil { 335 | return nil, err 336 | } 337 | 338 | return &pod.Status, nil 339 | } 340 | 341 | // GetPods returns a list of all pods known to be "running". 342 | func (p *MockV0Provider) GetPods(ctx context.Context) ([]*v1.Pod, error) { 343 | ctx, span := trace.StartSpan(ctx, "GetPods") 344 | defer span.End() 345 | 346 | log.G(ctx).Info("receive GetPods") 347 | 348 | var pods []*v1.Pod 349 | 350 | for _, pod := range p.pods { 351 | pods = append(pods, pod) 352 | } 353 | 354 | return pods, nil 355 | } 356 | 357 | func (p *MockV0Provider) ConfigureNode(ctx context.Context, n *v1.Node) { 358 | ctx, span := trace.StartSpan(ctx, "mock.ConfigureNode") 359 | defer span.End() 360 | 361 | n.Status.Capacity = p.capacity() 362 | n.Status.Allocatable = p.capacity() 363 | n.Status.Conditions = p.nodeConditions() 364 | n.Status.Addresses = p.nodeAddresses() 365 | n.Status.DaemonEndpoints = p.nodeDaemonEndpoints() 366 | os := p.operatingSystem 367 | if os == "" { 368 | os = "Linux" 369 | } 370 | n.Status.NodeInfo.OperatingSystem = os 371 | n.Status.NodeInfo.Architecture = "amd64" 372 | n.ObjectMeta.Labels["alpha.service-controller.kubernetes.io/exclude-balancer"] = "true" 373 | } 374 | 375 | // Capacity returns a resource list containing the capacity limits. 376 | func (p *MockV0Provider) capacity() v1.ResourceList { 377 | return v1.ResourceList{ 378 | "cpu": resource.MustParse(p.config.CPU), 379 | "memory": resource.MustParse(p.config.Memory), 380 | "pods": resource.MustParse(p.config.Pods), 381 | } 382 | } 383 | 384 | // NodeConditions returns a list of conditions (Ready, OutOfDisk, etc), for updates to the node status 385 | // within Kubernetes. 386 | func (p *MockV0Provider) nodeConditions() []v1.NodeCondition { 387 | // TODO: Make this configurable 388 | return []v1.NodeCondition{ 389 | { 390 | Type: "Ready", 391 | Status: v1.ConditionTrue, 392 | LastHeartbeatTime: metav1.Now(), 393 | LastTransitionTime: metav1.Now(), 394 | Reason: "KubeletReady", 395 | Message: "kubelet is ready.", 396 | }, 397 | { 398 | Type: "OutOfDisk", 399 | Status: v1.ConditionFalse, 400 | LastHeartbeatTime: metav1.Now(), 401 | LastTransitionTime: metav1.Now(), 402 | Reason: "KubeletHasSufficientDisk", 403 | Message: "kubelet has sufficient disk space available", 404 | }, 405 | { 406 | Type: "MemoryPressure", 407 | Status: v1.ConditionFalse, 408 | LastHeartbeatTime: metav1.Now(), 409 | LastTransitionTime: metav1.Now(), 410 | Reason: "KubeletHasSufficientMemory", 411 | Message: "kubelet has sufficient memory available", 412 | }, 413 | { 414 | Type: "DiskPressure", 415 | Status: v1.ConditionFalse, 416 | LastHeartbeatTime: metav1.Now(), 417 | LastTransitionTime: metav1.Now(), 418 | Reason: "KubeletHasNoDiskPressure", 419 | Message: "kubelet has no disk pressure", 420 | }, 421 | { 422 | Type: "NetworkUnavailable", 423 | Status: v1.ConditionFalse, 424 | LastHeartbeatTime: metav1.Now(), 425 | LastTransitionTime: metav1.Now(), 426 | Reason: "RouteCreated", 427 | Message: "RouteController created a route", 428 | }, 429 | } 430 | 431 | } 432 | 433 | // NodeAddresses returns a list of addresses for the node status 434 | // within Kubernetes. 435 | func (p *MockV0Provider) nodeAddresses() []v1.NodeAddress { 436 | return []v1.NodeAddress{ 437 | { 438 | Type: "InternalIP", 439 | Address: p.internalIP, 440 | }, 441 | } 442 | } 443 | 444 | // NodeDaemonEndpoints returns NodeDaemonEndpoints for the node status 445 | // within Kubernetes. 446 | func (p *MockV0Provider) nodeDaemonEndpoints() v1.NodeDaemonEndpoints { 447 | return v1.NodeDaemonEndpoints{ 448 | KubeletEndpoint: v1.DaemonEndpoint{ 449 | Port: p.daemonEndpointPort, 450 | }, 451 | } 452 | } 453 | 454 | // GetStatsSummary returns dummy stats for all pods known by this provider. 455 | func (p *MockV0Provider) GetStatsSummary(ctx context.Context) (*stats.Summary, error) { 456 | ctx, span := trace.StartSpan(ctx, "GetStatsSummary") 457 | defer span.End() 458 | 459 | // Grab the current timestamp so we can report it as the time the stats were generated. 460 | time := metav1.NewTime(time.Now()) 461 | 462 | // Create the Summary object that will later be populated with node and pod stats. 463 | res := &stats.Summary{} 464 | 465 | // Populate the Summary object with basic node stats. 466 | res.Node = stats.NodeStats{ 467 | NodeName: p.nodeName, 468 | StartTime: metav1.NewTime(p.startTime), 469 | } 470 | 471 | // Populate the Summary object with dummy stats for each pod known by this provider. 472 | for _, pod := range p.pods { 473 | var ( 474 | // totalUsageNanoCores will be populated with the sum of the values of UsageNanoCores computes across all containers in the pod. 475 | totalUsageNanoCores uint64 476 | // totalUsageBytes will be populated with the sum of the values of UsageBytes computed across all containers in the pod. 477 | totalUsageBytes uint64 478 | ) 479 | 480 | // Create a PodStats object to populate with pod stats. 481 | pss := stats.PodStats{ 482 | PodRef: stats.PodReference{ 483 | Name: pod.Name, 484 | Namespace: pod.Namespace, 485 | UID: string(pod.UID), 486 | }, 487 | StartTime: pod.CreationTimestamp, 488 | } 489 | 490 | // Iterate over all containers in the current pod to compute dummy stats. 491 | for _, container := range pod.Spec.Containers { 492 | // Grab a dummy value to be used as the total CPU usage. 493 | // The value should fit a uint32 in order to avoid overflows later on when computing pod stats. 494 | dummyUsageNanoCores := uint64(rand.Uint32()) 495 | totalUsageNanoCores += dummyUsageNanoCores 496 | // Create a dummy value to be used as the total RAM usage. 497 | // The value should fit a uint32 in order to avoid overflows later on when computing pod stats. 498 | dummyUsageBytes := uint64(rand.Uint32()) 499 | totalUsageBytes += dummyUsageBytes 500 | // Append a ContainerStats object containing the dummy stats to the PodStats object. 501 | pss.Containers = append(pss.Containers, stats.ContainerStats{ 502 | Name: container.Name, 503 | StartTime: pod.CreationTimestamp, 504 | CPU: &stats.CPUStats{ 505 | Time: time, 506 | UsageNanoCores: &dummyUsageNanoCores, 507 | }, 508 | Memory: &stats.MemoryStats{ 509 | Time: time, 510 | UsageBytes: &dummyUsageBytes, 511 | }, 512 | }) 513 | } 514 | 515 | // Populate the CPU and RAM stats for the pod and append the PodsStats object to the Summary object to be returned. 516 | pss.CPU = &stats.CPUStats{ 517 | Time: time, 518 | UsageNanoCores: &totalUsageNanoCores, 519 | } 520 | pss.Memory = &stats.MemoryStats{ 521 | Time: time, 522 | UsageBytes: &totalUsageBytes, 523 | } 524 | res.Pods = append(res.Pods, pss) 525 | } 526 | 527 | // Return the dummy stats. 528 | return res, nil 529 | } 530 | 531 | // NotifyPods is called to set a pod notifier callback function. This should be called before any operations are done 532 | // within the provider. 533 | func (p *MockProvider) NotifyPods(ctx context.Context, notifier func(*v1.Pod)) { 534 | p.notifier = notifier 535 | } 536 | 537 | func buildKeyFromNames(namespace string, name string) (string, error) { 538 | return fmt.Sprintf("%s-%s", namespace, name), nil 539 | } 540 | 541 | // buildKey is a helper for building the "key" for the providers pod store. 542 | func buildKey(pod *v1.Pod) (string, error) { 543 | if pod.ObjectMeta.Namespace == "" { 544 | return "", fmt.Errorf("pod namespace not found") 545 | } 546 | 547 | if pod.ObjectMeta.Name == "" { 548 | return "", fmt.Errorf("pod name not found") 549 | } 550 | 551 | return buildKeyFromNames(pod.ObjectMeta.Namespace, pod.ObjectMeta.Name) 552 | } 553 | 554 | // addAttributes adds the specified attributes to the provided span. 555 | // attrs must be an even-sized list of string arguments. 556 | // Otherwise, the span won't be modified. 557 | // TODO: Refactor and move to a "tracing utilities" package. 558 | func addAttributes(ctx context.Context, span trace.Span, attrs ...string) context.Context { 559 | if len(attrs)%2 == 1 { 560 | return ctx 561 | } 562 | for i := 0; i < len(attrs); i += 2 { 563 | ctx = span.WithField(ctx, attrs[i], attrs[i+1]) 564 | } 565 | return ctx 566 | } 567 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | contrib.go.opencensus.io/exporter/jaeger v0.1.0/go.mod h1:VYianECmuFPwU37O699Vc1GOcy+y8kOsfaxHRImmjbA= 4 | contrib.go.opencensus.io/exporter/ocagent v0.4.12/go.mod h1:450APlNTSR6FrvC3CTRqYosuDstRB9un7SOx2k/9ckA= 5 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 6 | github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= 7 | github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= 8 | github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= 9 | github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= 10 | github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= 11 | github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 12 | github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 13 | github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 14 | github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= 15 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 16 | github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= 17 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 18 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 19 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= 20 | github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 21 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= 22 | github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 23 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 24 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 25 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 26 | github.com/docker/spdystream v0.0.0-20170912183627-bc6354cbbc29 h1:llBx5m8Gk0lrAaiLud2wktkX/e8haX7Ru0oVfQqtZQ4= 27 | github.com/docker/spdystream v0.0.0-20170912183627-bc6354cbbc29/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= 28 | github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= 29 | github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= 30 | github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= 31 | github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f h1:8GDPb0tCY8LQ+OJ3dbHb5sA6YZWXFORQYZx5sdsTlMs= 32 | github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= 33 | github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM= 34 | github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8= 35 | github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= 36 | github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= 37 | github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc= 38 | github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 39 | github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= 40 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 41 | github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 42 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 43 | github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= 44 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= 45 | github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= 46 | github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= 47 | github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= 48 | github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= 49 | github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 50 | github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= 51 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 52 | github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 53 | github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= 54 | github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= 55 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= 56 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 57 | github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg= 58 | github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 59 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 60 | github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 61 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 62 | github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= 63 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 64 | github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 65 | github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= 66 | github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 67 | github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= 68 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 69 | github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= 70 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 71 | github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= 72 | github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= 73 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 74 | github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= 75 | github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 76 | github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 77 | github.com/googleapis/gnostic v0.1.0 h1:rVsPeBmXbYv4If/cumu1AzZPwV58q433hvONV1UEZoI= 78 | github.com/googleapis/gnostic v0.1.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= 79 | github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= 80 | github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 81 | github.com/gorilla/mux v1.7.0/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 82 | github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= 83 | github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= 84 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= 85 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= 86 | github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= 87 | github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 88 | github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= 89 | github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= 90 | github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= 91 | github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= 92 | github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 93 | github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= 94 | github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= 95 | github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= 96 | github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= 97 | github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 98 | github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= 99 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 100 | github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 101 | github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= 102 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 103 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 104 | github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= 105 | github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 106 | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 107 | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 108 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 109 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 110 | github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 111 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 112 | github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= 113 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= 114 | github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 115 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 116 | github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= 117 | github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= 118 | github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= 119 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 120 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 121 | github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 122 | github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= 123 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 124 | github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 125 | github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= 126 | github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 127 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 128 | github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 129 | github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= 130 | github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 131 | github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= 132 | github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 133 | github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= 134 | github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 135 | github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= 136 | github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= 137 | github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= 138 | github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 139 | github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= 140 | github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= 141 | github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 142 | github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 143 | github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= 144 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 145 | github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 146 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 147 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 148 | github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 149 | github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= 150 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 151 | github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 152 | github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 153 | github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 154 | github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 155 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 156 | github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 157 | github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc= 158 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= 159 | github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= 160 | github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= 161 | github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= 162 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 163 | github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= 164 | github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 165 | github.com/spf13/cobra v0.0.2/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= 166 | github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= 167 | github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= 168 | github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= 169 | github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 170 | github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= 171 | github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= 172 | github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= 173 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 174 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 175 | github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 176 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 177 | github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= 178 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 179 | github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= 180 | github.com/virtual-kubelet/virtual-kubelet v1.2.1-0.20200320212802-3ec3b14e49d0 h1:vC9HgqA+OA5xX3oCrGIpZUZgbpeHqxIdpChBMOfW1QM= 181 | github.com/virtual-kubelet/virtual-kubelet v1.2.1-0.20200320212802-3ec3b14e49d0/go.mod h1:ESTeGjhmKb/9CClm0uYuFaxFNPjyU5aNRNWsJGjZmhY= 182 | github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= 183 | go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 184 | go.opencensus.io v0.20.2 h1:NAfh7zF0/3/HqtMvJNZ/RFrSlCE6ZTlHmKfhL/Dm1Jk= 185 | go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= 186 | go.opencensus.io v0.21.0 h1:mU6zScU4U1YAFPHEHYk+3JC4SY7JxgkqS10ZOSyksNg= 187 | go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= 188 | golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 189 | golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 190 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 191 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= 192 | golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 193 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 194 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 195 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 196 | golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 197 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 198 | golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 199 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 200 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 201 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 202 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 203 | golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 204 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 205 | golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 206 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 207 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 208 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= 209 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 210 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 211 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 212 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a h1:tImsplftrFpALCYumobsd0K86vlAs/eXGFms2txfJfA= 213 | golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 214 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 215 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 216 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 217 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 218 | golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 219 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 220 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 221 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 222 | golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 223 | golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 224 | golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 225 | golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 226 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 227 | golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 228 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= 229 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 230 | golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 231 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 232 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= 233 | golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 234 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= 235 | golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 236 | golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 237 | golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 238 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 239 | golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 240 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 241 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 242 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 243 | golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 244 | google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= 245 | google.golang.org/api v0.3.2/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= 246 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 247 | google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= 248 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 249 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 250 | google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 251 | google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107 h1:xtNn7qFlagY2mQNFHMSRPjT2RkOV4OXM7P5TVy9xATo= 252 | google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 253 | google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= 254 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 255 | google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 256 | google.golang.org/grpc v1.20.0 h1:DlsSIrgEBuZAUFJcta2B5i/lzeHHbnfkNFAfFXLVFYQ= 257 | google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= 258 | gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= 259 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 260 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 261 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 262 | gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= 263 | gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= 264 | gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= 265 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 266 | gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= 267 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= 268 | gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 269 | gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= 270 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 271 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 272 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 273 | gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= 274 | gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 275 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 276 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 277 | k8s.io/api v0.0.0-20190222213804-5cb15d344471 h1:MzQGt8qWQCR+39kbYRd0uQqsvSidpYqJLFeWiJ9l4OE= 278 | k8s.io/api v0.0.0-20190222213804-5cb15d344471/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= 279 | k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628 h1:UYfHH+KEF88OTg+GojQUwFTNxbxwmoktLwutUzR0GPg= 280 | k8s.io/apimachinery v0.0.0-20190221213512-86fb29eff628/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= 281 | k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421 h1:NyOpnIh+7SLvC05NGCIXF9c4KhnkTZQE2SxF+m9otww= 282 | k8s.io/apiserver v0.0.0-20181213151703-3ccfe8365421/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w= 283 | k8s.io/client-go v0.0.0-20190521190702-177766529176 h1:gI8ZMlH24D7c30GMAbiwG8hK9l80yvqiiBLaDbRS/Gc= 284 | k8s.io/client-go v0.0.0-20190521190702-177766529176/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s= 285 | k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= 286 | k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 287 | k8s.io/klog v0.3.1 h1:RVgyDHY/kFKtLqh67NvEWIgkMneNoIrdkN0CxDSQc68= 288 | k8s.io/klog v0.3.1/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= 289 | k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22 h1:f0BTap/vrgs21vVbJ1ySdsNtcivpA1x4ut6Wla9HKKw= 290 | k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22/go.mod h1:iU+ZGYsNlvU9XKUSso6SQfKTCCw7lFduMZy26Mgr2Fw= 291 | k8s.io/kubernetes v1.13.7 h1:6I48MdE69fo0SRopCAnxgBlUqhlMjeWWEA8Y3ThzUyA= 292 | k8s.io/kubernetes v1.13.7/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= 293 | k8s.io/utils v0.0.0-20180801164400-045dc31ee5c4 h1:jx/N9qda/hFHvydYhYL9SZ6oh/vXekqK7YeIghe5cjI= 294 | k8s.io/utils v0.0.0-20180801164400-045dc31ee5c4/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= 295 | sigs.k8s.io/structured-merge-diff v0.0.0-20190426204423-ea680f03cc65/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= 296 | sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= 297 | sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= 298 | --------------------------------------------------------------------------------