我目前有一个 GKE Kubernetes 1.15 集群,我计划升级到 1.16。由于 1.16 不支持某些 API,我必须将我的部署从 extensions/v1beta1 更改为 apps/v1。
使用这个简单的 deployment.yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
当我将它应用到我的 1.15 cluster:kubectl -n mynamespace deployment.yml
时,实际看到的是以下(kubectl -n mynamespace get deployments nginx-deployment
):
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kubectl.kubernetes.io/last-applied-configuration: |
...
如您所见,实际的 apiVersion 是 extensions/v1beta1 而不是 apps/v1。为什么不应用我指定的版本?
更新:
这是我的 kubectl 版本:
Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.4", GitCommit:"8d8aa39598534325ad77120c120a22b3a990b5ea", GitTreeState:"clean", BuildDate:"2020-03-12T23:41:24Z", GoVersion:"go1.14", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.9-gke.24", GitCommit:"39e41a8d6b7221b901a95d3af358dea6994b4a40", GitTreeState:"clean", BuildDate:"2020-02-29T01:24:35Z", GoVersion:"go1.12.12b4", Compiler:"gc", Platform:"linux/amd64"}