Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Change bootkube recover flag to --recovery-dir. (#589)
Browse files Browse the repository at this point in the history
Field ops reports that people find the --asset-dir flag confusing; they
think that means you need to pass in the same --asset-dir that was used
to create the cluster.
  • Loading branch information
diegs authored Jun 16, 2017
1 parent 88590b0 commit 8124547
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ bootkube recover --help
Recover from an external running etcd cluster:

```
bootkube recover --asset-dir=recovered --etcd-servers=http://127.0.0.1:2379 --kubeconfig=/etc/kubernetes/kubeconfig
bootkube recover --recovery-dir=recovered --etcd-servers=http://127.0.0.1:2379 --kubeconfig=/etc/kubernetes/kubeconfig
```

Recover from a running apiserver (i.e. if the scheduler pods are all down):

```
bootkube recover --asset-dir=recovered --kubeconfig=/etc/kubernetes/kubeconfig
bootkube recover --recovery-dir=recovered --kubeconfig=/etc/kubernetes/kubeconfig
```

Recover from an etcd backup when self hosted etcd is enabled:

```
bootkube recover --asset-dir=recovered --etcd-backup-file=backup --kubeconfig=/etc/kubernetes/kubeconfig
bootkube recover --recovery-dir=recovered --etcd-backup-file=backup --kubeconfig=/etc/kubernetes/kubeconfig
```

For a complete recovery example please see the [hack/multi-node/bootkube-test-recovery](hack/multi-node/bootkube-test-recovery) and the [hack/multi-node/bootkube-test-recovery-self-hosted-etcd](hack/multi-node/bootkube-test-recovery-self-hosted-etcd) scripts.
Expand Down
12 changes: 6 additions & 6 deletions cmd/bootkube/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ var (
cmdRecover = &cobra.Command{
Use: "recover",
Short: "Recover a self-hosted control plane",
Long: "This command reads control plane manifests from a running apiserver or etcd and writes them to asset-dir. Users can then use `bootkube start` pointed at this asset-dir to re-the a self-hosted cluster. Please see the project README for more details and examples.",
Long: "This command reads control plane manifests from a running apiserver or etcd and writes them to recovery-dir. Users can then use `bootkube start` pointed at this recovery-dir to re-the a self-hosted cluster. Please see the project README for more details and examples.",
PreRunE: validateRecoverOpts,
RunE: runCmdRecover,
SilenceUsage: true,
}

recoverOpts struct {
assetDir string
recoveryDir string
etcdCAPath string
etcdCertificatePath string
etcdPrivateKeyPath string
Expand All @@ -44,7 +44,7 @@ var (

func init() {
cmdRoot.AddCommand(cmdRecover)
cmdRecover.Flags().StringVar(&recoverOpts.assetDir, "asset-dir", "", "Output path for writing recovered cluster assets.")
cmdRecover.Flags().StringVar(&recoverOpts.recoveryDir, "recovery-dir", "", "Output path for writing recovered cluster assets.")
cmdRecover.Flags().StringVar(&recoverOpts.etcdCAPath, "etcd-ca-path", "", "Path to an existing PEM encoded CA that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-certificate-path and --etcd-private-key-path, and must have etcd configured to use TLS with matching secrets.")
cmdRecover.Flags().StringVar(&recoverOpts.etcdCertificatePath, "etcd-certificate-path", "", "Path to an existing certificate that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-ca-path and --etcd-private-key-path, and must have etcd configured to use TLS with matching secrets.")
cmdRecover.Flags().StringVar(&recoverOpts.etcdPrivateKeyPath, "etcd-private-key-path", "", "Path to an existing private key that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-ca-path and --etcd-certificate-path, and must have etcd configured to use TLS with matching secrets.")
Expand Down Expand Up @@ -111,12 +111,12 @@ func runCmdRecover(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
return as.WriteFiles(recoverOpts.assetDir)
return as.WriteFiles(recoverOpts.recoveryDir)
}

func validateRecoverOpts(cmd *cobra.Command, args []string) error {
if recoverOpts.assetDir == "" {
return errors.New("missing required flag: --asset-dir")
if recoverOpts.recoveryDir == "" {
return errors.New("missing required flag: --recovery-dir")
}
if (recoverOpts.etcdCAPath != "" || recoverOpts.etcdCertificatePath != "" || recoverOpts.etcdPrivateKeyPath != "") && (recoverOpts.etcdCAPath == "" || recoverOpts.etcdCertificatePath == "" || recoverOpts.etcdPrivateKeyPath == "") {
return errors.New("you must specify either all or none of --etcd-ca-path, --etcd-certificate-path, and --etcd-private-key-path")
Expand Down
2 changes: 1 addition & 1 deletion hack/multi-node/bootkube-test-recovery
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ echo

scp -q -F ssh_config ../../_output/bin/linux/bootkube cluster/auth/kubeconfig cluster/tls/etcd-* core@$HOST:/home/core
ssh -q -F ssh_config core@$HOST "GLOG_v=${GLOG_v} /home/core/bootkube recover \
--asset-dir=/home/core/recovered \
--recovery-dir=/home/core/recovered \
--etcd-ca-path=/home/core/etcd-ca.crt \
--etcd-certificate-path=/home/core/etcd-client.crt \
--etcd-private-key-path=/home/core/etcd-client.key \
Expand Down
4 changes: 2 additions & 2 deletions hack/multi-node/bootkube-test-recovery-self-hosted-etcd
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ echo

scp -q -F ssh_config ../../_output/bin/linux/bootkube cluster/auth/kubeconfig cluster/etcdbackup core@$HOST:/home/core
ssh -q -F ssh_config core@$HOST "sudo GLOG_v=${GLOG_v} /home/core/bootkube recover \
--asset-dir=/home/core/recovered \
--recovery-dir=/home/core/recovered \
--etcd-backup-file=/home/core/etcdbackup \
--kubeconfig=/home/core/kubeconfig 2>> /home/core/recovery.log"

Expand All @@ -53,4 +53,4 @@ ssh -q -F ssh_config core@$HOST "sudo GLOG_v=${GLOG_v} /home/core/bootkube start

echo
echo "The cluster should now be recovered. You should be able to access the cluster again using:"
echo "kubectl --kubeconfig=cluster/auth/kubeconfig get nodes"
echo "kubectl --kubeconfig=cluster/auth/kubeconfig get nodes"

0 comments on commit 8124547

Please sign in to comment.