- Imperative commands are useful in quickly creating the resources on Kubernetes
kubectl
--dry-run -> When created with this option, Kubernetes just validates the definition and does not actually create the resource
-o=yaml -> Gets the output in YAML format
kubectl run nginx-pod --image=nginx:alpine
-> Create a pod with name nginx-pod and image nginx:alpine
kubectl run httpd --image=httpd:alpine
-> By default, run implies run-a-pod
kubectl run redis --image=redis:alpine --labels=tier=db
-> Create a pod with name redis and image redis:alpine and labels set to tier=db
kubectl run custom-nginx --image=nginx --port=8080
-> Create a pod with name custom-nginx and image nginx to run on port 8080
kubectl expose pod redis --port=6379 --name=redis-service
-> Create a service with name redis-service to expose pod named redis on service-port 6379
kubectl create deployment webapp --image=kodekloud/webapp-color --replicas=3
-> Create a deployment with name webapp and image set with 3 replicas
kubectl create ns dev-ns
-> Create a nanespace dev-ns
kubectl create deployment redis-deploy --namespace=dev-ns --image=redis --replicas=2
-> Create a deployment
kubectl expose pod httpd --name=httpd --type=ClusterIP --port=80 --target-port=8080
-> Expose a pod as service of type ClusterIP on the specifed ports
Comments
Post a Comment