From 9c9a65c53e1b9708d852257323f23b81bb03f9e2 Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Tue, 20 Mar 2018 07:11:36 +0100 Subject: [PATCH 1/6] Add feature state store --- cmd/kops/root.go | 13 +++++++++++++ cmd/kops/util/factory.go | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/kops/root.go b/cmd/kops/root.go index ccdd94a193..229e01a511 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -163,6 +163,19 @@ func initConfig() { if err := viper.ReadInConfig(); err == nil { fmt.Println("Using config file:", viper.ConfigFileUsed()) } + + if rootCommand.RegistryPath != "" { + viper.SetConfigFile(rootCommand.RegistryPath) + // If a state file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using state file:", viper.ConfigFileUsed()) + } + } + + viper.BindEnv("KOPS_STATE_STORE", "KOPS_STATE_STORE") + + // fmt.Println("Env state:", viper.GetString("KOPS_STATE_STORE")) + } func (c *RootCmd) AddCommand(cmd *cobra.Command) { diff --git a/cmd/kops/util/factory.go b/cmd/kops/util/factory.go index 2b933f9cae..75e4de13c0 100644 --- a/cmd/kops/util/factory.go +++ b/cmd/kops/util/factory.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/golang/glog" + "github.com/spf13/viper" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/client-go/rest" gceacls "k8s.io/kops/pkg/acls/gce" @@ -64,7 +65,7 @@ Trailing slash will be trimmed.` func (f *Factory) Clientset() (simple.Clientset, error) { if f.clientset == nil { - registryPath := f.options.RegistryPath + registryPath := viper.GetString("KOPS_STATE_STORE") if registryPath == "" { return nil, field.Required(field.NewPath("State Store"), STATE_ERROR) } From 642503279543cb0c1d19a9c3b77b80acf37aeecb Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Wed, 21 Mar 2018 01:05:55 +0100 Subject: [PATCH 2/6] Add feature with config file, flags, and env order --- cmd/kops/root.go | 66 ++++++++++++++++++++++++---------------- cmd/kops/util/factory.go | 4 +-- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 229e01a511..613353b037 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -21,7 +21,6 @@ import ( "fmt" "io" "os" - "strings" "github.com/golang/glog" "github.com/spf13/cobra" @@ -120,13 +119,12 @@ func NewCmdRoot(f *util.Factory, out io.Writer) *cobra.Command { } }) - cmd.PersistentFlags().StringVar(&rootCommand.configFile, "config", "", "config file (default is $HOME/.kops.yaml)") + cmd.PersistentFlags().StringVar(&rootCommand.configFile, "config", "", "yaml config file (default is $HOME/.kops.yaml)") + viper.BindPFlag("config", cmd.PersistentFlags().Lookup("config")) + viper.SetDefault("config", "$HOME/.kops.yaml") - defaultStateStore := os.Getenv("KOPS_STATE_STORE") - if strings.HasSuffix(defaultStateStore, "/") { - defaultStateStore = strings.TrimSuffix(defaultStateStore, "/") - } - cmd.PersistentFlags().StringVarP(&rootCommand.RegistryPath, "state", "", defaultStateStore, "Location of state storage. Overrides KOPS_STATE_STORE environment variable") + cmd.PersistentFlags().StringVar(&rootCommand.RegistryPath, "state", "", "Location of state storage. Overrides KOPS_STATE_STORE environment variable") + viper.BindPFlag("KOPS_STATE_STORE", cmd.PersistentFlags().Lookup("state")) defaultClusterName := os.Getenv("KOPS_CLUSTER_NAME") cmd.PersistentFlags().StringVarP(&rootCommand.clusterName, "name", "", defaultClusterName, "Name of cluster. Overrides KOPS_CLUSTER_NAME environment variable") @@ -150,32 +148,46 @@ func NewCmdRoot(f *util.Factory, out io.Writer) *cobra.Command { // initConfig reads in config file and ENV variables if set. func initConfig() { + + // Take in order Flag --state, ENV, .kops.yaml, .kops/config + + if os.Getenv("KOPS_STATE_STORE") != "" && rootCommand.RegistryPath == "" { + rootCommand.RegistryPath = os.Getenv("KOPS_STATE_STORE") + viper.BindEnv("KOPS_STATE_STORE") + fmt.Println("From env export, s3 :", rootCommand.RegistryPath) + viper.AutomaticEnv() + } + if rootCommand.configFile != "" { // enable ability to specify config file via flag viper.SetConfigFile(rootCommand.configFile) - } - - viper.SetConfigName(".kops") // name of config file (without extension) - viper.AddConfigPath("$HOME") // adding home directory as first search path - viper.AutomaticEnv() // read in environment variables that match - - // If a config file is found, read it in. - if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using config file:", viper.ConfigFileUsed()) - } - - if rootCommand.RegistryPath != "" { - viper.SetConfigFile(rootCommand.RegistryPath) - // If a state file is found, read it in. if err := viper.ReadInConfig(); err == nil { - fmt.Println("Using state file:", viper.ConfigFileUsed()) + viper.BindEnv("KOPS_STATE_STORE") + rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") + fmt.Println("Read Default config File, s3 :", rootCommand.RegistryPath) + viper.AutomaticEnv() + } + } + if rootCommand.configFile == "" && rootCommand.RegistryPath == "" { + viper.SetConfigName(".kops") // name of config file (without extension) + viper.AddConfigPath("$HOME") // adding home directory as first search path + viper.ReadInConfig() + if err := viper.ReadInConfig(); err == nil { + viper.BindEnv("KOPS_STATE_STORE") + rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") + fmt.Println("Read .kops File, s3 :", rootCommand.RegistryPath) + viper.AutomaticEnv() + } + viper.SetConfigName("config") + viper.AddConfigPath("$HOME/.kops") // adding home/.kops/config directory as second search path + viper.ReadInConfig() + if err := viper.ReadInConfig(); err == nil { + viper.BindEnv("KOPS_STATE_STORE") + rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") + fmt.Println("Read .kops/config File, s3 :", rootCommand.RegistryPath) + viper.AutomaticEnv() } } - - viper.BindEnv("KOPS_STATE_STORE", "KOPS_STATE_STORE") - - // fmt.Println("Env state:", viper.GetString("KOPS_STATE_STORE")) - } func (c *RootCmd) AddCommand(cmd *cobra.Command) { diff --git a/cmd/kops/util/factory.go b/cmd/kops/util/factory.go index 75e4de13c0..b9b701dca9 100644 --- a/cmd/kops/util/factory.go +++ b/cmd/kops/util/factory.go @@ -22,7 +22,6 @@ import ( "strings" "github.com/golang/glog" - "github.com/spf13/viper" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/client-go/rest" gceacls "k8s.io/kops/pkg/acls/gce" @@ -65,7 +64,8 @@ Trailing slash will be trimmed.` func (f *Factory) Clientset() (simple.Clientset, error) { if f.clientset == nil { - registryPath := viper.GetString("KOPS_STATE_STORE") + registryPath := f.options.RegistryPath + fmt.Println("Config S3:", registryPath) if registryPath == "" { return nil, field.Required(field.NewPath("State Store"), STATE_ERROR) } From 7889421dcd2ceb81d46ec7bb2a40e89581319494 Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Wed, 21 Mar 2018 07:17:31 +0100 Subject: [PATCH 3/6] Update documentation with state store oonfiguration explanation --- docs/state.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/state.md b/docs/state.md index c45c445cfb..af45735914 100644 --- a/docs/state.md +++ b/docs/state.md @@ -38,4 +38,11 @@ The state store can easily be moved to a different s3 bucket. The steps for a si 3. Either run `kops edit cluster ${CLUSTER_NAME}` or edit the cluster manifest yaml file. Update `.spec.configBase` to reference the new s3 bucket. 4. Run `kops update cluster ${CLUSTER_NAME} --yes` to apply the changes to the cluster. Newly launched nodes will now retrieve their dependent files from the new S3 bucket. The files in the old bucket are now safe to be deleted. -Repeat for each cluster needing to be moved. \ No newline at end of file +Repeat for each cluster needing to be moved. + +## State store configuration + +State store configuration must be use with `kops` cli. It will be retrieve in order through: ++ command line argument `--config $HOME/yourconfig` or `--state s3://yourstatestore` ++ envirornment variable `export KOPS_STATE_STORE=s3://yourstatestore` ++ config file `.kops.yaml`, `$HONE/.kops.yaml`, `$HOME/.kops/config.yaml` \ No newline at end of file From 9829245f3f839313fe247c9437a4071f3548928e Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Wed, 21 Mar 2018 07:25:30 +0100 Subject: [PATCH 4/6] Generate make gen-cli-docs --- docs/aws.md | 2 ++ docs/cli/kops.md | 3 ++- docs/cli/kops_completion.md | 2 +- docs/cli/kops_create.md | 2 +- docs/cli/kops_create_cluster.md | 2 +- docs/cli/kops_create_instancegroup.md | 2 +- docs/cli/kops_create_secret.md | 2 +- docs/cli/kops_create_secret_dockerconfig.md | 2 +- docs/cli/kops_create_secret_encryptionconfig.md | 2 +- docs/cli/kops_create_secret_keypair.md | 2 +- docs/cli/kops_create_secret_keypair_ca.md | 2 +- docs/cli/kops_create_secret_sshpublickey.md | 2 +- docs/cli/kops_delete.md | 2 +- docs/cli/kops_delete_cluster.md | 2 +- docs/cli/kops_delete_instancegroup.md | 2 +- docs/cli/kops_delete_secret.md | 2 +- docs/cli/kops_describe.md | 2 +- docs/cli/kops_describe_secrets.md | 2 +- docs/cli/kops_edit.md | 2 +- docs/cli/kops_edit_cluster.md | 2 +- docs/cli/kops_edit_instancegroup.md | 2 +- docs/cli/kops_export.md | 2 +- docs/cli/kops_export_kubecfg.md | 2 +- docs/cli/kops_get.md | 2 +- docs/cli/kops_get_clusters.md | 2 +- docs/cli/kops_get_instancegroups.md | 2 +- docs/cli/kops_get_secrets.md | 2 +- docs/cli/kops_import.md | 2 +- docs/cli/kops_import_cluster.md | 2 +- docs/cli/kops_replace.md | 2 +- docs/cli/kops_rolling-update.md | 2 +- docs/cli/kops_rolling-update_cluster.md | 2 +- docs/cli/kops_set.md | 2 +- docs/cli/kops_set_cluster.md | 2 +- docs/cli/kops_toolbox.md | 2 +- docs/cli/kops_toolbox_bundle.md | 2 +- docs/cli/kops_toolbox_convert-imported.md | 2 +- docs/cli/kops_toolbox_dump.md | 2 +- docs/cli/kops_toolbox_template.md | 2 +- docs/cli/kops_update.md | 2 +- docs/cli/kops_update_cluster.md | 2 +- docs/cli/kops_upgrade.md | 2 +- docs/cli/kops_upgrade_cluster.md | 2 +- docs/cli/kops_validate.md | 2 +- docs/cli/kops_validate_cluster.md | 2 +- docs/cli/kops_version.md | 2 +- 46 files changed, 48 insertions(+), 45 deletions(-) diff --git a/docs/aws.md b/docs/aws.md index 514ff20007..4c9c40585a 100644 --- a/docs/aws.md +++ b/docs/aws.md @@ -271,6 +271,8 @@ to revert or recover a previous state store. aws s3api put-bucket-versioning --bucket prefix-example-com-state-store --versioning-configuration Status=Enabled ``` +Information regarding cluster state store location must be set when using `kops` cli see [state store](state.md) for further information. + ### Sharing an S3 bucket across multiple accounts It is possible to use a single S3 bucket for storing kops state for clusters diff --git a/docs/cli/kops.md b/docs/cli/kops.md index b96adf30c6..5b935e55f9 100644 --- a/docs/cli/kops.md +++ b/docs/cli/kops.md @@ -17,8 +17,9 @@ kops helps you create, destroy, upgrade and maintain production-grade, highly av ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) -h, --help help for kops + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_completion.md b/docs/cli/kops_completion.md index bfced43f3b..2e30d5e4a3 100644 --- a/docs/cli/kops_completion.md +++ b/docs/cli/kops_completion.md @@ -50,7 +50,7 @@ kops completion [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create.md b/docs/cli/kops_create.md index 443bff7e69..683e95583e 100644 --- a/docs/cli/kops_create.md +++ b/docs/cli/kops_create.md @@ -54,7 +54,7 @@ kops create -f FILENAME [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_cluster.md b/docs/cli/kops_create_cluster.md index 5ea5b00258..995580959b 100644 --- a/docs/cli/kops_create_cluster.md +++ b/docs/cli/kops_create_cluster.md @@ -112,7 +112,7 @@ kops create cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_instancegroup.md b/docs/cli/kops_create_instancegroup.md index e77e6348e2..6d767dd9ce 100644 --- a/docs/cli/kops_create_instancegroup.md +++ b/docs/cli/kops_create_instancegroup.md @@ -44,7 +44,7 @@ kops create instancegroup [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret.md b/docs/cli/kops_create_secret.md index 9819c044c7..8ca686170d 100644 --- a/docs/cli/kops_create_secret.md +++ b/docs/cli/kops_create_secret.md @@ -33,7 +33,7 @@ Create a secret ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret_dockerconfig.md b/docs/cli/kops_create_secret_dockerconfig.md index 00c0753b96..ea6f8b1a14 100644 --- a/docs/cli/kops_create_secret_dockerconfig.md +++ b/docs/cli/kops_create_secret_dockerconfig.md @@ -36,7 +36,7 @@ kops create secret dockerconfig [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret_encryptionconfig.md b/docs/cli/kops_create_secret_encryptionconfig.md index 7597d8af3f..50073af731 100644 --- a/docs/cli/kops_create_secret_encryptionconfig.md +++ b/docs/cli/kops_create_secret_encryptionconfig.md @@ -36,7 +36,7 @@ kops create secret encryptionconfig [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret_keypair.md b/docs/cli/kops_create_secret_keypair.md index 5487c61c87..a7fb36e6c3 100644 --- a/docs/cli/kops_create_secret_keypair.md +++ b/docs/cli/kops_create_secret_keypair.md @@ -28,7 +28,7 @@ Create a secret keypair ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret_keypair_ca.md b/docs/cli/kops_create_secret_keypair_ca.md index f21656c0ab..e572fe3046 100644 --- a/docs/cli/kops_create_secret_keypair_ca.md +++ b/docs/cli/kops_create_secret_keypair_ca.md @@ -34,7 +34,7 @@ kops create secret keypair ca [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_create_secret_sshpublickey.md b/docs/cli/kops_create_secret_sshpublickey.md index 081cd27a6d..0d6b9ca01b 100644 --- a/docs/cli/kops_create_secret_sshpublickey.md +++ b/docs/cli/kops_create_secret_sshpublickey.md @@ -32,7 +32,7 @@ kops create secret sshpublickey [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_delete.md b/docs/cli/kops_delete.md index 02d3d230ea..7feb5efd1c 100644 --- a/docs/cli/kops_delete.md +++ b/docs/cli/kops_delete.md @@ -39,7 +39,7 @@ kops delete -f FILENAME [--yes] [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_delete_cluster.md b/docs/cli/kops_delete_cluster.md index 9dce77e499..d925c0e959 100644 --- a/docs/cli/kops_delete_cluster.md +++ b/docs/cli/kops_delete_cluster.md @@ -35,7 +35,7 @@ kops delete cluster CLUSTERNAME [--yes] [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_delete_instancegroup.md b/docs/cli/kops_delete_instancegroup.md index 0c0cd21896..d84025e91e 100644 --- a/docs/cli/kops_delete_instancegroup.md +++ b/docs/cli/kops_delete_instancegroup.md @@ -33,7 +33,7 @@ kops delete instancegroup [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_delete_secret.md b/docs/cli/kops_delete_secret.md index 47253253b8..d84057e602 100644 --- a/docs/cli/kops_delete_secret.md +++ b/docs/cli/kops_delete_secret.md @@ -29,7 +29,7 @@ kops delete secret [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_describe.md b/docs/cli/kops_describe.md index 9736fc31b9..80a2e10055 100644 --- a/docs/cli/kops_describe.md +++ b/docs/cli/kops_describe.md @@ -25,7 +25,7 @@ Get additional information about cloud and cluster resources. ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_describe_secrets.md b/docs/cli/kops_describe_secrets.md index 99a40a57ac..ab0f0d6db5 100644 --- a/docs/cli/kops_describe_secrets.md +++ b/docs/cli/kops_describe_secrets.md @@ -30,7 +30,7 @@ kops describe secrets [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_edit.md b/docs/cli/kops_edit.md index 933bd1832d..8c209e4d27 100644 --- a/docs/cli/kops_edit.md +++ b/docs/cli/kops_edit.md @@ -35,7 +35,7 @@ Edit a resource configuration. This command changes the desired configuration in ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_edit_cluster.md b/docs/cli/kops_edit_cluster.md index 5e152f6cc7..1c25d066dd 100644 --- a/docs/cli/kops_edit_cluster.md +++ b/docs/cli/kops_edit_cluster.md @@ -37,7 +37,7 @@ kops edit cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_edit_instancegroup.md b/docs/cli/kops_edit_instancegroup.md index 8cc11e6047..067adae378 100644 --- a/docs/cli/kops_edit_instancegroup.md +++ b/docs/cli/kops_edit_instancegroup.md @@ -37,7 +37,7 @@ kops edit instancegroup [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_export.md b/docs/cli/kops_export.md index bad04cff34..c95b90aa8b 100644 --- a/docs/cli/kops_export.md +++ b/docs/cli/kops_export.md @@ -26,7 +26,7 @@ Export configurations from a cluster. ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_export_kubecfg.md b/docs/cli/kops_export_kubecfg.md index e7f4b8b12f..2f9d46cf76 100644 --- a/docs/cli/kops_export_kubecfg.md +++ b/docs/cli/kops_export_kubecfg.md @@ -30,7 +30,7 @@ kops export kubecfg CLUSTERNAME [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_get.md b/docs/cli/kops_get.md index 7edbdbf8bd..f115cdd7a0 100644 --- a/docs/cli/kops_get.md +++ b/docs/cli/kops_get.md @@ -50,7 +50,7 @@ kops get [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_get_clusters.md b/docs/cli/kops_get_clusters.md index 954de6510a..47471b3242 100644 --- a/docs/cli/kops_get_clusters.md +++ b/docs/cli/kops_get_clusters.md @@ -40,7 +40,7 @@ kops get clusters [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_get_instancegroups.md b/docs/cli/kops_get_instancegroups.md index 13bcdde9d0..e12e91c7c5 100644 --- a/docs/cli/kops_get_instancegroups.md +++ b/docs/cli/kops_get_instancegroups.md @@ -36,7 +36,7 @@ kops get instancegroups [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_get_secrets.md b/docs/cli/kops_get_secrets.md index b64bda34f7..0b97ae798e 100644 --- a/docs/cli/kops_get_secrets.md +++ b/docs/cli/kops_get_secrets.md @@ -34,7 +34,7 @@ kops get secrets [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_import.md b/docs/cli/kops_import.md index 2c54065248..44320d4669 100644 --- a/docs/cli/kops_import.md +++ b/docs/cli/kops_import.md @@ -27,7 +27,7 @@ Imports a kubernetes cluster created by kube-up.sh into a state store. This com ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_import_cluster.md b/docs/cli/kops_import_cluster.md index 1ff83d162a..b3a9ee4fb5 100644 --- a/docs/cli/kops_import_cluster.md +++ b/docs/cli/kops_import_cluster.md @@ -32,7 +32,7 @@ kops import cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_replace.md b/docs/cli/kops_replace.md index 12f40ffded..5adebc953b 100644 --- a/docs/cli/kops_replace.md +++ b/docs/cli/kops_replace.md @@ -35,7 +35,7 @@ kops replace -f FILENAME [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_rolling-update.md b/docs/cli/kops_rolling-update.md index 1ac0083db3..1c3a2f32e7 100644 --- a/docs/cli/kops_rolling-update.md +++ b/docs/cli/kops_rolling-update.md @@ -70,7 +70,7 @@ Note: terraform users will need to run all of the following commands from the sa ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_rolling-update_cluster.md b/docs/cli/kops_rolling-update_cluster.md index f4666d98ad..40361e89c3 100644 --- a/docs/cli/kops_rolling-update_cluster.md +++ b/docs/cli/kops_rolling-update_cluster.md @@ -84,7 +84,7 @@ kops rolling-update cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_set.md b/docs/cli/kops_set.md index 256f99809f..4dc72f9397 100644 --- a/docs/cli/kops_set.md +++ b/docs/cli/kops_set.md @@ -28,7 +28,7 @@ kops set does not update the cloud resources, to apply the changes use "kops upd ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_set_cluster.md b/docs/cli/kops_set_cluster.md index d89381c493..3402421c5a 100644 --- a/docs/cli/kops_set_cluster.md +++ b/docs/cli/kops_set_cluster.md @@ -34,7 +34,7 @@ kops set cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_toolbox.md b/docs/cli/kops_toolbox.md index 864825f3d5..72de4fef06 100644 --- a/docs/cli/kops_toolbox.md +++ b/docs/cli/kops_toolbox.md @@ -26,7 +26,7 @@ Misc infrequently used commands. ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_toolbox_bundle.md b/docs/cli/kops_toolbox_bundle.md index 7dbbe40d42..02501183da 100644 --- a/docs/cli/kops_toolbox_bundle.md +++ b/docs/cli/kops_toolbox_bundle.md @@ -31,7 +31,7 @@ kops toolbox bundle [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_toolbox_convert-imported.md b/docs/cli/kops_toolbox_convert-imported.md index 93f42d8a5e..9a3b1ba3c7 100644 --- a/docs/cli/kops_toolbox_convert-imported.md +++ b/docs/cli/kops_toolbox_convert-imported.md @@ -36,7 +36,7 @@ kops toolbox convert-imported [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_toolbox_dump.md b/docs/cli/kops_toolbox_dump.md index febd4a5bf6..735c4e6e2d 100644 --- a/docs/cli/kops_toolbox_dump.md +++ b/docs/cli/kops_toolbox_dump.md @@ -31,7 +31,7 @@ kops toolbox dump [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_toolbox_template.md b/docs/cli/kops_toolbox_template.md index a9800518e7..2f24063a37 100644 --- a/docs/cli/kops_toolbox_template.md +++ b/docs/cli/kops_toolbox_template.md @@ -42,7 +42,7 @@ kops toolbox template [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_update.md b/docs/cli/kops_update.md index 9427138e01..40652c7c86 100644 --- a/docs/cli/kops_update.md +++ b/docs/cli/kops_update.md @@ -26,7 +26,7 @@ Creates or updates cloud resources to match cluster desired configuration. ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_update_cluster.md b/docs/cli/kops_update_cluster.md index 3dfe47fe4e..48ab4a35d4 100644 --- a/docs/cli/kops_update_cluster.md +++ b/docs/cli/kops_update_cluster.md @@ -40,7 +40,7 @@ kops update cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_upgrade.md b/docs/cli/kops_upgrade.md index 0958643470..1fd7dc2998 100644 --- a/docs/cli/kops_upgrade.md +++ b/docs/cli/kops_upgrade.md @@ -26,7 +26,7 @@ Automates checking for and applying Kubernetes updates. This upgrades a cluster ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_upgrade_cluster.md b/docs/cli/kops_upgrade_cluster.md index f4c62ba556..21ffe3049f 100644 --- a/docs/cli/kops_upgrade_cluster.md +++ b/docs/cli/kops_upgrade_cluster.md @@ -32,7 +32,7 @@ kops upgrade cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_validate.md b/docs/cli/kops_validate.md index 4f6602cb03..89398cf24b 100644 --- a/docs/cli/kops_validate.md +++ b/docs/cli/kops_validate.md @@ -33,7 +33,7 @@ This commands validates the following components: ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_validate_cluster.md b/docs/cli/kops_validate_cluster.md index 0fbaf36875..de68e47793 100644 --- a/docs/cli/kops_validate_cluster.md +++ b/docs/cli/kops_validate_cluster.md @@ -38,7 +38,7 @@ kops validate cluster [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) diff --git a/docs/cli/kops_version.md b/docs/cli/kops_version.md index d147f95a0f..939bdb2cee 100644 --- a/docs/cli/kops_version.md +++ b/docs/cli/kops_version.md @@ -29,7 +29,7 @@ kops version [flags] ``` --alsologtostderr log to standard error as well as files - --config string config file (default is $HOME/.kops.yaml) + --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false) From 1408fc9aca5cc91563ca1e64b876e8571ca69b6d Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Tue, 27 Mar 2018 22:02:27 +0200 Subject: [PATCH 5/6] Remove unecessary println, add comment for /Users/julien and windows, update docs --- cmd/kops/root.go | 6 +----- docs/state.md | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/kops/root.go b/cmd/kops/root.go index 613353b037..791006a712 100644 --- a/cmd/kops/root.go +++ b/cmd/kops/root.go @@ -154,7 +154,6 @@ func initConfig() { if os.Getenv("KOPS_STATE_STORE") != "" && rootCommand.RegistryPath == "" { rootCommand.RegistryPath = os.Getenv("KOPS_STATE_STORE") viper.BindEnv("KOPS_STATE_STORE") - fmt.Println("From env export, s3 :", rootCommand.RegistryPath) viper.AutomaticEnv() } @@ -164,18 +163,16 @@ func initConfig() { if err := viper.ReadInConfig(); err == nil { viper.BindEnv("KOPS_STATE_STORE") rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") - fmt.Println("Read Default config File, s3 :", rootCommand.RegistryPath) viper.AutomaticEnv() } } if rootCommand.configFile == "" && rootCommand.RegistryPath == "" { viper.SetConfigName(".kops") // name of config file (without extension) - viper.AddConfigPath("$HOME") // adding home directory as first search path + viper.AddConfigPath("$HOME") // adding home directory as first search path. Assume that exist. Need to be fix for windows viper.ReadInConfig() if err := viper.ReadInConfig(); err == nil { viper.BindEnv("KOPS_STATE_STORE") rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") - fmt.Println("Read .kops File, s3 :", rootCommand.RegistryPath) viper.AutomaticEnv() } viper.SetConfigName("config") @@ -184,7 +181,6 @@ func initConfig() { if err := viper.ReadInConfig(); err == nil { viper.BindEnv("KOPS_STATE_STORE") rootCommand.RegistryPath = viper.GetString("KOPS_STATE_STORE") - fmt.Println("Read .kops/config File, s3 :", rootCommand.RegistryPath) viper.AutomaticEnv() } } diff --git a/docs/state.md b/docs/state.md index af45735914..a1a66c8e0a 100644 --- a/docs/state.md +++ b/docs/state.md @@ -45,4 +45,5 @@ Repeat for each cluster needing to be moved. State store configuration must be use with `kops` cli. It will be retrieve in order through: + command line argument `--config $HOME/yourconfig` or `--state s3://yourstatestore` + envirornment variable `export KOPS_STATE_STORE=s3://yourstatestore` -+ config file `.kops.yaml`, `$HONE/.kops.yaml`, `$HOME/.kops/config.yaml` \ No newline at end of file ++ config file `.kops.yaml`, `$HONE/.kops.yaml`, `$HOME/.kops/config.yaml` +It assume that $HOME is correctly set. \ No newline at end of file From 1db96919011d97298bf51115d378ff80d7c18499 Mon Sep 17 00:00:00 2001 From: Julien SENON Date: Wed, 25 Apr 2018 00:10:30 +0200 Subject: [PATCH 6/6] Update after make gen-cli-docs --- docs/cli/kops.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/cli/kops.md b/docs/cli/kops.md index 5b935e55f9..8da13878c3 100644 --- a/docs/cli/kops.md +++ b/docs/cli/kops.md @@ -19,7 +19,6 @@ kops helps you create, destroy, upgrade and maintain production-grade, highly av --alsologtostderr log to standard error as well as files --config string yaml config file (default is $HOME/.kops.yaml) -h, --help help for kops - --config string yaml config file (default is $HOME/.kops.yaml) --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) --log_dir string If non-empty, write log files in this directory --logtostderr log to standard error instead of files (default false)