kubectl-setup
Use when the user asks to "install kubectl", "set up kubens", "configure kubernetes CLI tools", or needs to make kubectl/kubens/kubectx replicable via dotfiles Ansible package list.
Файлы1
Открыть в GitHubSKILL.md.claude/skills/kubectl-setup/SKILL.md
GitHubkubectl + kubens/kubectx Setup
State (as of 2026-08)
kubectl1.36.1 — installed viabrew install kubectlkubectx/kubens0.11.0 — installed, managed via Ansiblek9s— installed, managed via Ansible
Package list (ansible/group_vars/all/main.yml)
All three tools are in brew_packages (see ADR-0002 — brew/Brewfile was removed,
group_vars is the source of truth):
brew_packages:
- k9s
- kubectl
- kubectx
Aliases
k alias comes from the OMZ kubectl plugin (already in .zshrc plugins list).
Do NOT duplicate it in aliases.zsh — it's already provided by OMZ.
In zsh/aliases.zsh:
alias kns='kubens'
alias kx='kubectx'
Replicating on a new machine
Handled by the install tag in the Ansible playbook (see ansible/README.md):
ansible-playbook playbooks/site.yml --limit <profile>-mac --tags install
Aliases come automatically from stow + OMZ kubectl plugin.
Notes
colima start --kubernetescreates a separate local cluster context navigable withkxkubectxuses~/.kube/config— contexts are added by cloud CLIs (e.g.aws eks update-kubeconfig)- zsh completions installed automatically by Homebrew to
/opt/homebrew/share/zsh/site-functions
~/.kube/config is Ansible-templated, not hand-managed
Rendered by the stow role from ansible/roles/stow/templates/kubeconfig.j2 (task
"Template ~/.kube/config"). File header says "DO NOT EDIT BY HAND" — edit the
template and re-run --tags stow, not the file directly.
Contexts:
services-eks-cluster-test/services-eks-cluster-staging— work-only, gated{% if 'work' in group_names %}. Auth isaws eks get-token(AWS_PROFILE=staging).homelab— both profiles, gated{% if homelab_client_certificate_data is defined %}. Server is the Tailscale IP100.74.130.73:6443(not the LAN IP) so it resolves from either Mac. Client cert/key come fromgroup_vars/all/vault.sops.yaml(homelab_client_certificate_data,homelab_client_key_data), inserted withsops --set(see ansible-dotfiles-setup skill).
current-context picks services-eks-cluster-staging on work-mac, homelab otherwise.
Gotcha — gate all three sections (clusters/contexts/users) consistently. The
kubeconfig YAML splits one logical context into three top-level blocks. Gating only
clusters: and leaving contexts:/users: ungated (or vice versa) renders a context
that references a cluster/user name which doesn't exist in the file — kubectl then
lists a broken context. Always mirror the same {% if %} on all three blocks for a
given context.