0% found this document useful (0 votes)
46 views

Kub Commands

The document describes various kubectl commands for working with Kubernetes objects like pods, replica sets, deployments, services, and namespaces. It includes commands for creating, describing, getting, deleting, exposing, and scaling these objects. Additionally, it shows examples of using configmaps and passing commands/arguments to containers.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views

Kub Commands

The document describes various kubectl commands for working with Kubernetes objects like pods, replica sets, deployments, services, and namespaces. It includes commands for creating, describing, getting, deleting, exposing, and scaling these objects. Additionally, it shows examples of using configmaps and passing commands/arguments to containers.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

------------- commands related to pods---------

kubectl get pods


kubectl run nginx --image=nginx
kubectl describe pod nginx
kubectl describe pod nginx | grep -i image
kubectl get pods -o wide
kubectl get pods nginx
kubectl delete pod nginx
kubectl run redis --image=redis --dry-run=client -o yaml > pod.yaml
kubectl apply -f pod.yaml
kubectl edit pod redis
kubectl get pod <pod-name> -o yaml > pod-definition.yaml

--------------Replica set--------------------
kubectl create -f replicaset.yml
kubectl get replicaset
kubectl delete replicaset myapp-replicaset
kubectl replace -f replicaset.yml
kubectl scale --replicas=6 -f replicaset.yml
kubectl scale --replicas=6 replicaset myapp-replicaset // type/name
kubectl describe replicaset new-replica-set | grep -i image
kubectl apply -f replicaset-definition-1.yaml // to make changes in
replicaset file
kubectl scale --replicas=5 replicasets.apps new-replica-set // to scale
replicaset

-------------Deployment----------------------
kubectl get all
kubectl get deployments
kubectl create deployment --image=nginx nginx
kubectl create deployment nginx --image=nginx --replicas=4

------------Services-----------------------
kubectl expose pod redis --port=6379 --name redis-service --dry-run=client -o yaml
kubectl create service clusterip redis --tcp=6379:6379 --dry-run=client -o yaml
kubectl expose pod nginx --port=80 --name nginx-service --type=NodePort --dry-
run=client -o yaml
kubectl create service nodeport nginx --tcp=80:80 --node-port=30080 --dry-
run=client -o yaml

------------name-space-----------------------
kubectl create namespace test-123 --dry-run -o yaml
kubectl get pods --namespace=kube-system
kubectl create -f pod.yaml --namespace=dev
kubectl create namespace dev
kubectl get pods --all-namespaces

---------Imperative-command------------------
kubectl run nginx --image=nginx --dry-run=client -o yaml
kubectl create deployment --image=nginx nginx --dry-run -o yaml
kubectl create deployment nginx --image=nginx --dry-run=client -o yaml > nginx-
deployment.yaml
kubectl expose pod redis --name redis-service --port 6379 --target-port 6379
kubectl create deployment webapp --image=kodekloud/webapp-color --replicas=3
kubectl run httpd --image=httpd:alpine --port 80 --expose

---------Commands&Arguments-----------------
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-sleeper-2
spec:
containers:
- name: ubuntu
image: ubuntu
command: ["sleep"]
args: ["5000"]

or

containers:
- name: ubuntu
image: ubuntu
command:
- "sleep"
- "1200"

----------cofigmaps-----------------
kubectl get configmaps
kubectl get pod webapp-color -o yaml > pod.yaml
kubectl create cm webapp-config-map --from-literal=APP_COLOR=darkblue
kubectl create cm webapp-config-map --from-literal=APP_COLOR=darkblue

You might also like