一、准备python3的安装包
安装Python3.8.6版本
1、安装部署包,解压
tar -zxvf Python-3.8.6.tgz
2、准备编译环境
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
3、编译安装
# 进入解压目录
cd Python-3.8.6
./configure --prefix=/root/training/Python-3.8.6
make
make install
4、创建软连接
ln -s /root/training/Python-3.8.6/bin/python3.8 /usr/local/bin/python3
ln -s /root/training/Python-3.8.6/bin/pip3 /usr/local/bin/pip3
# 查看是否创建成功
ls -l /usr/local/bin
5、配置环境变量
#配置python
vim /etc/profile
# 加配置
export PYTHON_HOME=/root/training/Python-3.8.6
export PATH=$PYTHON_HOME/bin:$PATH
6、查看配置
python3 --version
二、容器开启debug
1、首先要把pod.yaml改成debug模式
#在镜像下方
command:
- /usr/sbin/init
securityContext:
privileged: true
#进入k8s容器中下载openssh-server并设置密码
kubectl exec $(kubectl get pod |grep xxx | awk '{print $1}') -- bash -c "yum install -y openssh-server && echo Port=30010 >>/etc/ssh/sshd_config && systemctl start sshd && echo 123qweASD|passwd root --stdin"
2、创建service开启nodeport的形式访问
容器端口为上方的30010对应,然后就可以使用vscode进行ssh连接30010端口