运行
时出现以下错误kubectl create -f pod.yaml
错误
Error from server (BadRequest): error when creating "pod.yaml": Pod in
version "ratings:v1" cannot be handled as a Pod: no kind "Pod" is
registered for version "ratings:v1"
minikube启动并运行,我甚至尝试将其更改为kind: Deployment
,但我又收到了一条错误消息:
error: unable to recognize "pod.yaml": no matches for /, Kind=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: {}
volumes:
- name: api-service-claim
persistentVolumeClaim:
claimName: api-service-claim
# tomcat
- name: tomcat
image: tomcat
# node
- name: node
image: node
resources: {}
# openJdk
- name: node
- image: node
resources: {}
答案 0 :(得分:4)
这里有很多问题。我已经描述了其中一些:
<强> 1 强>
pod.yaml
文件的结构是Deployment
对象的结构。
<强> 2 强>
apiVersion
的{{1}}取决于kubernetes版本:
Deployment
适用于1.8.0之前的版本apps/v1beta1
适用于从1.9.0之前的1.8.0开始的版本apps/v1beta2
适用于从1.9.0开始的版本因此,如果您在最新的kubernetes群集上部署apps/v1
,则应该从以下位置开始:
pod.yaml
第3 强> 部分:
apiVersion: apps/v1
kind: Deployment
应更改为:
spec:
replicas: 1
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
template:
metadata:
labels:
app: product-ratings-vue
<强> 4 强>
第二个spec:
replicas: 1
template:
metadata:
labels:
app: product-ratings-vue
块应移至与spec
相同的级别:
spec.template.metadata
最终 spec:
replicas: 1
template:
metadata:
labels:
app: product-ratings-vue
spec:
containers:
是:
deployment.yaml