liveBook · Manning

Kubectl run

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

kubectl run is a kubectl command that creates a pod from a specified container image and command options.

Creates a pod from a specified container image and command options. Use interactive mode to create a temporary troubleshooting environment inside the pod’s network namespace. section 8.1.2

Open a troubleshooting shell

Run `kubectl run tool --image lansible/dnstools:latest -it`, then test cluster communication with commands such as `nslookup kubernetes`, `curl`, or `cat /etc/resolv.conf`. After exiting, reconnect with `kubectl exec -it tool -- sh`. Add `--rm` to delete the pod when the session ends: `kubectl run curlpod --image=nicolaka/netshoot --rm -it -- sh`. section 8.1.2

Use kubectl run during pod troubleshooting to:

  • Create a shell-capable pod when the failing container cannot be opened. section 8.1.2
  • Generate a pod manifest for later editing with `--dry-run=client -o yaml`. section 8.1.1
root@kind-control-plane:/# kubectl run tool --image 
lansible/dnstools:latest -it
If you don't see a command prompt, try pressing enter.
/ #

Shows the interactive prompt produced when kubectl run creates a troubleshooting pod. section 8.1.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Demonstrates image selection, interactive shells, command execution, cleanup, and manifest generation, but not full resource configuration.
Examples
Uses dnstools, busybox, and netshoot pods for shell access, DNS lookup, Service requests, and disposable diagnostics.
What it assumes
Assumes basic kubectl and pod familiarity while demonstrating shell access, exec, container networking, and manifest generation.
What you can do after
Diagnose/debug with it by launching a shell-capable pod, testing cluster connectivity, executing commands, and removing the pod afterward.
How it connects
Connects pods, container images, network namespaces, kubectl exec, DNS, Kubernetes Services, and YAML manifests.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.