Skip to content

Commit

Permalink
Reuse k8s drain code
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb authored and chrislovecnm committed Mar 1, 2017
1 parent 7e0ac01 commit 32081f3
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 1,310 deletions.
1 change: 1 addition & 0 deletions cmd/kops/rollingupdatecluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func RunRollingUpdateCluster(f *util.Factory, out io.Writer, options *RollingUpd
Force: options.Force,
Cloud: cloud,
K8sClient: k8sClient,
ClientConfig: kutil.NewClientConfig(config, "kube-system"),
FailOnDrainError: options.FailOnDrainError,
FailOnValidate: options.FailOnValidate,
CloudOnly: options.CloudOnly,
Expand Down
43 changes: 43 additions & 0 deletions upup/pkg/kutil/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package kutil

import (
"k8s.io/kubernetes/pkg/client/restclient"
"fmt"
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"github.com/golang/glog"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
)

func NewClientConfig(clientConfig *restclient.Config, namespace string) clientcmd.ClientConfig {
c := &SimpleClientConfig{clientConfig: clientConfig, namespace: namespace}
return c
}

// ClientConfig is used to make it easy to get an api server client
type SimpleClientConfig struct {
clientConfig *restclient.Config
namespace string
}

var _ clientcmd.ClientConfig = &SimpleClientConfig{}

// RawConfig returns the merged result of all overrides
func (c*SimpleClientConfig) RawConfig() (clientcmdapi.Config, error) {
return clientcmdapi.Config{}, fmt.Errorf("SimpleClientConfig::RawConfig not implemented")
}

// ClientConfig returns a complete client config
func (c*SimpleClientConfig) ClientConfig() (*restclient.Config, error) {
return c.clientConfig, nil
}
// Namespace returns the namespace resulting from the merged
// result of all overrides and a boolean indicating if it was
// overridden
func (c*SimpleClientConfig) Namespace() (string, bool, error) {
return c.namespace, false, nil
}
// ConfigAccess returns the rules for loading/persisting the config.
func (c*SimpleClientConfig) ConfigAccess() clientcmd.ConfigAccess {
glog.Fatalf("SimpleClientConfig::RawConfig not implemented")
return nil
}
Loading

0 comments on commit 32081f3

Please sign in to comment.