Kubernetes YAML Cheat Sheet/Add or update label from CLI

Patch a label onto a resource.

Section: Metadata, Labels, and Annotations

Add or update label from CLI

bash
bash
kubectl label deployment api tier=web --overwrite

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Metadata, Labels, and Annotations
Get resources by label selector
Use labels to query related objects.
OpenIn sheetbashsame section
Labels and annotations example
Common metadata block for selectors and tooling.
OpenIn sheetyamlsame section
Add annotation from CLI
Write metadata without affecting selectors.
OpenIn sheetbashsame section
Explain a field path
Discover valid YAML fields from kubectl.
OpenIn sheetbash1 tag match
Apply YAML file
Create or update resources from a YAML file.
OpenIn sheetbash1 tag match
Apply YAML directory
Apply all manifests in a directory.
OpenIn sheetbash1 tag match