gpt4 book ai didi

deployment - Kubectl create 用于持久存储出错

转载 作者:行者123 更新时间:2023-12-02 11:50:32 25 4
gpt4 key购买 nike

我正在尝试为 couch DB 部署持久存储,但由于错误而失败

kubectl create -f couch_persistant_deploy.yaml

error: error validating "couch_persistant_deploy.yaml": error validating data: couldn't find type: v1.Deployment; if you choose to ignore these errors, turn validation off with --validate=false



创建volume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: task-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/sda1/data/test

声明卷.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: task-pv-claim
labels:
app: couchdb
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

部署 VM.yaml
apiVersion: extensions/v1beta1
#apiVersion: v1
kind: Deployment
#kind: ReplicationController
metadata:
name: couchdb
spec:
replicas: 1
template:
metadata:
labels:
app: couchdb
spec:
containers:
- name: couchdb
image: "couchdb"
imagePullPolicy: Always
env:
- name: COUCHDB_USER
value: admin
- name: COUCHDB_PASSWORD
value: password
ports:
- name: couchdb
containerPort: 5984
- name: epmd
containerPort: 4369
containerPort: 9100
volumeMounts:
- mountPath: "/opt/couchdb/data"
name: task-pv-storage
imagePullSecrets:
- name: registrypullsecret2
#volumes:
#- name: database-storage
# emptyDir: {}
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim

任何线索都非常感谢。

最佳答案

你的错误信息应该是这样的:

error: error validating "couch_persistant_deploy.yaml": error validating data: ValidationError(Deployment.spec.template.spec.volumes[0]): unknown field "claimName" in io.k8s.api.core.v1.Volume; if you choose to ignore these errors, turn validation off with --validate=false



看,错误信息是具体的: unknown field "claimName" in io.k8s.api.core.v1.Volume
您需要将 claimName 放在 persistentVolumeClaim 下。
  volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim # fix is here

但你做到了
  volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: task-pv-claim # invalid

这使您的部署对象无效

关于deployment - Kubectl create 用于持久存储出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48544969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com