<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://cramsession.net/index.php?action=history&amp;feed=atom&amp;title=Computer_Notes%2FKubernetes%2FKubernetes_Command-Line_Cheat_Sheet</id>
	<title>Computer Notes/Kubernetes/Kubernetes Command-Line Cheat Sheet - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://cramsession.net/index.php?action=history&amp;feed=atom&amp;title=Computer_Notes%2FKubernetes%2FKubernetes_Command-Line_Cheat_Sheet"/>
	<link rel="alternate" type="text/html" href="https://cramsession.net/index.php?title=Computer_Notes/Kubernetes/Kubernetes_Command-Line_Cheat_Sheet&amp;action=history"/>
	<updated>2026-09-10T01:56:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://cramsession.net/index.php?title=Computer_Notes/Kubernetes/Kubernetes_Command-Line_Cheat_Sheet&amp;diff=1842&amp;oldid=prev</id>
		<title>Mflavell: Created page with &quot;&#039;&#039;&#039;Kubernetes Command-Line Cheat Sheet&#039;&#039;&#039; is a reference guide for standard operations using the &lt;code&gt;kubectl&lt;/code&gt; command-line interface to manage Kubernetes clusters, workloads, and node infrastructure.  == Cluster Context &amp; Namespaces == {| class=&quot;wikitable&quot; ! Command !! Description |- | &lt;code&gt;kubectl config get-contexts&lt;/code&gt; || List all available cluster contexts. |- | &lt;code&gt;kubectl config use-context &amp;lt;context-name&amp;gt;&lt;/code&gt; || Switch active cluster context....&quot;</title>
		<link rel="alternate" type="text/html" href="https://cramsession.net/index.php?title=Computer_Notes/Kubernetes/Kubernetes_Command-Line_Cheat_Sheet&amp;diff=1842&amp;oldid=prev"/>
		<updated>2026-09-10T00:14:12Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;#039;Kubernetes Command-Line Cheat Sheet&amp;#039;&amp;#039;&amp;#039; is a reference guide for standard operations using the &amp;lt;code&amp;gt;kubectl&amp;lt;/code&amp;gt; command-line interface to manage Kubernetes clusters, workloads, and node infrastructure.  == Cluster Context &amp;amp; Namespaces == {| class=&amp;quot;wikitable&amp;quot; ! Command !! Description |- | &amp;lt;code&amp;gt;kubectl config get-contexts&amp;lt;/code&amp;gt; || List all available cluster contexts. |- | &amp;lt;code&amp;gt;kubectl config use-context &amp;lt;context-name&amp;gt;&amp;lt;/code&amp;gt; || Switch active cluster context....&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;Kubernetes Command-Line Cheat Sheet&amp;#039;&amp;#039;&amp;#039; is a reference guide for standard operations using the &amp;lt;code&amp;gt;kubectl&amp;lt;/code&amp;gt; command-line interface to manage Kubernetes clusters, workloads, and node infrastructure.&lt;br /&gt;
&lt;br /&gt;
== Cluster Context &amp;amp; Namespaces ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl config get-contexts&amp;lt;/code&amp;gt; || List all available cluster contexts.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl config use-context &amp;amp;lt;context-name&amp;amp;gt;&amp;lt;/code&amp;gt; || Switch active cluster context.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl config set-context --current --namespace=&amp;amp;lt;ns&amp;amp;gt;&amp;lt;/code&amp;gt; || Set default namespace for current context.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get ns&amp;lt;/code&amp;gt; || List all namespaces in the cluster.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Viewing &amp;amp; Inspecting Resources ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get pods -A&amp;lt;/code&amp;gt; || List all pods across all namespaces.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get pods -o wide&amp;lt;/code&amp;gt; || List pods with IP addresses and node assignments.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get all -n &amp;amp;lt;namespace&amp;amp;gt;&amp;lt;/code&amp;gt; || Show all active resources in a specific namespace.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl describe &amp;amp;lt;resource&amp;amp;gt;/&amp;amp;lt;name&amp;amp;gt;&amp;lt;/code&amp;gt; || View detailed state, events, and configuration.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get &amp;amp;lt;resource&amp;amp;gt; &amp;amp;lt;name&amp;amp;gt; -o yaml&amp;lt;/code&amp;gt; || Export resource manifest to YAML format.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Deploying &amp;amp; Managing Workloads ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl apply -f &amp;amp;lt;file.yaml&amp;amp;gt;&amp;lt;/code&amp;gt; || Create or update resources declaratively.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl delete -f &amp;amp;lt;file.yaml&amp;amp;gt;&amp;lt;/code&amp;gt; || Delete resources defined in a YAML manifest.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl scale deploy/&amp;amp;lt;name&amp;amp;gt; --replicas=&amp;amp;lt;N&amp;amp;gt;&amp;lt;/code&amp;gt; || Scale the replica count of a Deployment.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl rollout restart deploy/&amp;amp;lt;name&amp;amp;gt;&amp;lt;/code&amp;gt; || Perform a zero-downtime rolling restart.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl rollout undo deploy/&amp;amp;lt;name&amp;amp;gt;&amp;lt;/code&amp;gt; || Roll back to the previous deployment revision.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Debugging &amp;amp; Observability ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl logs -f &amp;amp;lt;pod-name&amp;amp;gt;&amp;lt;/code&amp;gt; || Stream real-time logs from a pod container.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl logs -p &amp;amp;lt;pod-name&amp;amp;gt;&amp;lt;/code&amp;gt; || View logs from a previous crashed container instance.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl exec -it &amp;amp;lt;pod-name&amp;amp;gt; -- /bin/sh&amp;lt;/code&amp;gt; || Open an interactive shell inside a running pod.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl port-forward svc/&amp;amp;lt;name&amp;amp;gt; 8080:80&amp;lt;/code&amp;gt; || Forward local port 8080 to cluster service port 80.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get events --sort-by=&amp;#039;.metadata.creationTimestamp&amp;#039;&amp;lt;/code&amp;gt; || List recent cluster events sorted by timestamp.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl top pods&amp;lt;/code&amp;gt; / &amp;lt;code&amp;gt;kubectl top nodes&amp;lt;/code&amp;gt; || Display live CPU and memory metrics.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Node Operations &amp;amp; Maintenance ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Command !! Description&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl get nodes&amp;lt;/code&amp;gt; || List all cluster nodes and their current status.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl cordon &amp;amp;lt;node-name&amp;amp;gt;&amp;lt;/code&amp;gt; || Mark a node as unschedulable.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl drain &amp;amp;lt;node-name&amp;amp;gt; --ignore-daemonsets&amp;lt;/code&amp;gt; || Safely evict all pods before node maintenance.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;kubectl uncordon &amp;amp;lt;node-name&amp;amp;gt;&amp;lt;/code&amp;gt; || Mark a node as schedulable again.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Essential Productivity Shell Shortcuts ==&lt;br /&gt;
Add these shortcuts to your shell profile (&amp;lt;code&amp;gt;~/.bashrc&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;~/.zshrc&amp;lt;/code&amp;gt;) to speed up workflow:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
alias k=&amp;#039;kubectl&amp;#039;&lt;br /&gt;
alias kgp=&amp;#039;kubectl get pods&amp;#039;&lt;br /&gt;
alias kgs=&amp;#039;kubectl get svc&amp;#039;&lt;br /&gt;
alias kgd=&amp;#039;kubectl get deployments&amp;#039;&lt;br /&gt;
alias kdp=&amp;#039;kubectl describe pod&amp;#039;&lt;br /&gt;
alias kl=&amp;#039;kubectl logs -f&amp;#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Kubernetes]]&lt;br /&gt;
* [[Secure Shell]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Kubernetes]]&lt;br /&gt;
[[Category:Cheat Sheets]]&lt;br /&gt;
[[Category:System Administration]]&lt;/div&gt;</summary>
		<author><name>Mflavell</name></author>
	</entry>
</feed>