Home>

I want to create a container from a local container image with kubenetes

error: error validating "deployments.yaml": error validating data: ValidationError (Deployment.spec.template.spec): unknown field "imagePullPolicy" in io.k8s.api.core.v1.PodSpec;if you choose to ignore these errors , turn validation off with --validate = false
Corresponding source code
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bot
spec: spec:
  replicas: 1
  selector:
    matchLabels:
      app: bot
  template:
    metadata:
      labels: labels:
        app: bot
    spec: spec:
      containers: containers:
      --image: testbot
        name: bot
      imagePullPolicy: Never
What I tried

docker build --tag testbot: bot ..Was executed
kubectl apply -f deployments.yamlWas executed

Supplementary information (FW/tool version, etc.)

Ubuntu 20.04.1 LTS
Docker version 19.03.8
Kubernetes v1.19.1

  • Answer # 1

    In the error message

    error: error validating "deployments.yaml": error validating data: ValidationError (Deployment.spec.template.spec): unknown field "imagePullPolicy" in io.k8s.api.core.v1.PodSpec;if you choose to ignore these errors , turn validation off with --validate = false

    So the first thing you should try is
    "Doubt that the description in deployments.yaml is really grammatical"
    is.

    As far as the Kubernetes image documentation is concernedimagePullPolicyIsimageIt looked like an element that should be placed in the same hierarchy as.

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: bot
    spec: spec:
      replicas: 1
      selector:
        matchLabels:
          app: bot
      template:
        metadata:
          labels: labels:
            app: bot
        spec: spec:
          containers: containers:
          --image: testbot
            name: bot
    + imagePullPolicy: Never
    --imagePullPolicy: Never

Related articles