POD Yaml file issue

Hi , I am using below code to create a pod. but its throwing error. Please help me out.

Code -
apiVersion: v1
kind: pod
metadata
name: my-pod
labels:
app: mypod1
tier: frontend
spec:
containers:
-name: nginx
image: nginx "

Error - "Error from server (BadRequest): error when creating “pod.yaml”: pod in version “v1” cannot be handled as a Pod: no kind “pod” is registered for version “v1” in scheme “k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30

Hello, @rahulc.devops
first letter of resource name should be capital.

kind: Pod

Thanks a lot…It worked

@Tej-Singh-Rana , Thank you sir.

pod-definition.yaml
apiVersion: v1
kind: Pod
metadata:
name: redis
labels:
app: redis-app

spec:
containers:
-name: redis-image
image: redis123

using command- kubectl create -f pod-definition.yaml
Getting below error:
Error from server (BadRequest): error when creating “pod-definition.yaml”: Pod in version “v1” cannot be handled as a Pod: json: cannot unmarshal object into Go struct field PodSpec.spec.containers of type []v1.Container

Hi @harshtaneja166,

I don’t now if it’s a copy paste issue or not but you need to respect some structure, i spsect that the space just after - on -name create this issue. Try the following syntax :

apiVersion: v1
kind: Pod
metadata:
  name: redis
  labels:
    app: redis-app
spec:
  containers:
  - name: redis-image
    image: redis123

NB : redis123 is not a correct image

Regard

It worked for me, thank you!