diff --git a/pkg/kubectl/cmd/exec.go b/pkg/kubectl/cmd/exec.go index eb6c676c5b0..8d4014f9b1e 100644 --- a/pkg/kubectl/cmd/exec.go +++ b/pkg/kubectl/cmd/exec.go @@ -167,20 +167,20 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s } } - cmdParent := cmd.Parent() - if cmdParent != nil { - p.FullCmdName = cmdParent.CommandPath() - } - if len(p.FullCmdName) > 0 && cmdutil.IsSiblingCommandExists(cmd, "describe") { - p.SuggestedCmdUsage = fmt.Sprintf("Use '%s describe pod/%s' to see all of the containers in this pod.", p.FullCmdName, p.PodName) - } - namespace, _, err := f.DefaultNamespace() if err != nil { return err } p.Namespace = namespace + cmdParent := cmd.Parent() + if cmdParent != nil { + p.FullCmdName = cmdParent.CommandPath() + } + if len(p.FullCmdName) > 0 && cmdutil.IsSiblingCommandExists(cmd, "describe") { + p.SuggestedCmdUsage = fmt.Sprintf("Use '%s describe pod/%s -n %s' to see all of the containers in this pod.", p.FullCmdName, p.PodName, p.Namespace) + } + config, err := f.ClientConfig() if err != nil { return err