Learn about kuberc, the new alpha feature in Kubernetes 1.33 that lets you customize kubectl! Discover how to use ~/.kube/kuberc to create aliases, set default flags, and streamline your Kubernetes workflow.
Learn about kuberc, the new alpha feature in Kubernetes 1.33 that lets you customize kubectl! Discover how to use ~/.kube/kuberc to create aliases, set default flags, and streamline your Kubernetes workflow.
For years, Kubernetes users have wished for a dedicated way to personalize their kubectl command-line experience, much like .bashrc
for shells or .gitconfig
for Git. That wish is now taking its first official steps: kuberc has arrived as an alpha feature in Kubernetes 1.33.
This is a significant development for anyone who spends their day interacting with Kubernetes clusters, promising a more streamlined and efficient workflow, a native way of creating aliases and shortcuts.
kuberc is a configuration file that kubectl can now read on startup to apply user-defined preferences. The primary goal is to separate your personal kubectl settings—like aliases and default flags—from your kubeconfig file, which is primarily for cluster connection details and authentication.
With Kubernetes 1.33 (codenamed “Octarine”), kubectl can be configured to look for a ~/.kube/kuberc
file (or a custom path) to load these personalizations.
The introduction of kuberc brings several powerful advantages:
Custom Aliases: Define short, memorable aliases for frequently used kubectl commands (e.g., klogs for kubectl logs –follow –tail=50).
Smarter Defaults: Set default flags for subcommands. For instance, you can make kubectl apply always use –server-side or have kubectl get default to a specific output format like YAML.
Cleaner kubeconfig: Keeps your kubeconfig files focused on cluster access, while your personal CLI preferences live separately in kuberc.
Consistency Across Clusters: Your kuberc settings apply universally, no matter which cluster context you’re using.
Team Standardization (Potential): Teams can share base kuberc files to establish common aliases and defaults, improving collaboration and onboarding.
Reduced Typing & Errors: Simplifies complex commands, saving keystrokes and minimizing the chance of typos.
Since kuberc is an alpha feature in Kubernetes 1.33, you need to opt-in to use it:
Enable kuberc: Set the environment variable KUBECTL_KUBERC=true.
export KUBECTL_KUBERC=true
You might want to add this to your shell’s profile file (e.g., ~/.bashrc
, ~/.zshrc
) to enable it automatically in new terminal sessions.
Create Your kuberc File: By default, kubectl will look for this file at ~/.kube/kuberc
. You can also specify a different path using the --kuberc <path-to-your-kuberc-file>
flag with your kubectl commands.
The kuberc file uses a YAML format. Here’s a basic structure based on KEP-3104:
# ~/.kube/kuberc
apiVersion: kubectl.config.k8s.io/v1alpha1
kind: Preference
aliases:
- name: klogs
command: logs
appendArgs:
- --follow
- --tail=50
- name: kgp
command: get
appendArgs:
- pods
overrides:
- command: apply
flags:
- name: server-side
default: "true"
- command: delete
flags:
- name: interactive
default: "true"
Example Usage with the above kuberc:
kubectl klogs my-pod-name
would expand to kubectl logs –follow –tail=50 my-pod-name
kubectl kgp -n my-namespace
would expand to kubectl get pods -n my-namespace
kubectl apply -f my-manifest.yaml
would automatically behave like kubectl apply –server-side=true -f my-manifest.yaml
kubectl delete pod my-pod
would prompt for confirmation as if kubectl delete –interactive=true pod my-pod was run.
Important Note for Alpha: As an alpha feature, the exact syntax and capabilities might evolve. Also, be aware that kubectl auto-completion for aliases defined in kuberc might not be fully supported yet.
The arrival of kuberc in Kubernetes 1.33 (alpha) is a game-changer for personalizing your kubectl workflow. It provides a clean, official way to manage aliases and default command behaviors, separate from your cluster configurations.
You can visit the KEP-3104 to learn more about the feature and its development. If you’ve updated your kubectl to 1.33 or newer, enable the KUBECTL_KUBERC
environment variable and start experimenting with your own ~/.kube/kuberc
file today.