Declarative way - using yaml file:
$ cat nginx-pod.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 80
name: nginx-pod
After that invoke kubectl:
kubectl apply -f ./nginx-pod.yml
kubectl run nginxpod --image=nginx
To generate yaml in imperative way, use this command:
kubectl run nginxpod --image=nginx --dry-run=client -o yaml