Show Menu

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_n­ame}
Performs a rolling update for a given pod
kubectl scale --repl­icas=3 {resou­rce­_ty­pe}­/{r­eso­urc­e_n­ame}
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.j­son
Force replace, delete and then re-create the resource. Will cause a service outage.
kubectl edit svc/do­cke­r-r­egi­stry
Edit the service named docker­-re­gistry

Resource types

ConfigMaps allow you to decouple config­uration artifacts from image content to keep contai­nerized applic­ations portable.
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod.
A Deployment controller provides declar­ative updates for Pods and Replic­aSets.
An Ingress is a collection of rules that allow inbound connec­tions to reach the cluster services.
A job creates one or more pods and ensures that a specified number of them succes­sfully terminate.
Kubernetes supports multiple virtual clusters backed by the same physical cluster. These virtual clusters are called namesp­aces.
Nodes are the physical cluster nodes.
A Persis­ten­tVo­lum­eClaim (PVC) is a request for storage by a user.
A Persis­ten­tVolume (PV) is a piece of storage in the cluster that has been provis­ioned by an admini­str­ator.
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.
A ReplicaSet ensures that a specified number of pod replicas are running at any one time.
A Cron Job manages time based Jobs.
Objects of type secret are intended to hold sensitive inform­ation.
A Kubernetes Service is an abstra­ction which defines a logical set of Pods and a policy by which to access them.

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


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