ahmetb / kubectx

Faster way to switch between clusters and namespaces in kubectl
https://kubectx.dev
Apache License 2.0
17.66k stars 1.26k forks source link

kubens and kubectx not interactive #355

Closed RafaelMoreira1180778 closed 2 years ago

RafaelMoreira1180778 commented 2 years ago

I installed kubens and kubectx manually since on Pop!OS 22.04 I cannot use the apt method for installation.

I followed the steps for the manual installation and then executed this command: # chmod +x /opt/kubectx/kubectx /opt/kubectx/kubens /usr/local/bin/kubectx /usr/local/bin/kubens.

The problem is that when I execute kubens or kubectx the prompt is not interactive, it only lists the contexts of the namespaces and does not prompt me to select one:

$ /usr/local/bin/kubens
default
fluent-bit
gitlab-kubernetes-agent
kube-node-lease
kube-public
kube-system
pwa
$ /usr/local/bin/kubectx
arn:aws:eks:eu-west-1:...:cluster/my-cluster

I do not know why this is not prompting the interactive mode, but here is my ~/.zshrc configuration file:

if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(
  git
  sudo
  docker
  docker-compose
)

source $ZSH/oh-my-zsh.sh

# P10K
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

# ZSH AutoComplete
source ~/.zsh-plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh

# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

# AWS
export PATH=/usr/local/bin/aws_completer:$PATH
complete -C '/usr/local/bin/aws_completer' aws

# SSH autocompletion
h=()
if [[ -r ~/.ssh/config ]]; then
  h=($h ${${${(@M)${(f)"$(cat ~/.ssh/config)"}:#Host *}#Host }:#*[*?]*})
fi
if [[ -r ~/.ssh/known_hosts ]]; then
  h=($h ${${${(f)"$(cat ~/.ssh/known_hosts{,2} || true)"}%%\ *}%%,*}) 2>/dev/null
fi
if [[ $#h -gt 0 ]]; then
  zstyle ':completion:*:ssh:*' hosts $h
  zstyle ':completion:*:slogin:*' hosts $h
fi

autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit

# ALIASES

# K8S
alias k="/usr/local/bin/kubectl"
alias kc="/usr/local/bin/kubectx"
alias kn="/usr/local/bin/kubens"

# DOCKER
alias d="/usr/bin/docker"
alias dc="/home/rafael/.docker/cli-plugins/docker-compose"

This configuration is pretty basic and should not interfere. I am running the latest oh-my-zsh and zsh versions, as well as the latest powerlevel10k version.

RafaelMoreira1180778 commented 2 years ago

So this was my bad, the documentation tells you that you need the fzf package.

I installed and it's OK.