From c5604694567e28157767e0b2778ba86935a3d6e4 Mon Sep 17 00:00:00 2001 From: Lars Windolf Date: Tue, 28 Nov 2023 14:11:07 +0100 Subject: [PATCH] Update kubectl.md --- cheat-sheet/kubernetes/kubectl.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/cheat-sheet/kubernetes/kubectl.md b/cheat-sheet/kubernetes/kubectl.md index 84cc67fe7..76a23fd02 100644 --- a/cheat-sheet/kubernetes/kubectl.md +++ b/cheat-sheet/kubernetes/kubectl.md @@ -46,20 +46,22 @@ Removing/Readding nodes ## Creating/manipulating resources +Working with file based definitions you can issue the lifecycle commands using the same input file: + kubectl create -f some.json - kubectl delete -f some.json # Useful to delete the same resources with the same YAML! - - kubectl edit # Edit live, will automatically restart stuff + kubectl apply -f some.json + kubectl diff -f some.json + kubectl delete -f some.json - kubectl get rc -o yaml >some.yaml - kubectl update -f some.yaml +Note that you can alway use `--dry-run` to review the effective changes + +For existing resources you can use specific commands + kubectl edit # Edit live, will automatically restart stuff + kubectl delete + kubectl annotate [--overwrite=true] key=value - kubectl delete pod -l name= - kubectl delete services <service> - kubectl delete deployment <application> - kubectl run-container --image= --port= kubectl resize --replicas=4 rc @@ -69,13 +71,7 @@ Removing/Readding nodes kubectl set env deployment/ = kubectl set env deployment/ --list kubectl set env pods --all --list - -## Testing kubectl Commands - -Several commands allow passing "--dry-run" to test impact - - kubectl run --dry-run [...] - + ## Debugging in Pods Running commands in pods