What are best ways to run imperative commands?

Using Imperative Commands

  1. Create Pods
  2. Expose Pods
  3. Create a deployment with 3 replicas
  4. Create pods and expose container port
  5. Create a pod. Next, create a service of type ClusterIP by the same name and expose it on PORT 80.
  6. Create a deployment and expose on node port

Example Of imperative commands

  1. Create Pods
    kubectl run redis --image redis:alpine -l label=label1,app=redis --dry-run=client -o yaml

  2. Expose Pods
    kubectl expose pod redis --port=6379 --name redis-service --dry-run=client -o yaml

  3. Create a deployment with 3 replicas
    Ther are 2 ways o do that
    a) run imperative comand o store yaml in file and update replicas
    kubectl create deployment webapp --image nginx --dry-run=client -o yaml
    b) create with imperative command and scale with another command
    kubectl create deployment webapp --image=nginx
    kubectl scale deployment/webapp --replicas=3

  4. Create pods and expose container port
    kubectl run custom-nginx --image=nginx --port=8080

  5. Create a pod. Next, create a service of type ClusterIP by the same name and expose it on PORT 80.
    kubectl run httpd --image=httpd:alpine --port=80 --expose

  6. Create a deployment and expose on node port
    kubectl create deployment webapp --image=nginx
    kubectl expose deployment webapp --port=8080 --name webapp-service

Static Pods as well
kubectl run --restart=Never --image=busybox static-busybox --dry-run -o yaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml