Skip to main content
Updated the answer to include a valid, tested YAML file instead of the original.
Source Link
Haxiel
  • 8.7k
  • 1
  • 23
  • 32

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

You seem to be testing the image pull configuration, and you have specified that you simply want to run echo SUCCESS inside the container. Considering both these conditions, it would be preferable to pull down bash image instead of the mysql image.

The following alternate YAML should work correctlyfor your needs:

---
apiVersion: v1
kind: Pod
metadata:
  name: Tesing_for_Image_pulltesting-for-image-pull
spec:
  containers:
  - name: mysqlbash
    image: mysqlbash
    imagePullPolicy: Always
    command: ["echo",["echo"]
 "SUCCESS"]   args: ["SUCCESS"]

Do noteThe following changes have been made from the original YAML file: 1) The kind element has been corrected to the value Pod. 2) The name of the pod has been changed to fit Kubernetes requirements (lowercase DNS-like name). 3) The image and name elements have been modified to use the bash image. 4) The command definition has been changed to use the command and args keys instead.

Note that YAML uses spaces instead of tabs for indentation. Also, and the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

The following YAML should work correctly:

---
apiVersion: v1
kind: Pod
metadata:
  name: Tesing_for_Image_pull
spec:
  containers:
  - name: mysql
    image: mysql
    imagePullPolicy: Always
    command: ["echo", "SUCCESS"]

Do note that YAML uses spaces instead of tabs for indentation. Also, the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

You seem to be testing the image pull configuration, and you have specified that you simply want to run echo SUCCESS inside the container. Considering both these conditions, it would be preferable to pull down bash image instead of the mysql image.

The following alternate YAML should work for your needs:

---
apiVersion: v1
kind: Pod
metadata:
  name: testing-for-image-pull
spec:
  containers:
  - name: bash
    image: bash
    imagePullPolicy: Always
    command: ["echo"]
    args: ["SUCCESS"]

The following changes have been made from the original YAML file: 1) The kind element has been corrected to the value Pod. 2) The name of the pod has been changed to fit Kubernetes requirements (lowercase DNS-like name). 3) The image and name elements have been modified to use the bash image. 4) The command definition has been changed to use the command and args keys instead.

Note that YAML uses spaces instead of tabs for indentation, and the suggested syntax for YAML is to use two spaces per level of indentation instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

edited body
Source Link
Haxiel
  • 8.7k
  • 1
  • 23
  • 32

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

The following YAML should work correctly:

---
apiVersion: v1
kind: podPod
metadata:
  name: Tesing_for_Image_pull
spec:
  containers:
  - name: mysql
    image: mysql
    imagePullPolicy: Always
    command: ["echo", "SUCCESS"]

Do note that YAML uses spaces instead of tabs for indentation. Also, the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

The following YAML should work correctly:

---
apiVersion: v1
kind: pod
metadata:
  name: Tesing_for_Image_pull
spec:
  containers:
  - name: mysql
    image: mysql
    imagePullPolicy: Always
    command: ["echo", "SUCCESS"]

Do note that YAML uses spaces instead of tabs for indentation. Also, the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

The following YAML should work correctly:

---
apiVersion: v1
kind: Pod
metadata:
  name: Tesing_for_Image_pull
spec:
  containers:
  - name: mysql
    image: mysql
    imagePullPolicy: Always
    command: ["echo", "SUCCESS"]

Do note that YAML uses spaces instead of tabs for indentation. Also, the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.

Source Link
Haxiel
  • 8.7k
  • 1
  • 23
  • 32

The simple pod example YAML for Kubernetes shows that the 'metadata' and 'spec' elements required are at the top level of the definition. The kubectl command is most likely failing because it cannot find the 'spec' element, which defines the specification of the pod.

The following YAML should work correctly:

---
apiVersion: v1
kind: pod
metadata:
  name: Tesing_for_Image_pull
spec:
  containers:
  - name: mysql
    image: mysql
    imagePullPolicy: Always
    command: ["echo", "SUCCESS"]

Do note that YAML uses spaces instead of tabs for indentation. Also, the suggested syntax for YAML is to use two spaces per level of indentation, instead of the traditional four spaces.

For more example YAML files, refer to the Kubernetes website repository on GitHub.