kuberc: an exciting new feature for kubectl

Kubernetes 1.33, scheduled for late April, introduces kuberc, a new feature that allows you to customize kubectl. This feature, described in KEP-3104, enables you to create aliases and enforce options for kubectl subcommands. This customization is possible through a .kube/kuberc file in your home directory (the path can be modified with the --kuberc flag). The example below demonstrates how to create an alias for creating a namespace with a predefined name, and how to force the interactive behavior of the kubectl delete command: apiVersion: kubectl.config.k8s.io/v1alpha1 kind: Preference # alias "kubectl crns" for "kubectl create namespace test-kuberc-ns" aliases: - name: crns command: create namespace appendArgs: - test-kuberc-ns # Force the --interactive=true flag for kubectl delete overrides: - command: delete flags: - name: interactive default: "true" Let’s take the example of the kubectl delete command. Kubernetes maintainers cannot enable confirmation before deletion by default, as it would disrupt many CI/CD processes. However, with kuberc’s customization options, you can enable this feature when needed, without affecting other users. This feature will be available in alpha with Kubernetes 1.33 and can be activated using the environment variable KUBECTL_KUBERC=true. Note that, for now, kubectl’s auto-completion does not work with aliases defined by kuberc.

Apr 8, 2025 - 15:54
 0
kuberc: an exciting new feature for kubectl

Kubernetes 1.33, scheduled for late April, introduces kuberc, a new feature that allows you to customize kubectl. This feature, described in KEP-3104, enables you to create aliases and enforce options for kubectl subcommands.

This customization is possible through a .kube/kuberc file in your home directory (the path can be modified with the --kuberc flag).

The example below demonstrates how to create an alias for creating a namespace with a predefined name, and how to force the interactive behavior of the kubectl delete command:

apiVersion: kubectl.config.k8s.io/v1alpha1
kind: Preference
# alias "kubectl crns" for "kubectl create namespace test-kuberc-ns"
aliases:
  - name: crns
    command: create namespace
    appendArgs:
      - test-kuberc-ns
# Force the --interactive=true flag for kubectl delete
overrides:
  - command: delete
    flags:
      - name: interactive
        default: "true"

kuberc in action

Let’s take the example of the kubectl delete command. Kubernetes maintainers cannot enable confirmation before deletion by default, as it would disrupt many CI/CD processes. However, with kuberc’s customization options, you can enable this feature when needed, without affecting other users.

This feature will be available in alpha with Kubernetes 1.33 and can be activated using the environment variable KUBECTL_KUBERC=true. Note that, for now, kubectl’s auto-completion does not work with aliases defined by kuberc.