1

From "Extending kubectl with plugins":

It is currently not possible to create plugins that overwrite existing kubectl commands. [...] Due to this limitation, it is also not possible to use plugins to add new subcommands to existing kubectl commands. For example, adding a subcommand kubectl create foo by naming your plugin kubectl-create-foo will cause that plugin to be ignored.

-- https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/#limitations

Is there another way to extend kubectl create?

ciis0
  • 311
  • 1
  • 9
  • Well, you answered(the official documentation) the question. you might need to tweak your approach a bit. Care to share what you want to achieve? – P.... Jun 28 '22 at 17:57
  • You can just use a script, why use it as a plugin? anyway, plugins are local to the client machine so is any other script. – P.... Jun 28 '22 at 18:07
  • it is not extensible via kubectl plugins, but I was looking if there maybe is another way to add an "generator"(?) to `kubectl create`. I checked the source, it really seems kubectl create subcommands are hardcoded :( – ciis0 Jun 28 '22 at 22:16

1 Answers1

1

It does not look like that in source code, all sub-commands are currently registered explicitly (cf.):

    // create subcommands
    cmd.AddCommand(NewCmdCreateNamespace(f, ioStreams))
    cmd.AddCommand(NewCmdCreateQuota(f, ioStreams))
    cmd.AddCommand(NewCmdCreateSecret(f, ioStreams))
    cmd.AddCommand(NewCmdCreateConfigMap(f, ioStreams))
    cmd.AddCommand(NewCmdCreateServiceAccount(f, ioStreams))
    cmd.AddCommand(NewCmdCreateService(f, ioStreams))
    cmd.AddCommand(NewCmdCreateDeployment(f, ioStreams))
    cmd.AddCommand(NewCmdCreateClusterRole(f, ioStreams))
    cmd.AddCommand(NewCmdCreateClusterRoleBinding(f, ioStreams))
    cmd.AddCommand(NewCmdCreateRole(f, ioStreams))
    cmd.AddCommand(NewCmdCreateRoleBinding(f, ioStreams))
    cmd.AddCommand(NewCmdCreatePodDisruptionBudget(f, ioStreams))
    cmd.AddCommand(NewCmdCreatePriorityClass(f, ioStreams))
    cmd.AddCommand(NewCmdCreateJob(f, ioStreams))
    cmd.AddCommand(NewCmdCreateCronJob(f, ioStreams))
    cmd.AddCommand(NewCmdCreateIngress(f, ioStreams))
    cmd.AddCommand(NewCmdCreateToken(f, ioStreams))
    return cmd
ciis0
  • 311
  • 1
  • 9