Change:
The command provides a flag but this doesn't do anything. most likely the flag shouldn't exist. I have no idea how kustomize could be useful here to start a single pod. This creates a pod, and shows that is ignored: No response <details</details<detailsAzure, K3OS</details<detailsOSX 11.6.1 (Big Sur) </detailsNo response No response No response
/sig cli
This comes from the inclusion of DeleteFlags: brings in FilenameFlags: has Kustomize, resulting in the flag: I suspect there are many flags from DeleteFlags that don't really apply to . : Not sure what this would do : seems to be ignored and : doesn't seem to be used : doesn't seem to be used : also probably doesn't apply There might be others as well...
It seems to delete object which created by command.
I agree, As far as I can see, , and have this deleteFlags exposure.
/assign
/reopen
Reopened this issue. <detailsIn response to : /reopen Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/triage accepted

Discussion:
"k8s.io/apimachinery/pkg/watch" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/resource" <del> "k8s.io/client-go/kubernetes" </del> corev1client "k8s.io/client-go/kubernetes/typed/core/v1" "k8s.io/client-go/tools/cache" watchtools "k8s.io/client-go/tools/watch"

var metadataAccessor = meta.NewAccessor() <ins> var attachFunc = attach.DefaultAttachFunc </ins> type RunObject struct { Object  runtime.Object Mapping *meta.RESTMapping

PrintFlags  *genericclioptions.PrintFlags RecordFlags *genericclioptions.RecordFlags <del> DeleteFlags   *cmddelete.DeleteFlags </del> DeleteOptions *cmddelete.DeleteOptions DryRunStrategy cmdutil.DryRunStrategy

func NewRunOptions(streams genericclioptions.IOStreams) *RunOptions { return &RunOptions{ PrintFlags:  genericclioptions.NewPrintFlags("created").WithTypeSetter(scheme.Scheme), <del> DeleteFlags: cmddelete.NewDeleteFlags("to use to replace the resource."), </del> RecordFlags: genericclioptions.NewRecordFlags(), Recorder: genericclioptions.NoopRecorder{},

}, } <del> o.DeleteFlags.AddFlags(cmd) </del> o.PrintFlags.AddFlags(cmd) o.RecordFlags.AddFlags(cmd)

return printer.PrintObj(obj, o.Out) } <del> deleteOpts, err := o.DeleteFlags.ToOptions(dynamicClient, o.IOStreams) if err != nil { return err </del> <ins> o.DeleteOptions = &cmddelete.DeleteOptions{ CascadingStrategy: metav1.DeletePropagationBackground, DynamicClient:     dynamicClient, GracePeriod:       -1, IgnoreNotFound:    true, IOStreams:         o.IOStreams, Quiet:             o.Quiet, Timeout:           time.Duration(0), WaitForDeletion:   false, </ins> } <del> deleteOpts.IgnoreNotFound = true deleteOpts.WaitForDeletion = false deleteOpts.GracePeriod = -1 deleteOpts.Quiet = o.Quiet o.DeleteOptions = deleteOpts </del> return nil }

