LinuxCommandLibrary

kubectl

TLDR

Get resources

$ kubectl get [pods|deployments|services|nodes]
copy
Describe resource
$ kubectl describe [pod] [name]
copy
Apply manifest
$ kubectl apply -f [manifest.yaml]
copy
Delete resource
$ kubectl delete [pod] [name]
copy
View logs
$ kubectl logs [pod-name]
copy
Execute in pod
$ kubectl exec -it [pod-name] -- [/bin/bash]
copy
Port forward
$ kubectl port-forward [pod-name] [8080:80]
copy

SYNOPSIS

kubectl [options] command [type] [name] [flags]

DESCRIPTION

kubectl is the Kubernetes command-line tool. It communicates with the Kubernetes API to manage cluster resources.
The tool creates, inspects, updates, and deletes workloads. It's the primary interface for cluster administration.
kubectl manages Kubernetes clusters.

PARAMETERS

get TYPE

List resources.
describe TYPE NAME
Show resource details.
apply -f FILE
Apply configuration.
delete TYPE NAME
Delete resource.
logs POD
Show pod logs.
exec POD
Execute in container.
-n NAMESPACE
Target namespace.
--help
Display help information.

CAVEATS

Requires kubeconfig. Context determines cluster. RBAC affects access.

HISTORY

kubectl is the official CLI for Kubernetes, developed as the primary cluster management interface.

SEE ALSO

kubeadm(1), k9s(1), helm(1), kubectx(1)

Copied to clipboard