升級集群時,系統會自動校驗ECI Platform Version和Kubernetes的兼容情況,對于ECI Platform Version和目標Kubernetes版本不兼容的ECI Pod,需要手動刪除重建ECI Pod后,才能升級集群的Kubernetes版本。升級集群前,請確保ECI Platform Version與Kubernetes版本兼容。本文介紹ECI Platform Version的兼容矩陣以及如何升級ECI Platform Version。
ECI Platform Version介紹
ECI Platform Version表示ECI(Elastic Container Instance)基礎設施的特定運行時環境的版本號,可以區分不同的ECI運行時環境。隨著ECI運行時環境的迭代,例如添加新功能、修復Bug或更新補丁,將會發布新的ECI Platform Version修訂版。
您在ACK集群創建的ECI Pod默認會帶有一個Key為k8s.aliyun.com/eci-platform-version
的Annotation,Value即為ECI Platform Version的版本號。Annotation示例如下:
---
apiVersion: v1
kind: Pod
metadata:
annotations:
k8s.aliyun.com/eci-platform-version: 1.0.0
name: demo-76d8d9f9d8-l7pwm
namespace: default
...
ECI Platform Version兼容的Kubernetes版本
如下所示,不同版本的ECI Platform Version兼容的Kubernetes版本有所不同。
新創建ECI Pod的ECI Platform Version版本為1.1.0,存量ECI Pod的ECI Platform Version版本為1.0.0或者為空。
ECI Platform Version版本 | 兼容的Kubernetes版本 |
1.1.0 | 1.12、1.14、1.16、1.18、1.20、1.22、1.24、1.26 、1.28、1.30、1.31(灰度中) |
1.0.0 | 1.12、1.14、1.16、1.18、1.20、1.22、1.24 |
空 ( | 1.12、1.14、1.16、1.18、1.20、1.22、1.24 |
升級ECI Platform Version
連接集群。具體操作,請參見已獲取集群KubeConfig并通過kubectl工具連接集群。
獲取版本號為空或為1.0.0的ECI Pod的信息。
獲取的信息包括ECI Pod的命名空間、名稱、ECI Platform Version和ECI實例ID,并將這些信息以英文半角逗號(,)分隔的格式展示。
kubectl get pods -A -o json | jq -r '.items[] | select(.metadata.annotations["k8s.aliyun.com/eci-platform-version"] == "1.0.0" or .metadata.annotations["k8s.aliyun.com/eci-platform-version"] == null or .metadata.annotations["k8s.aliyun.com/eci-platform-version"] == "") | select(.spec.nodeName | startswith("virtual-kubelet")) | "\(.metadata.namespace),\(.metadata.name),\(.metadata.annotations["k8s.aliyun.com/eci-platform-version"] // ""),\(.metadata.annotations["k8s.aliyun.com/eci-instance-id"])"'
返回示例如下:
default,portal-server-57dfc4fdc8-2gl64,,eci-2zecdr8z5jy******
刪除重建目標ECI Pod。
命令示例如下:
kubectl delete pod portal-server-57dfc4fdc8-2gl64 -n default
返回示例如下:
pod "portal-server-57dfc4fdc8-2gl64" deleted
ECI Pod刪除重建后,新建的ECI Pod的ECI Platform Version版本會自動升級為更新后的版本。您可以執行以下命令,查看ECI Platform Version版本。
kubectl get pods -A -o json | jq -r '.items[] | select(.spec.nodeName | startswith("virtual-kubelet")) | "\(.metadata.namespace),\(.metadata.name),\(.metadata.annotations["k8s.aliyun.com/eci-platform-version"] // ""),\(.metadata.annotations["k8s.aliyun.com/eci-instance-id"] // "")"'