#511·kubectx

kubectx change indent of yaml file (osx arm)

Author: victorcisternasCreated Aug 31, 2026Updated Sep 16, 2026

Hi,

First of all, I am grateful for kubectx, it makes things easier for us.

When I switch contexts using kubectx, the YAML file's indentation changes, extra spaces are added. This doesn't happen with the command kubectl config use-context k8sxxx1.

NOTE: I use the configuration with the KUBECONFIG variable in .zprofile file.

Simple example:

Original ident of file:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: xxxxxxx
    server: https://xxx.xxx.xxx.xxx:6443
  name: k8sxxx1
- cluster:
    certificate-authority-data: xxxxxxx
    server: https://xxx.xxx.xxx.xxx:6443
  name: k8sxxx2
....

Command: kubectx k8sxxx1

apiVersion: v1
clusters:
  - cluster:
        certificate-authority-data: xxxxxxx
        server: https://xxx.xxx.xxx.xxx:6443
    name: k8sxxx1
  - cluster:
        certificate-authority-data: xxxxxxx
        server: https://xxx.xxx.xxx.xxx:6443
    name: k8sxxx2
....

OSX

ProductName:		macOS
ProductVersion:		26.5.2
BuildVersion:		25F84
Darwin 172-16-49-17.lan.uchile.cl 25.5.0 Darwin Kernel Version 25.5.0: Tue Jun  9 22:28:24 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T6020 arm64

kubectx installed with brew:

kubectx ✔ 0.11.0 (15 files, 50.7MB) [Linked]

I used with the console: iTerm2 or Terminal