diff --git a/.config/fastfetch/config.jsonc b/.config/fastfetch/config.jsonc index d156783..3bb5499 100644 --- a/.config/fastfetch/config.jsonc +++ b/.config/fastfetch/config.jsonc @@ -45,6 +45,11 @@ "key": "Docker", "text": "docker --version 2>/dev/null | cut -d' ' -f3 | tr -d ','" }, + { + "type": "command", + "key": "Kubectl", + "text": "kubectl version --client --output=yaml 2>/dev/null | grep gitVersion | cut -d' ' -f4" + }, { "type": "command", "key": "Go", diff --git a/.config/fish/completions/kubectl.fish b/.config/fish/completions/kubectl.fish new file mode 120000 index 0000000..04f9499 --- /dev/null +++ b/.config/fish/completions/kubectl.fish @@ -0,0 +1 @@ +/Applications/OrbStack.app/Contents/MacOS/../Resources/completions/fish/kubectl.fish \ No newline at end of file diff --git a/.config/fish/conf.d/aliases.fish b/.config/fish/conf.d/aliases.fish index 5aff957..d89b7fc 100644 --- a/.config/fish/conf.d/aliases.fish +++ b/.config/fish/conf.d/aliases.fish @@ -3,10 +3,13 @@ alias ld="ls -lisaGh" alias g="goto" alias vim="nvim" alias code="open -a 'Visual Studio Code'" +alias kubi="open -a 'Lens'" alias do-st="docker compose" alias do-re="docker compose down && docker compose up -d" alias qaserv="TERM=xterm-256color ssh root@195.201.17.47" +alias kc1="set -gx KUBECONFIG ~/.kube/config" +alias kc2="set -gx KUBECONFIG ~/.kube/work" alias ram="vm_stat" # DevOps Core Tools @@ -18,6 +21,18 @@ alias dcl="docker compose logs -f" alias dce="docker compose exec" alias dps="docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'" +# Kubernetes power aliases +alias k="kubectl" +alias kx="kubectx" # Context switching +alias kn="kubens" # Namespace switching +alias kgp="kubectl get pods -o wide" +alias kgs="kubectl get svc -o wide" +alias kgd="kubectl get deploy -o wide" +alias kl="kubectl logs -f" +alias ke="kubectl exec -it" +alias kdesc="kubectl describe" +alias kpf="kubectl port-forward" + # Testing alias pw="pnpm exec playwright" alias pwt="pnpm exec playwright test" diff --git a/.config/fish/conf.d/dev-helpers.fish b/.config/fish/conf.d/dev-helpers.fish index 8cd6e0d..7b6131a 100644 --- a/.config/fish/conf.d/dev-helpers.fish +++ b/.config/fish/conf.d/dev-helpers.fish @@ -13,6 +13,13 @@ function docker-cleanup docker volume prune -f end +# Kubernetes context info +function kinfo + echo "Context: "(kubectl config current-context) + echo "Namespace: "(kubectl config view --minify -o jsonpath='{..namespace}') + kubectl get nodes --no-headers | wc -l | xargs echo "Nodes:" +end + # Quick YAML validation function yaml-check python3 -c "import yaml; yaml.safe_load(open('$argv[1]'))" diff --git a/.config/fish/conf.d/kubernetes.fish b/.config/fish/conf.d/kubernetes.fish new file mode 100644 index 0000000..3148387 --- /dev/null +++ b/.config/fish/conf.d/kubernetes.fish @@ -0,0 +1,42 @@ +# Kubernetes setup +set -gx KUBECONFIG ~/.kube/config + +# Kubernetes aliases +alias k="kubectl" +alias kgp="kubectl get pods" +alias kgn="kubectl get nodes" +alias kgs="kubectl get services" +alias kgc="kubectl config get-contexts" +alias kuc="kubectl config use-context" +alias kns="kubectl config set-context --current --namespace" + +# Kubernetes context function +function update_kubernetes_context + if command -q kubectl + set -l kube_ctx (kubectl config current-context 2>/dev/null) + if test $status -eq 0 + set -l kube_ns (kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null) + set -gx STARSHIP_KUBERNETES_CONTEXT $kube_ctx + if test -n "$kube_ns" + set -gx STARSHIP_KUBERNETES_NAMESPACE $kube_ns + end + else + set -e STARSHIP_KUBERNETES_CONTEXT + set -e STARSHIP_KUBERNETES_NAMESPACE + end + end +end + +# Wrapper for kubectl +function kubectl + command kubectl $argv + set -l exit_code $status + + if test $exit_code -eq 0; and test "$argv[1]" = "config"; and contains "$argv[2]" "use-context" "set-context" + update_kubernetes_context + end + return $exit_code +end + +# Update context on startup +update_kubernetes_context diff --git a/.config/fish/conf.d/nvim.fish b/.config/fish/conf.d/nvim.fish index 098d402..57b689d 100644 --- a/.config/fish/conf.d/nvim.fish +++ b/.config/fish/conf.d/nvim.fish @@ -27,3 +27,8 @@ function vdocker echo "No Docker files found" end end + +# Edit kubernetes manifests +function vk8s + find . -name "*.yaml" -o -name "*.yml" | grep -E "(k8s|kubernetes|deploy)" | head -5 | xargs nvim +end diff --git a/.config/starship.toml b/.config/starship.toml index 6262699..12562bb 100644 --- a/.config/starship.toml +++ b/.config/starship.toml @@ -4,6 +4,7 @@ $time\ $directory\ $git_branch\ $git_status\ +$kubernetes\ $docker_context\ $python\ $golang\ @@ -50,6 +51,12 @@ staged = "+" renamed = "»" deleted = "✘" +[kubernetes] +format = '[$symbol$context( \($namespace\))]($style) ' +symbol = "☸ " +style = "bold cyan" +disabled = false + [docker_context] symbol = " " format = "[$symbol$context]($style) " diff --git a/README.md b/README.md index c4617ec..b6e115f 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,7 @@ Das Installationsskript kann optional verschiedene KI-Kommandozeilentools für S - **Mise Integration** - Modernes Tool- & Node-Version-Management - **FZF Integration** - Fuzzy finding everywhere - **Git Shortcuts** - Aliases für häufige Commands +- **Kubernetes** - kubectl completion - **Auto-completion** - Für Docker, Git, etc. ---