Improve kubeadm init message

Now that we are locking down the insecure port, we should give clearer instructions on how to copy out the root owned admin.conf file, chmod it and use it.

Signed-off-by: Joe Beda <joe.github@bedafamily.com>
This commit is contained in:
Joe Beda 2017-03-13 00:33:58 +00:00
parent e1ec10f248
commit c15d011da3
No known key found for this signature in database
GPG Key ID: 4296898C63A3591D

View File

@ -21,6 +21,8 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"path" "path"
"strconv"
"text/template"
"github.com/renstrom/dedent" "github.com/renstrom/dedent"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -42,20 +44,25 @@ import (
) )
var ( var (
initDoneMsgf = dedent.Dedent(` initDoneTempl = template.Must(template.New("init").Parse(dedent.Dedent(`
Your Kubernetes master has initialized successfully! Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run: To start using your cluster, you need to run (as a regular user):
export KUBECONFIG=%s
sudo cp {{.KubeConfigPath}} $HOME/
sudo chmod $(id -u):$(id -g) $HOME/{{.KubeConfigName}}
export KUBECONFIG=$HOME/{{.KubeConfigName}}
You should now deploy a pod network to the cluster. You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
http://kubernetes.io/docs/admin/addons/ http://kubernetes.io/docs/admin/addons/
You can now join any number of machines by running the following on each node: You can now join any number of machines by running the following on each node
as root:
kubeadm join --token %s %s:%d kubeadm join --token {{.Token}} {{.MasterIP}}:{{.MasterPort}}
`)
`)))
) )
// NewCmdInit returns "kubeadm init" command. // NewCmdInit returns "kubeadm init" command.
@ -256,6 +263,13 @@ func (i *Init) Run(out io.Writer) error {
return err return err
} }
fmt.Fprintf(out, initDoneMsgf, path.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName), i.cfg.Token, i.cfg.API.AdvertiseAddress, i.cfg.API.BindPort) ctx := map[string]string{
return nil "KubeConfigPath": path.Join(kubeadmapi.GlobalEnvParams.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName),
"KubeConfigName": kubeadmconstants.AdminKubeConfigFileName,
"Token": i.cfg.Token,
"MasterIP": i.cfg.API.AdvertiseAddress,
"MasterPort": strconv.Itoa(int(i.cfg.API.BindPort)),
}
return initDoneTempl.Execute(out, ctx)
} }