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

Terminal welcome on first invocation #357

Closed mattbryce93 closed 1 year ago

mattbryce93 commented 2 years ago

On a new terminal, whenever I invoke kubectx I get the standard built in Ubuntu terminal welcome. Afterwards kubectx works as expected. I'm wondering if anyone else has seen this happen to them? This is on WSL2 Ubuntu 22.04

➜  ~ kubectx
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.10.16.3-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri  1 Jul 14:48:51 NZST 2022

  System load:  0.26025390625      Processes:             42
  Usage of /:   1.9% of 250.98GB   Users logged in:       1
  Memory usage: 9%                 IPv4 address for eth0: 172.28.11.20
  Swap usage:   0%

 * Super-optimized for small spaces - read how we shrank the memory
   footprint of MicroK8s to make it the smallest full K8s around.

   https://ubuntu.com/blog/microk8s-memory-optimisation

0 updates can be applied immediately.

Last login: Fri Jul  1 14:23:41 NZST 2022 on pts/11
ahmetb commented 2 years ago

Where did you install it from? Can you vi the executable and see if it is some sort of wrapper script?

I also don't understand why there are microk8s references in the shell startup (MotD?).

mattbryce93 commented 2 years ago

I'll save you reading the entire file but it matches master currently:

➜  ~ curl https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx | md5sum
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6108  100  6108    0     0  16716      0 --:--:-- --:--:-- --:--:-- 16734
d679716885e8592585af4fcf9d106ec7  -
➜  ~ cat $(which kubectx) | md5sum
d679716885e8592585af4fcf9d106ec7  -

Sorry for the late reply, was away from my PC for the last month

mattbryce93 commented 2 years ago

This was the installation script I used to set up my environment (started scripting it due to issues like this forcing me to recreate the wsl instance:

#!/bin/zsh

script_name=$0
script_full_path=$(dirname "$0")

rm -r /home/$USER/.kube

mkdir /home/$USER/.kube

echo "RUNNING: 'cp $script_full_path/files/kube-config /home/$USER/.kube'"
cp $script_full_path/files/kube-config /home/$USER/.kube/config

# Download the latest version of Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
# Make the binary executable
chmod +x ./minikube
# Move the binary to your executable path
sudo mv ./minikube /usr/local/bin/
# Install the conntrack package
sudo apt install -y conntrack

# Install the needed packages
sudo apt install -yqq daemonize dbus-user-session fontconfig

sudo cp $script_full_path/files/enter-systemd-namespace /usr/sbin/enter-systemd-namespace
sudo cp $script_full_path/files/start-systemd-namespace /usr/sbin/start-systemd-namespace
sudo chmod +x /usr/sbin/enter-systemd-namespace

# sudo sed -i 2a"# Start or enter a PID namespace in WSL2\nsource /usr/sbin/start-systemd-namespace\n" /etc/bash.bashrc

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

curl --output helm-linux-amd64.tar.gz https://get.helm.sh/helm-v3.4.2-linux-amd64.tar.gz
tar -zxvf helm-linux-amd64.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
rm helm-linux-amd64.tar.gz
rm -rf linux-amd64

sudo git clone https://github.com/ahmetb/kubectx /usr/local/kubectx
sudo ln -s /usr/local/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /usr/local/kubectx/kubens /usr/local/bin/kubens

mkdir -p ~/.oh-my-zsh/completions
chmod -R 755 ~/.oh-my-zsh/completions
ln -s /usr/local/kubectx/completion/_kubectx.zsh ~/.oh-my-zsh/completions/_kubectx.zsh
ln -s /usr/local/kubectx/completion/_kubens.zsh ~/.oh-my-zsh/completions/_kubens.zsh
ahmetb commented 1 year ago

Sorry I'm not able to repro this on WSL with Ubuntu as described (fetch the script via curl, chmod+x, add it to PATH and run it).