if o.Attach { if remove { <del> defer o.removeCreatedObjects(f, createdObjects) </del> <ins> defer func() { if err := o.removeCreatedObjects(f, createdObjects); err != nil { fmt.Fprintf(o.ErrOut, "Delete failed: %vn", err) } }() </ins> } opts := &attach.AttachOptions{

return err } opts.Config = config <del> opts.AttachFunc = attach.DefaultAttachFunc </del> <ins> opts.AttachFunc = attachFunc </ins> <del> clientset, err := kubernetes.NewForConfig(config) </del> <ins> clientset, err := f.KubernetesClientSet() </ins> if err != nil { return err }

apiequality "k8s.io/apimachinery/pkg/api/equality" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" <ins> "k8s.io/apimachinery/pkg/runtime/schema" </ins> "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/cli-runtime/pkg/genericclioptions" restclient "k8s.io/client-go/rest" "k8s.io/client-go/rest/fake" <ins> "k8s.io/client-go/tools/remotecommand" "k8s.io/kubectl/pkg/cmd/attach" </ins> "k8s.io/kubectl/pkg/cmd/delete" cmdtesting "k8s.io/kubectl/pkg/cmd/testing" cmdutil "k8s.io/kubectl/pkg/cmd/util"

} } <ins> func TestRunAttach(t *testing.T) { tests := []struct { name                string rm                  bool quiet               bool deleteErrorMessage  string expectedDeleteCount int expectedOut         string expectedErrOut      string }{ { name:                "test attach", rm:                  false, quiet:               false, expectedDeleteCount: 0, expectedOut:         "", expectedErrOut:      "If you don't see a command prompt, try pressing enter.n", }, { name:                "test attach with quiet", rm:                  false, quiet:               true, expectedDeleteCount: 0, expectedOut:         "", expectedErrOut:      "", }, { name:                "test attach with rm", rm:                  true, quiet:               false, expectedDeleteCount: 1, expectedOut:         "pod "foo" deletedn", expectedErrOut:      "If you don't see a command prompt, try pressing enter.n", }, { name:                "test attach with rm should not print message if quiet is specified", rm:                  true, quiet:               true, expectedDeleteCount: 1, expectedOut:         "", expectedErrOut:      "", }, { name:                "error should be displayed if delete fails", rm:                  true, quiet:               false, deleteErrorMessage:  "delete error message", expectedDeleteCount: 1, expectedOut:         "", expectedErrOut:      "If you don't see a command prompt, try pressing enter.nDelete failed: delete error messagen", }, } fakePod := &corev1.Pod{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", Kind:       "Pod", }, ObjectMeta: metav1.ObjectMeta{ Name:      "foo", Namespace: "default", }, Spec: corev1.PodSpec{ Containers: []corev1.Container{ { Name: "bar", }, }, }, Status: corev1.PodStatus{ Phase: corev1.PodRunning, Conditions: []corev1.PodCondition{ { Type:   corev1.PodReady, Status: corev1.ConditionTrue, }, }, }, } for _, test := range tests { t.Run(test.name, func(tt *testing.T) { postCount := 0 attachCount := 0 deleteCount := 0 attachFunc = func(o *attach.AttachOptions, containerToAttach *corev1.Container, raw bool, sizeQueue remotecommand.TerminalSizeQueue) func() error { if containerToAttach.Name != "bar" { tt.Fatalf("expected attach to container name "bar", but got %q", containerToAttach.Name) } return func() error { attachCount++ return nil } } tf := cmdtesting.NewTestFactory().WithNamespace("test") defer tf.Cleanup() codec := scheme.Codecs.LegacyCodec(scheme.Scheme.PrioritizedVersionsAllGroups()...) ns := scheme.Codecs.WithoutConversion() tf.Client = &fake.RESTClient{ GroupVersion:         schema.GroupVersion{Version: ""}, NegotiatedSerializer: ns, Client: fake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { switch p, m := req.URL.Path, req.Method; { case m == "POST" && p == "/namespaces/test/pods": postCount++ body := cmdtesting.ObjBody(codec, fakePod) return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil case m == "GET" && p == "/api/v1/namespaces/default/pods": event := &metav1.WatchEvent{ Type:   "ADDED", Object: runtime.RawExtension{Object: fakePod}, } body := cmdtesting.ObjBody(codec, event) return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil case m == "GET" && p == "/namespaces/default/pods/foo": body := cmdtesting.ObjBody(codec, fakePod) return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil case m == "DELETE" && p == "/namespaces/default/pods/foo": deleteCount++ if test.deleteErrorMessage != "" { body := cmdtesting.ObjBody(codec, &metav1.Status{ Status:  metav1.StatusFailure, Message: test.deleteErrorMessage, }) return &http.Response{StatusCode: http.StatusInternalServerError, Header: cmdtesting.DefaultHeader(), Body: body}, nil } else { body := cmdtesting.ObjBody(codec, fakePod) return &http.Response{StatusCode: http.StatusOK, Header: cmdtesting.DefaultHeader(), Body: body}, nil } default: tt.Errorf("unexpected request: %s %#vn%#v", req.Method, req.URL, req) return nil, fmt.Errorf("unexpected request") } }), } tf.ClientConfigVal = &restclient.Config{ ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Version: ""}, NegotiatedSerializer: ns}, } streams, _, bufOut, bufErr := genericclioptions.NewTestIOStreams() cmdutil.BehaviorOnFatal(func(str string, code int) { bufErr.Write([]byte(str)) }) cmd := NewCmdRun(tf, streams) cmd.Flags().Set("image", "test-image") cmd.Flags().Set("attach", "true") if test.rm { cmd.Flags().Set("rm", "true") } if test.quiet { cmd.Flags().Set("quiet", "true") } parentCmd := cobra.Command{} parentCmd.AddCommand(cmd) cmd.Run(cmd, []string{"test-pod"}) if postCount != 1 { tt.Fatalf("expected 1 post request, but got %d", postCount) } if attachCount != 1 { tt.Fatalf("expected 1 attach call, but got %d", attachCount) } if deleteCount != test.expectedDeleteCount { tt.Fatalf("expected %d delete requests, but got %d", test.expectedDeleteCount, deleteCount) } if bufErr.String() != test.expectedErrOut { tt.Fatalf("unexpected error. got: %q, expected: %q", bufErr.String(), test.expectedErrOut) } if bufOut.String() != test.expectedOut { tt.Fatalf("unexpected output. got: %q, expected: %q", bufOut.String(), test.expectedOut) } }) } } </ins> func TestRunOverride(t *testing.T) { tests := []struct { name           string