如何在Kubernetes中使用apply而不是create进行部署?

问题描述 投票:0回答:1

我正在尝试使用kubectl apply以声明方式创建部署。我做的时候就可以正常创建以下配置了

kubectl create -f postgres-deployment.yaml

但是,如果我去

kubectl apply -f postgres-deployment.yaml

我收到了可爱的错误消息:

错误:无法解码“postgres-deployment.yaml”:没有注册版本“apps / v1beta1”的“部署”

我试图寻找解释这意味着什么,但我无法弄清楚。

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: postgres-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:10.1
        ports:
        - containerPort: 5432
kubernetes
1个回答
1
投票

旧Kubernetes版本支持extensions/v1beta1 API组上的Deployment对象。 That is no longer the case

对于1.9.0之前的Kubernetes版本,您应该使用API​​组apps/v1beta2

In Kubernetes 1.9及以上你应该使用API​​组apps/v1

© www.soinside.com 2019 - 2024. All rights reserved.