kubectl shell command prompt tool kube-shell

kubectl shell command prompt tool kube-shell

0. About kube-shell

Kube-shell is implemented based on python-prompt-toolkit to provide Kubectl ease of use and increase productivity.

kube-shell provides the following functions:

  • Automatically complete kubectl commands and parameter prompts
  • Color-coded display
  • History command autofill
  • Fuzzy query, automatically completed by the server
  • Context information and switching, F4 to switch clusters, F5 to switch Namespaces

1. Environmental preparation

1.1 python2.7.5 upgrade to 2.7.14

View Python version

[root@os161 /]# python -V
Python 2.7.5

download python2.7.14

[root@os161 /]# wget https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
--2018-01-19 17:06:49--  https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tgz
正在解析主机 www.python.org (www.python.org)... 151.101.228.223, 2a04:4e42:36::223
正在连接 www.python.org (www.python.org)|151.101.228.223|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:17176758 (16M) [application/octet-stream]
正在保存至: “Python-2.7.14.tgz”

 0% [ 

Unzip the Python package

tar -zxvf Python-2.7.13.tgz

Check & prepare build environment

yum install gcc* openssl openssl-devel ncurses-devel.x86_64  bzip2-devel sqlite-devel python-devel zlib

Install

cd Python-2.7.14
./configure --prefix=/usr/local
make && make altinstall 

Backup legacy, yum and other components depend on 2.7.5 to work

mv /usr/bin/python /usr/bin/python2.7.5
ln -s /usr/local/bin/python2.7 /usr/bin/python 

verify

[root@os163 Python-2.7.14]# python -V
Python 2.7.14
[root@os163 Python-2.7.14]# python2.7.5 -V
Python 2.7.5

Fix yum and other components python

[root@localhost bin]# vim /usr/bin/yum
首行的#!/usr/bin/python 改为 #!/usr/bin/python2.7.5

[root@localhost bin]# vim /usr/libexec/urlgrabber-ext-down
首行的#!/usr/bin/python 改为 #!/usr/bin/python2.7.5

1.2 Pip installation

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
ln -s /usr/local/bin/pip2.7 /usr/bin/pip   

Do not try to install pip in the following way, it will not work!

sudo yum -y install epel-release 
sudo yum -y install python-pip

2. kube-shell installation

pip install kube-shell

3. Verification and use

[root@os163 Python-2.7.14]# kube-shell
kube-shell> kubectl get clusterrole -n kube-system
               kubectl  kubectl controls the Kubernetes cluster manager  






 [F4] Cluster: kubernetes [F5] Namespace: default User: kubernetes-admin [F9] In-line help: ON [F10] Exit   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324481831&siteId=291194637