Ошибка с сервера (BadRequest): ошибка при создании "pod.yaml":

Я получаю следующую ошибку при запуске

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: {}

1 ответ

Решение

У вас здесь много проблем. Я описал некоторые из них:

1. pod.yaml Структура файла является структурой Deployment объект.

2.apiVersion за Deployment зависит от версии 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 блок должен быть перемещен на том же уровне, что и 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
Другие вопросы по тегам