k8s 版本升级 1.25.0 -> 1.25.1

该文章详细描述了如何将Kubernetes集群从1.25.0版本升级到1.25.1版本,包括升级kubeadm、kubectl、kubelet,以及对master和node节点的逐个处理,如设置不可调度、重启服务和恢复调度等操作。

k8s 版本升级 1.25.0 -> 1.25.1

升级之前 K8s VERSION 1.25.0, 目标 v1.25.0-0 -> v1.25.1-0:

# 升级之前 v1.25.0 :
[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.0   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.0   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.0   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.0   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21

# 升级之后 v1.25.1 :
[root@k8s-master-1 ~]# kubectl get node -o wide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION           CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   39d   v1.25.1   192.168.3.101   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-1     Ready    <none>          39d   v1.25.1   192.168.3.104   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-2     Ready    <none>          39d   v1.25.1   192.168.3.105   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21
k8s-node-3     Ready    <none>          39d   v1.25.1   192.168.3.106   <none>        CentOS Linux 7 (Core)   3.10.0-1160.el7.x86_64   docker://20.10.21


升级管理节点(master) 9步 :

1 查找最新版本号:
yum list --showduplicates kubeadm

2 升级kubeadm:
yum install -y kubeadm-1.25.1-0

3 驱逐Node上的pod,并设置为不可调度(有啥提示参数要加的都加上):
kubectl drain k8s-master-1 --ignore-daemonsets

4 检查集群是否可以升级,并获取可以升级的版本(直接升级1.25的最新版本 可以忽略版本号,如果是升级到次新版本 主要要加上版本号):
 kubeadm upgrade plan 1.25.1-0

5 根据提示进行下一步操作:
kubeadm upgrade apply v1.25.1 --etcd-upgrade=false    #--etcd-upgrade=false 默认为true即升级Etcd,用此参数不升级Etcd.

6 升级kubectl 和 kubelet:
yum install kubectl-1.25.1 kubelet-1.25.1 -y

7 重启kubelet:
systemctl daemon-reload
systemctl restart kubelet

8 取消不可调度,重新上线:
kubectl uncordon k8s-master-1

9 查看升级后的master版本: 
kubectl get node -o wide

升级工作节点(node)

1 升级kubeadm:
yum  install -y kubeadm-1.25.1

2 驱逐Node节点上的pod,且不可调度(master 端操作):
kubectl drain k8s-node-3 --ignore-daemonsets

3 升级kubelet 配置:
kubeadm upgrade node

4 升级kubectl 和 kubelet:
yum install kubectl-1.25.1 kubelet-1.25.1 -y

5 重启kubelet:
systemctl daemon-reload
systemctl restart kubelet

6 取消不可调度,重新上线(master 端操作):
kubectl uncordon k8s-node-3

7 查看升级后的Node节点版本(master 端操作): 
kubectl get node -o wide

至此 Master + Node 升级完成


                       **** 以下为详细过程 ****

升级主节点(k8s-master-1):

1 查找最新版本号:

yum list --showduplicates kubeadm

在这里插入图片描述
2 升级kubeadm

yum install -y kubeadm-1.25.1.0

在这里插入图片描述
3 驱逐Node上的pod,并设置为不可调度(有啥提示参数要加的都加上):

kubectl drain k8s-master-1 --ignore-daemonsets

在这里插入图片描述

4 检查集群是否可以升级,并获取可以升级的版本 (直接升1.25的最新版,可忽略版本号,如果是升级到次新版本要加上版本号):

 kubeadm upgrade plan 1.25.1

在这里插入图片描述

5 根据提示进行下一步操作:

kubeadm upgrade apply v1.25.1

6 升级kubectl 和 kubelet:

yum install kubectl-1.25.1 kubelet-1.25.1 -y

在这里插入图片描述

7 重启kubelet:

systemctl daemon-reload
systemctl restart kubelet

8 取消不可调度,重新上线:

kubectl uncordon k8s-master-1

在这里插入图片描述


Node 节点升级

1 升级kubeadm:

yum  install -y kubeadm-1.25.1

在这里插入图片描述
2 驱逐Node节点上的pod,且不可调度(master 端操作):

kubectl drain k8s-node-3 --ignore-daemonsets

在这里插入图片描述
3 升级kubelet:

kubeadm upgrade node

在这里插入图片描述

4 升级kubectl 和 kubelet:

yum install kubectl-1.25.1 kubelet-1.25.1 -y

在这里插入图片描述

5 重启kubelet:

systemctl daemon-reload
systemctl restart kubelet

6 取消不可调度,重新上线(master 端操作):

kubectl uncordon k8s-node-3

[root@k8s-master-1 ~]# kubectl uncordon k8s-node-3
node/k8s-node-3 uncordoned

7 master上查看结果:

kubectl get node -o wide

在这里插入图片描述

ERROR: Ignored the following versions that require a different python version: 1.11.0 Requires-Python <3.13,>=3.9; 1.11.0rc1 Requires-Python <3.13,>=3.9; 1.11.0rc2 Requires-Python <3.13,>=3.9; 1.11.1 Requires-Python <3.13,>=3.9; 1.11.2 Requires-Python <3.13,>=3.9; 1.11.3 Requires-Python <3.13,>=3.9; 1.11.4 Requires-Python >=3.9; 1.12.0 Requires-Python >=3.9; 1.12.0rc1 Requires-Python >=3.9; 1.12.0rc2 Requires-Python >=3.9; 1.13.0 Requires-Python >=3.9; 1.13.0rc1 Requires-Python >=3.9; 1.13.1 Requires-Python >=3.9; 1.14.0 Requires-Python >=3.10; 1.14.0rc1 Requires-Python >=3.10; 1.14.0rc2 Requires-Python >=3.10; 1.14.1 Requires-Python >=3.10; 1.15.0 Requires-Python >=3.10; 1.15.0rc1 Requires-Python >=3.10; 1.15.0rc2 Requires-Python >=3.10; 1.15.1 Requires-Python >=3.10; 1.15.2 Requires-Python >=3.10; 1.15.3 Requires-Python >=3.10; 1.16.0 Requires-Python >=3.11; 1.16.0rc1 Requires-Python >=3.11; 1.16.0rc2 Requires-Python >=3.11; 1.16.1 Requires-Python >=3.11; 1.16.2 Requires-Python >=3.11; 1.2.0 Requires-Python >=3.9; 1.2.1 Requires-Python >=3.9; 1.2.1rc1 Requires-Python >=3.9; 1.25.0 Requires-Python >=3.9; 1.25.1 Requires-Python >=3.9; 1.25.2 Requires-Python >=3.9; 1.26.0 Requires-Python <3.13,>=3.9; 1.26.1 Requires-Python <3.13,>=3.9; 1.26.2 Requires-Python >=3.9; 1.26.3 Requires-Python >=3.9; 1.26.4 Requires-Python >=3.9; 1.3.0 Requires-Python >=3.9; 1.3.1 Requires-Python >=3.10; 1.3.2 Requires-Python >=3.10; 1.3.3 Requires-Python >=3.11; 11.0.0 Requires-Python >=3.9; 11.1.0 Requires-Python >=3.9; 11.2.1 Requires-Python >=3.9; 11.3.0 Requires-Python >=3.9; 2.0.0 Requires-Python >=3.9; 2.0.1 Requires-Python >=3.9; 2.0.2 Requires-Python >=3.9; 2.1.0 Requires-Python >=3.10; 2.1.0 Requires-Python >=3.9; 2.1.0rc0 Requires-Python >=3.9; 2.1.1 Requires-Python >=3.10; 2.1.1 Requires-Python >=3.9; 2.1.2 Requires-Python >=3.10; 2.1.2 Requires-Python >=3.9; 2.1.3 Requires-Python >=3.10; 2.1.3 Requires-Python >=3.9; 2.1.4 Requires-Python >=3.9; 2.14.1 Requires-Python >=3.9; 2.15.0 Requires-Python >=3.9; 2.15.1 Requires-Python >=3.9; 2.15.2 Requires-Python >=3.9; 2.16.0 Requires-Python >=3.9; 2.16.1 Requires-Python >=3.9; 2.16.2 Requires-Python >=3.9; 2.17.0 Requires-Python >=3.9; 2.17.1 Requires-Python >=3.9; 2.18.0 Requires-Python >=3.9; 2.19.0 Requires-Python >=3.9; 2.2.0 Requires-Python >=3.10; 2.2.0 Requires-Python >=3.9; 2.2.0rc0 Requires-Python >=3.9; 2.2.1 Requires-Python >=3.10; 2.2.1 Requires-Python >=3.9; 2.2.2 Requires-Python >=3.10; 2.2.2 Requires-Python >=3.9; 2.2.3 Requires-Python >=3.10; 2.2.3 Requires-Python >=3.9; 2.2.4 Requires-Python >=3.10; 2.2.5 Requires-Python >=3.10; 2.2.6 Requires-Python >=3.10; 2.20.0 Requires-Python >=3.9; 2.3.0 Requires-Python >=3.11; 2.3.0 Requires-Python >=3.9; 2.3.1 Requires-Python >=3.11; 2.3.1 Requires-Python >=3.9; 2.3.2 Requires-Python >=3.11; 2.3.2 Requires-Python >=3.9; 2.3.3 Requires-Python >=3.11; 2.3.3 Requires-Python >=3.9; 2.32.5 Requires-Python >=3.9; 3.10.0 Requires-Python >=3.10; 3.10.0rc1 Requires-Python >=3.10; 3.10.1 Requires-Python >=3.10; 3.10.3 Requires-Python >=3.10; 3.10.5 Requires-Python >=3.10; 3.10.6 Requires-Python >=3.10; 3.10.7 Requires-Python >=3.10; 3.8.0 Requires-Python >=3.9; 3.8.0rc1 Requires-Python >=3.9; 3.8.1 Requires-Python >=3.9; 3.8.2 Requires-Python >=3.9; 3.8.3 Requires-Python >=3.9; 3.8.4 Requires-Python >=3.9; 3.9.0 Requires-Python >=3.9; 3.9.0rc2 Requires-Python >=3.9; 3.9.1 Requires-Python >=3.9; 3.9.1.post1 Requires-Python >=3.9; 3.9.2 Requires-Python >=3.9; 3.9.3 Requires-Python >=3.9; 3.9.4 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement fonttools>=4.22.0 (from matplotlib) (from versions: none) ERROR: No matching distribution found for fonttools>=4.22.0
10-13
<think>我们面临的问题是:在安装依赖时,由于Python版本不匹配导致找不到满足fonttools>=4.22.0的版本。 可能的原因及解决方案: 1. **Python版本过低**:fonttools 4.22.0可能要求较高的Python版本。我们需要检查fonttools 4.22.0所需的Python版本,并确认当前环境是否满足。 2. **当前环境中可用的fonttools版本过低**:可能是由于索引源中没有适用于当前Python版本的fonttools 4.22.0或更高版本。 步骤: **步骤1:检查当前Python版本** 在终端运行: ```bash python --version # 或 python3 --version ``` **步骤2:查看fonttools 4.22.0所需的Python版本** 我们可以访问PyPI页面:https://pypi.org/project/fonttools/4.22.0/,查看该版本所需的Python版本要求。 或者使用pip命令尝试安装并观察错误信息(但不要实际安装,因为我们可能无法安装): ```bash pip install fonttools==4.22.0 ``` 如果当前Python版本低于fonttools 4.22.0所要求的版本,则会收到类似错误。 根据经验,fonttools 4.22.0要求Python版本至少为3.7(具体以实际为准,但一般新版本会要求较高Python版本)。 **步骤3:解决方案** 根据情况选择以下方案: **方案A:升级Python版本(推荐)** 如果当前Python版本过低,建议升级到更高版本(如3.7及以上)。 升级方法: - 访问Python官网下载最新版本:https://www.python.org/downloads/ - 使用版本管理工具(如pyenv)安装多版本并切换。 **方案B:降低fonttools版本要求** 如果无法升级Python,尝试安装一个与当前Python版本兼容的fonttools版本。 查看可用的fonttools版本及其兼容性: - 访问:https://pypi.org/project/fonttools/#history - 或者使用命令: ```bash pip install fonttools== ``` 这将列出所有可用版本。然后选择一个低于4.22.0但满足项目最低要求的版本(需要知道项目要求的最低fonttools版本是多少?)。 但注意:降低版本可能导致依赖它的其他库不兼容。 **方案C:检查pip的索引源是否完整** 有时镜像源可能没有及时同步完整版本。可以尝试切换至官方源: ```bash pip install -i https://pypi.org/simple fonttools==4.22.0 ``` **方案D:使用虚拟环境隔离** 如果系统中存在多个Python版本,确保在正确的Python版本环境中安装。 例如,使用venv创建虚拟环境(假设已经安装了所需版本的Python): ```bash # 创建虚拟环境 python3.8 -m venv myenv # 激活 source myenv/bin/activate # Linux/Mac myenv\Scripts\activate.bat # Windows # 然后在虚拟环境中安装 pip install fonttools==4.22.0 ``` 结合用户之前遇到的索引源问题,我们还可以考虑设置国内镜像源加速下载(但镜像源同步可能有延迟,所以如果镜像源没有对应版本的包,可以尝试官方源)。 具体到用户的问题,如果用户因为Python版本过低无法安装,那么升级Python是最彻底的解决方案。 如果用户确实无法升级Python,那么我们需要寻找一个支持当前Python版本的fonttools版本。例如,假设用户当前环境是Python3.6,那么我们可以尝试安装fonttools 4.21.2(如果这个版本支持Python3.6且满足项目要求)。 如何确定一个较旧的fonttools版本是否支持当前Python? - 在PyPI上查看该版本的发布信息,通常有“Requires: Python >=...”的说明。 - 或者使用pip尝试安装指定版本,如果不支持则会报错。 示例命令: ```bash # 尝试安装一个旧版本 pip install fonttools==4.21.2 ``` 如果成功安装,则说明该版本可用。 注意:如果项目要求必须>=4.22.0,那么降低版本可能不可行,只能升级Python。 总结步骤: 1. 确定当前Python版本。 2. 查询fonttools 4.22.0所需的Python版本(假设为3.7+)。 3. 如果当前版本>=3.7,则可能是镜像源问题,切换索引源重试。 4. 如果当前版本<3.7,则考虑升级Python或降低fonttools版本(如果项目允许)。 最后,如果用户的项目要求必须使用fonttools>=4.22.0且当前Python版本过低,那么升级Python是唯一选择。 生成的相关问题: 1. 如何查看当前Python版本? 2. 如何在Windows/Mac/Linux上升级Python? 3. 如何创建和使用Python虚拟环境? 4. 如何切换pip的索引源? 5. 如何安装特定版本的Python包? </think>### 解决 Python 版本不兼容导致无法安装 fonttools≥4.22.0 的问题 #### 1. **确认版本兼容性** fonttools 4.22.0 对 Python 版本有严格要求: ```bash # 查看当前Python版本 python --version # 检查fonttools版本兼容矩阵: pip install fonttools==4.22.0 --dry-run ``` - **兼容范围**: fonttools≥4.22.0 需要 Python≥3.8(详见[官方文档](https://pypi.org/project/fonttools/)) #### 2. **升级 Python 环境(推荐方案)** 若当前 Python<3.8: ```mermaid graph LR A[Python 3.7↓] --> B{升级方案} B --> C[直接安装新版] B --> D[虚拟环境隔离] C --> E[下载安装包<br>https://www.python.org/downloads/] D --> F[conda create -n py38 python=3.8] ``` **操作步骤**: 1. 下载 Python 3.8+ 安装包: ```bash # Windows https://www.python.org/ftp/python/3.12.0/python-3.12.0-amd64.exe # Linux/macOS wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tar.xz ``` 2. 安装时勾选 `Add to PATH`(Windows)或配置环境变量 3. 验证安装: ```bash python3.12 --version # 应输出 Python 3.12.x ``` #### 3. **使用兼容版本降级方案** 若无法升级 Python: ```bash # 查找支持当前Python的最高fonttools版本 pip install fonttools== # 查看所有版本 # 安装兼容版本(例如Python3.7可装4.21.2) pip install "fonttools>=4.0, <=4.21.2" ``` **版本兼容参考**: | Python 版本 | 最高兼容 fonttools | |------------|-------------------| | 3.6 | ≤4.19.2 | | 3.7 | ≤4.21.2 | | ≥3.8 | ≥4.22.0 | #### 4. **虚拟环境解决方案** 使用虚拟环境隔离高版本 Python: ```bash # 创建并激活虚拟环境 python -m venv fonttools_env source fonttools_env/bin/activate # Linux/macOS fonttools_env\Scripts\activate.bat # Windows # 安装高版本Python(若系统级版本低) conda install python=3.10 -y # 通过conda # 安装目标库 pip install fonttools>=4.22.0 ``` #### 5. **编译安装扩展支持** 若遇 SSL/TLS 问题(常见于旧系统): ```bash # 安装编译依赖(Linux示例) sudo apt-get install libssl-dev zlib1g-dev # 重新编译Python启用SSL cd Python-3.12.0 ./configure --with-openssl=/usr/local/openssl # 指定OpenSSL路径[^2] make && make install ``` > **关键提示**:安装后验证 OpenSSL 支持: > ```python > import ssl > print(ssl.OPENSSL_VERSION) # 应输出 OpenSSL 1.1.1+ > ``` #### 验证解决方案 ```bash # 最终安装验证 python -c "import fonttools; print(fonttools.__version__)" # 成功时应输出 ≥4.22.0 ``` ### 常见问题排查 1. **仍提示版本不兼容**: - 清除 pip 缓存:`pip cache purge` - 强制重装:`pip install --no-cache-dir --force-reinstall fonttools` 2. **多版本冲突**: ```bash # 查看已安装包 pip list | grep fonttools # 卸载冲突版本 pip uninstall fonttools ``` 3. **依赖链问题**: 若其他库依赖特定 fonttools 版本,尝试同步升级: ```bash pip install --upgrade package-that-requires-fonttools ``` 通过以上方案,可解决 99% 的 Python 版本与 fonttools 兼容性问题[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值