diff --git a/cmd/plugin/kubectl/kubectl.go b/cmd/plugin/kubectl/kubectl.go index 1171e9218..7a702f318 100644 --- a/cmd/plugin/kubectl/kubectl.go +++ b/cmd/plugin/kubectl/kubectl.go @@ -32,7 +32,11 @@ import ( // PodExecString takes a pod and a command, uses kubectl exec to run the command in the pod // and returns stdout as a string func PodExecString(flags *genericclioptions.ConfigFlags, pod *apiv1.Pod, container string, args []string) (string, error) { - args = append([]string{"exec", "-n", pod.Namespace, "-c", container, pod.Name}, args...) + params := []string{"exec", "-n", pod.Namespace, pod.Name} + if len(container) > 0 { + params = append(params, "-c", container) + } + args = append(params, args...) return ExecToString(flags, args) } diff --git a/cmd/plugin/util/util.go b/cmd/plugin/util/util.go index e1910140d..4fd21c4e5 100644 --- a/cmd/plugin/util/util.go +++ b/cmd/plugin/util/util.go @@ -31,7 +31,7 @@ import ( const ( DefaultIngressDeploymentName = "ingress-nginx-controller" DefaultIngressServiceName = "ingress-nginx-controller" - DefaultIngressContainerName = "controller" + DefaultIngressContainerName = "" ) // IssuePrefix is the github url that we can append an issue number to to link to it @@ -131,7 +131,7 @@ func AddSelectorFlag(cmd *cobra.Command) *string { // AddContainerFlag adds a --container flag to a cobra command func AddContainerFlag(cmd *cobra.Command) *string { v := "" - cmd.Flags().StringVar(&v, "container", DefaultIngressContainerName, "The name of the ingress-nginx controller container") + cmd.Flags().StringVarP(&v, "container", "c", DefaultIngressContainerName, "The name of the ingress-nginx controller container") return &v }