Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 来自服务器的错误(BadRequest):创建“时出错”;“亚马尔舱”:_Kubernetes_Kubectl - Fatal编程技术网

Kubernetes 来自服务器的错误(BadRequest):创建“时出错”;“亚马尔舱”:

Kubernetes 来自服务器的错误(BadRequest):创建“时出错”;“亚马尔舱”:,kubernetes,kubectl,Kubernetes,Kubectl,我在运行时遇到以下错误 kubectl create -f pod.yaml 错误 minikube已启动并正在运行,我甚至尝试将其更改为kind:Deployment,但我收到另一个错误提示: error: unable to recognize "pod.yaml": no matches for /, Kind=Deployment 亚马尔: 你这里有很多问题。我已经描述了其中的一些: 1. pod.yaml文件的结构是部署对象的结构 2. 部署的apiVersion取决于kubern

我在运行时遇到以下错误

kubectl create -f pod.yaml
错误

minikube已启动并正在运行,我甚至尝试将其更改为
kind:Deployment
,但我收到另一个错误提示:

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


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

1.
pod.yaml
文件的结构是
部署
对象的结构

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

  • apps/v1beta1
    适用于1.8.0之前的版本
  • apps/v1beta2
    适用于1.9.0之前的1.8.0版本
  • apps/v1
    适用于从1.9.0开始的版本
因此,如果您在最新的kubernetes集群上部署
pod.yaml
,那么应该从以下位置开始:

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
块应在与
spec.template.metadata
相同的级别上移动:

    spec:
      replicas: 1
      template:
        metadata:
          labels: 
            app: product-ratings-vue
        spec:
          containers: 
最后的
部署.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

请发布你的
pod.yaml
。聊天?我将把它标记为已解决,因为它确实解决了问题。@Drew1208让我们来聊聊
volumes
语句应该在
容器的所有项目下方。
    spec:
      replicas: 1
      template:
        metadata:
          labels: 
            app: product-ratings-vue
        spec:
          containers: 
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