From 10102cef3cebd6952821a3d769e107b2c775e1a9 Mon Sep 17 00:00:00 2001 From: Marques Johansson Date: Tue, 19 Mar 2019 17:27:37 -0400 Subject: [PATCH] Restore machine readability to the print-join-command output The output of `kubeadm token create --print-join-command` should be usable by batch scripts. This issue was pointed out in: https://github.com/kubernetes/kubeadm/issues/1454 --- cmd/kubeadm/app/cmd/token.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/kubeadm/app/cmd/token.go b/cmd/kubeadm/app/cmd/token.go index de6916c412b..ec95277b51f 100644 --- a/cmd/kubeadm/app/cmd/token.go +++ b/cmd/kubeadm/app/cmd/token.go @@ -225,7 +225,7 @@ func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, c return err } - // if --print-join-command was specified, print the full `kubeadm join` command + // if --print-join-command was specified, print a machine-readable full `kubeadm join` command // otherwise, just print the token if printJoinCommand { skipTokenPrint := false @@ -233,6 +233,8 @@ func RunCreateToken(out io.Writer, client clientset.Interface, cfgPath string, c if err != nil { return errors.Wrap(err, "failed to get join command") } + joinCommand = strings.ReplaceAll(joinCommand, "\\\n", "") + joinCommand = strings.ReplaceAll(joinCommand, "\t", "") fmt.Fprintln(out, joinCommand) } else { fmt.Fprintln(out, internalcfg.BootstrapTokens[0].Token.String())