Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kgoksal/k8s-cheat-sheet

K8S Cheat Sheet
https://github.com/kgoksal/k8s-cheat-sheet

Last synced: about 1 month ago
JSON representation

K8S Cheat Sheet

Awesome Lists containing this project

README

        

# CLUSTER MANAGEMENT
### 1. Display endpoint details for the cluster’s master and services.
**$ kubectl cluster-info**
### 2. Show the Kubernetes version that is active on
the server and client
**$ kubectl version**
### 3. Get the cluster’s configuration
**$ kubectl config view**
### 4. List the available API resources
**$ kubectl api-resources**
### 5. List everything
**$ kubectl get all --all-namespaces** / kubectl get all -A

# NODE MANAGEMENT
### 1. List the nodes
**$ kubectl get node**
### 2. Update the taints on nodes
**$ kubectl taint node **
### 3. Delete a node
**$ kubectl delete node **

# POD MANAGEMENT

### 1. List pods
**$ kubectl get pod**
### 2. Delete a pod
**$ kubectl delete pod **
### 3. See detailed state of a pods
**$ kubectl describe pod **
### 4. Create a pod
**$ kubectl create pod **
### 5. Run a command for a container inside a pod
**$ kubectl exec -c **
### 6. Get interactive shell on a pod
**$ kubectl exec -it /bin/sh**
### 7. See resource usage (CPU/Memory/Storage) for pods
**$ kubectl top pod**
### 8. Add/update the annotations of a pod
$ kubectl annotate pod
### 9. Add/update the label of a pod
$ kubectl label pod
### 10. View the list of replication controllers
$ kubectl get rc
### 11. View the list of replication controllers by
namespace
$ kubectl get rc --namespace=””
### 12. Scale a ReplicaSet
$ kubectl scale --replicas=
replicaset

# DEPLOYMENT MANAGEMENT

### 1. List the deployments
$ kubectl get deployment
### 2. Show the precise status of single or multiple
deployments.
$ kubectl describe deployment
### 3. Edit and update the deployment.
$ kubectl edit deployment
### 4. Create a new deployment
$ kubectl create deployment
### 5. Delete a deployment
$ kubectl delete deployment
### 6.Check the rollout status of a deployment
$ kubectl rollout status deployment

### 7. Display Resource usage (CPU/Memory/Storage)
for nodes
$ kubectl top node
### 8. See resource allocation per node
$ kubectl describe nodes | grep Allocated -A 5
### 9.List the pods running on a node
$ kubectl get pods -o wide | grep
### 10. To annotate a node
$ kubectl annotate node
### 11. Add or update the labels of a node
$ kubectl label nodes
### 12. Scale a Deployment
$ kubectl scale deployment --
replicas=

# SECRETS
### 1. Create a secret
$ kubectl create secret
### 2. List secrets
$ kubectl get secrets
### 3. View details about secrets
$ kubectl describe secrets
### 4. Delete a secret
$ kubectl delete secret

# SERVICES
### 1. List the services
**$ kubectl get services**
### 2. View the detailed state of a service
**$ kubectl describe services **
### 3. Expose a replication controller, deployment or pod as a new Kubernetes service
**$ kubectl expose deployment [deployment_name]**
### 4. Edit/update the definition of a service
**$ kubectl edit service **

# COMMON OPTIONAL FLAGS
### 1. –o Format of output. (Suppose you wanted to list all of the pods in ps output format with additional information.)
**$ kubectl get pods -o wide**
### 2. Create any resource(pod/replicaset/deployment, etc) using a yaml/json file.
**$ kubectl apply -f **
### 3. dry run:
**$ kubectl apply -f --dry-run=client**
### 3. dry run + yaml format:
**$ kubectl apply -f --dry-run=client -o yaml**