본문 바로가기

SW Development

[Kubernetes] cheating sheet

# Create a deployment called "web1" with the nginx web server image

kubectl create deployment --image nginxdemos/hello web1

 

#Expose the deployment to the network

kubectl expose deployment web1 --port=80 --type=LoadBalancer

 

# Get all

kubectl get all

 

# Get pods

kubectl get pod

kubectl get pod -w

 

# Get deployments

kubectl get deploy

kubectl get deploy -w

kubectl get deploy -o wide

 

# Get node information

kubectl get nodes -o wide

 

# Describe pods

kubectl describe pod

kubectl describe pod <pod-name>

 

# Delete pods

kubectl delete pod <pod-name>

 

# Describe deployment 

kubectl describe deploy 

kubectl describe deploy <deployment-name>

 

# View logs

kubectl logs <pod-name>

 

# Scale

kubectl scale deploy <deployment-name> --replicas=20

 

# Autoscaling is possible with autoscal command

kubectl autoscale deployment <deployment-name> --min=2 --max=10

 

# Deploy from YAML file

kubectl apply -f https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml

# Delete deployment and service

kubectl delete deployment -l app=redis

kubectl delete service -l app=redis

 

# Get in the pod

kubectl exec -it <pod-name> -- <shell>

ex. kubectl exec -it web1-59b9cfcfc9-bzszs -- bin/sh

ex. kubectl exec web1-59b9cfcfc9-bzszs -- cat /etc/hosts # Show /etc/hosts contains in the web1-59b9cfcfc9-bzszs pod.

 

# Check Resource

kubectl top node

kubectl top pod

kubectl describe pod <pod-name>

 

'SW Development' 카테고리의 다른 글

[Helm] popular commands  (0) 2020.07.26
[Docker] Cheating sheet  (0) 2020.03.28
Conditional Segue  (0) 2016.03.27
Code productivity  (0) 2015.09.13