gpt4 book ai didi

kubernetes - 来自服务器的错误 (BadRequest) : error when creating "pod.yaml":

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

运行时出现如下错误

kubectl create -f pod.yaml

错误

Error from server (BadRequest): error when creating "pod.yaml": Pod in 
version "applicant:v1" cannot be handled as a Pod: no kind "Pod" is
registered for version "applicant:v1"

minikube 已启动并运行,我什至尝试将其更改为 kind: Deployment 但我收到另一个错误消息:

error: unable to recognize "pod.yaml": no matches for /, Kind=Deployment

亚姆:

apiVersion: apps/v1
kind: Deployment
metadata:
name: customer-applicant
labels:
app: applicant-vue
spec:
replicas: 1
selector:
matchLabels:
app: applicant-vue
template:
metadata:
labels:
app: applicant-vue
spec:
containers:
- name: api-applicant
image: api-applicant
ports:
- containerPort: 8080
- containerPort: 8000
resources: {}
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: api-applicant-claim

# ekomi-import
- name: applicant-import
image: applicant-import
resources: {}

# cache
- name: cache
image: cache
resources:
limits:
memory: "536870912"

# storage
- name: storage
image: storage
ports:
- containerPort: 7000
- containerPort: 7001
- containerPort: 7199
- containerPort: 9042
- containerPort: 9160
resources: {}
# view
- name: view
image: view
ports:
- containerPort: 3000
resources: {}

volumes:
- name: applicant-claim
persistentVolumeClaim:
claimName: applicant-claim
# tomcat
- name: tomcat
image: tomcat
# node
- name: node
image: node
resources: {}
# openJdk
- name: node
- image: node
resources: {}

最佳答案

你这里有很多问题。我已经描述了其中的一些:

1.pod.yaml 文件的结构是一个 Deployment 对象的结构。

2.部署apiVersion取决于kubernetes版本:

  • apps/v1beta1 1.8.0 之前的版本
  • apps/v1beta2 从 1.8.0 开始到 1.9.0 之前的版本
  • apps/v1 适用于从 1.9.0 开始的版本

因此,如果您将 pod.yaml 部署在最新的 kubernetes 集群上,它应该从:

apiVersion: apps/v1
kind: Deployment

3.部分:

spec:
replicas: 1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
template:
metadata:
labels:
app: product-ratings-vue

应该改为:

spec:
replicas: 1
template:
metadata:
labels:
app: product-ratings-vue

4.第二个 spec block 应该移动到与 spec.template.metadata 相同的级别:

    spec:
replicas: 1
template:
metadata:
labels:
app: product-ratings-vue
spec:
containers:

最终的deployment.yaml是:

apiVersion: apps/v1
kind: Deployment
metadata:
name: customer-ratings
labels:
app: product-ratings-vue
spec:
replicas: 1
selector:
matchLabels:
app: product-ratings-vue
template:
metadata:
labels:
app: product-ratings-vue
spec:
containers:
- name: api-service
image: api-service
ports:
- containerPort: 8080
- containerPort: 8000
resources: {}
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: api-service-claim

# ekomi-import
- name: ekomi-import
image: ekomi-import
resources: {}

# cache
- name: cache
image: cache
resources:
limits:
memory: "536870912"

# storage
- name: storage
image: storage
ports:
- containerPort: 7000
- containerPort: 7001
- containerPort: 7199
- containerPort: 9042
- containerPort: 9160
resources: {}
# view
- name: view
image: view
ports:
- containerPort: 3000
resources: {}

# tomcat
- name: tomcat
image: tomcat
# node
- name: node
image: node
resources: {}
# openJdk
- name: node
image: node
resources: {}

volumes:
- name: api-service-claim
persistentVolumeClaim:
claimName: api-service-claim

关于kubernetes - 来自服务器的错误 (BadRequest) : error when creating "pod.yaml":,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48808887/

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