2025-03-14 21:59:59 -06:00
|
|
|
# kubectl apply
|
|
|
|
|
|
|
|
|
|
> Manage applications through files defining Kubernetes resources.
|
|
|
|
|
> Create and update resources in a cluster.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_apply>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- Apply a configuration to a resource by file name:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl apply {{[-f|--filename]}} {{path/to/file}}`
|
|
|
|
|
|
|
|
|
|
- Apply a configuration to a resource from `kustomization.yaml` in a directory:
|
|
|
|
|
|
|
|
|
|
`kubectl apply {{[-k|--kustomize]}} {{path/to/directory}}`
|
|
|
|
|
|
|
|
|
|
- Apply a configuration to a resource by `stdin`:
|
|
|
|
|
|
|
|
|
|
`{{cat pod.json}} | kubectl apply {{[-f|--filename]}} -`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Edit the latest last-applied-configuration annotations of resources from the default editor:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl apply edit-last-applied {{[-f|--filename]}} {{path/to/file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Set the latest last-applied-configuration annotations by setting it to match the contents of a file:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl apply set-last-applied {{[-f|--filename]}} {{path/to/file}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- View the latest last-applied-configuration annotations by type/name or file:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl apply view-last-applied {{[-f|--filename]}} {{path/to/file}}`
|