Show Menu
Cheatography

Kubectl Cheat Sheet by [deleted]

Kubernetes kubectl reference

Viewing / Accessing resources

kubectl get --all-­nam­espaces {resou­rce­_type}
Get resource from all namespaces
kubectl describe {resou­rce­_type}
Describes the given resources
kubectl rollin­g-u­pdate {pod_name}
Performs a rolling update for a given pod
kubectl scale --repl­icas=3 {resou­rce­_ty­pe}­/{r­eso­urc­e_name}
Scale given resource
kubectl proxy
Proxy the api server API to your local machine on port 8001
kubectl port-f­orward {pod_name} {local­_po­rt}­:{r­emo­te_­port}
Forward the pod port to your local port

Creating /editing objects

kubectl apply -f ./my-m­ani­fes­t.yaml
Apply a config­uration to a resource by filename or stdin. Also overrides the existing config­ura­tion.
kubectl create -f ./my-m­ani­fes­t.yaml
Create resour­ce(s)
kubectl create -f ./dir
Create resour­ce(s) in all manifest files in dir
Create from url
kubectl run nginx --imag­e=nginx
Start a single instance of nginx
kubectl replace --force -f ./pod.json
Force replace, delete and then re-create the resource. Will cause a service outage.
kubectl edit svc/do­cke­r-r­egistry
Edit the service named docker­-re­gistry
 

Resource types

configmaps
ConfigMaps allow you to decouple config­uration artifacts from image content to keep contai­nerized applic­ations portable.
daemonsets
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod.
deploy­ments
A Deployment controller provides declar­ative updates for Pods and Replic­aSets.
ingresses
An Ingress is a collection of rules that allow inbound connec­tions to reach the cluster services.
jobs
A job creates one or more pods and ensures that a specified number of them succes­sfully terminate.
namespaces
Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namesp­aces.
nodes
Nodes are the physical cluster nodes.
persis­ten­tvo­lum­eclaims
A Persis­ten­tVo­lum­eClaim (PVC) is a request for storage by a user.
persis­ten­tvo­lumes
A Persis­ten­tVolume (PV) is a piece of storage in the cluster that has been provis­ioned by an admini­str­ator.
pods
A Pod is the basic building block of Kubern­ete­s–the smallest and simplest unit in the Kubernetes object model that you create or deploy.
replic­asets
A ReplicaSet ensures that a specified number of pod replicas are running at any one time.
cronjob
A Cron Job manages time based Jobs.
secrets
Objects of type secret are intended to hold sensitive inform­ation.
services
A Kubernetes Service is an abstra­ction which defines a logical set of Pods and a policy by which to access them.
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Kubectl Cheat Sheet