8000 Add a way to print the current kubectl command argument string in a reusable way for kuberctl · Issue #1748 · kubernetes/kubectl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add a way to print the current kubectl command argument string in a reusable way for kuberctl #1748
Open
@koba1t

Description

@koba1t

What would you like to be added:

I want to add a feature to kubectl that outputs a command-line string capable of reproducing the current execution context of a kubectl command in environments where kuberc is not configured, effectively replicating the functionality currently provided by kuberc.

Why is this needed:

In Kubernetes, SREs sometimes share kubectl command snippets within their teams to consistently verify the state of clusters and applications.

Example
## Check running specific production pods
$ kubectl get po -n app-01 --field-selector status.phase=Running -l environment=production

However, as kuberctl becomes more widely used, individual kubectl command snippets may become unshareable. Therefore, it would be beneficial to have a method to share requests made by kubectl even without kuberc configuration.

Design Proposal:

## kuberc
apiVersion: kubectl.config.k8s.io/v1alpha1
kind: Preference

aliases:
  - name: getdbprod
    command: get
    prependArgs:
    - pods
    flags:
    - name: labels
      default: what=database
    - name: namespace
      default: us-2-production

overrides:
  - command: apply
    flags:
      - name: server-side
        default: "true"
  - command: delete
    flags:
      - name: interactive
        default: "true"

snippetOutput: true ## example

Example output

$ KUBECTL_KUBERC=true kubectl getdbprod
## Execute: $ kubectl get pods -l what=database -n us-2-production
...
$ KUBECTL_KUBERC=true kubectl apply -f -
## Execute: $ kubectl apply --server-side=true -f -
...

link

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0