Skip to content

Instantly share code, notes, and snippets.

@TNonet
Created December 8, 2024 16:49
Show Gist options
  • Save TNonet/9e511993272c9ef99dd995b6a6c07104 to your computer and use it in GitHub Desktop.
Save TNonet/9e511993272c9ef99dd995b6a6c07104 to your computer and use it in GitHub Desktop.
Patching K8s pod with test + replace of same label
kubectl patch pods/${POD_NAME} -n NAMESPACE --type=json --patch='[{ "op": "test", "path": "/metadata/labels/A", "value": "true" }, { "op": "replace", "path": "/metadata/labels/A", "value": "false" }]' -v=10
I1208 08:41:47.443982 20260 loader.go:373] Config loaded from file: ~/kind-local-config.yml
I1208 08:41:47.445047 20260 cached_discovery.go:113] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/servergroups.json
I1208 08:41:47.446809 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/authentication.k8s.io/v1/serverresources.json
I1208 08:41:47.446811 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/policy.clusterpedia.io/v1alpha1/serverresources.json
I1208 08:41:47.446822 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/policy/v1/serverresources.json
I1208 08:41:47.446826 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/admissionregistration.k8s.io/v1/serverresources.json
I1208 08:41:47.446838 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/certificates.k8s.io/v1/serverresources.json
I1208 08:41:47.446822 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/rbac.authorization.k8s.io/v1/serverresources.json
I1208 08:41:47.446823 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apiregistration.k8s.io/v1/serverresources.json
I1208 08:41:47.446874 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/discovery.k8s.io/v1/serverresources.json
I1208 08:41:47.446938 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/authorization.k8s.io/v1/serverresources.json
I1208 08:41:47.446946 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apps/v1/serverresources.json
I1208 08:41:47.446952 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/v1/serverresources.json
I1208 08:41:47.446989 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/events.k8s.io/v1/serverresources.json
I1208 08:41:47.447004 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/flowcontrol.apiserver.k8s.io/v1beta3/serverresources.json
I1208 08:41:47.447006 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/storage.k8s.io/v1/serverresources.json
I1208 08:41:47.447006 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apiextensions.k8s.io/v1/serverresources.json
I1208 08:41:47.447100 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/networking.k8s.io/v1/serverresources.json
I1208 08:41:47.447443 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/cluster.clusterpedia.io/v1alpha2/serverresources.json
I1208 08:41:47.447463 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/autoscaling/v2/serverresources.json
I1208 08:41:47.448108 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/node.k8s.io/v1/serverresources.json
I1208 08:41:47.448114 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/scheduling.k8s.io/v1/serverresources.json
I1208 08:41:47.448129 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/batch/v1/serverresources.json
I1208 08:41:47.448130 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/flowcontrol.apiserver.k8s.io/v1beta2/serverresources.json
I1208 08:41:47.448137 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/clusterpedia.io/v1beta1/serverresources.json
I1208 08:41:47.448141 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/autoscaling/v1/serverresources.json
I1208 08:41:47.448156 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/coordination.k8s.io/v1/serverresources.json
I1208 08:41:47.448302 20260 cached_discovery.go:113] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/servergroups.json
I1208 08:41:47.448368 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/authentication.k8s.io/v1/serverresources.json
I1208 08:41:47.448388 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/policy/v1/serverresources.json
I1208 08:41:47.448397 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apiregistration.k8s.io/v1/serverresources.json
I1208 08:41:47.448409 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/policy.clusterpedia.io/v1alpha1/serverresources.json
I1208 08:41:47.448414 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/autoscaling/v1/serverresources.json
I1208 08:41:47.448424 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/authorization.k8s.io/v1/serverresources.json
I1208 08:41:47.448453 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/batch/v1/serverresources.json
I1208 08:41:47.448462 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apps/v1/serverresources.json
I1208 08:41:47.448466 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/node.k8s.io/v1/serverresources.json
I1208 08:41:47.448476 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/rbac.authorization.k8s.io/v1/serverresources.json
I1208 08:41:47.448481 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/apiextensions.k8s.io/v1/serverresources.json
I1208 08:41:47.448516 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/events.k8s.io/v1/serverresources.json
I1208 08:41:47.448521 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/certificates.k8s.io/v1/serverresources.json
I1208 08:41:47.448519 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/scheduling.k8s.io/v1/serverresources.json
I1208 08:41:47.448526 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/discovery.k8s.io/v1/serverresources.json
I1208 08:41:47.448546 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/storage.k8s.io/v1/serverresources.json
I1208 08:41:47.448564 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/autoscaling/v2/serverresources.json
I1208 08:41:47.448606 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/networking.k8s.io/v1/serverresources.json
I1208 08:41:47.448570 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/coordination.k8s.io/v1/serverresources.json
I1208 08:41:47.448573 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/v1/serverresources.json
I1208 08:41:47.448582 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/admissionregistration.k8s.io/v1/serverresources.json
I1208 08:41:47.448623 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/flowcontrol.apiserver.k8s.io/v1beta2/serverresources.json
I1208 08:41:47.448593 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/flowcontrol.apiserver.k8s.io/v1beta3/serverresources.json
I1208 08:41:47.448609 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/cluster.clusterpedia.io/v1alpha2/serverresources.json
I1208 08:41:47.448618 20260 cached_discovery.go:77] returning cached discovery info from ~/.kube/cache/discovery/127.0.0.1_65061/clusterpedia.io/v1beta1/serverresources.json
I1208 08:41:47.452101 20260 round_trippers.go:466] curl -v -XGET -H "Accept: application/json" -H "User-Agent: kubectl/v1.27.8 (darwin/arm64) kubernetes/0153a20" 'https://127.0.0.1:65061/api/v1/namespaces/NAMESPACE/pods/POD_NAME'
I1208 08:41:47.458550 20260 round_trippers.go:553] GET https://127.0.0.1:65061/api/v1/namespaces/NAMESPACE/pods/POD_NAME 200 OK in 6 milliseconds
I1208 08:41:47.458564 20260 round_trippers.go:570] HTTP Statistics: GetConnection 0 ms ServerProcessing 6 ms Duration 6 ms
I1208 08:41:47.458569 20260 round_trippers.go:577] Response Headers:
I1208 08:41:47.458574 20260 round_trippers.go:580] Content-Type: application/json
I1208 08:41:47.458578 20260 round_trippers.go:580] X-Kubernetes-Pf-Flowschema-Uid: 98385574-9e1b-41c8-83fb-cf2968d4fd62
I1208 08:41:47.458582 20260 round_trippers.go:580] X-Kubernetes-Pf-Prioritylevel-Uid: e4086ae8-e9e4-43b1-95bd-28435bc52785
I1208 08:41:47.458585 20260 round_trippers.go:580] Date: Sun, 08 Dec 2024 16:41:47 GMT
I1208 08:41:47.458589 20260 round_trippers.go:580] Audit-Id: 5c80a514-b31c-4eac-921e-bd47207ef37f
I1208 08:41:47.458592 20260 round_trippers.go:580] Cache-Control: no-cache, private
I1208 08:41:47.458718 20260 request.go:1188] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"POD_NAME","generateName":"X","namespace":"NAMESPACE","uid":"f3d43c8a-5334-4222-a8b0-9895eafbecc1","resourceVersion":"2149300","creationTimestamp":"2024-12-08T00:38:58Z","labels":{"A":"true"},}}
I1208 08:41:47.459979 20260 request.go:1188] Request Body: [{"op":"test","path":"/metadata/labels/A","value":"true"},{"op":"replace","path":"/metadata/labels/A","value":"false"}]
I1208 08:41:47.460006 20260 round_trippers.go:466] curl -v -XPATCH -H "Accept: application/json" -H "Content-Type: application/json-patch+json" -H "User-Agent: kubectl/v1.27.8 (darwin/arm64) kubernetes/0153a20" 'https://127.0.0.1:65061/api/v1/namespaces/NAMESPACE/pods/POD_NAME?fieldManager=kubectl-patch'
I1208 08:41:47.479178 20260 round_trippers.go:553] PATCH https://127.0.0.1:65061/api/v1/namespaces/NAMESPACE/pods/POD_NAME?fieldManager=kubectl-patch 200 OK in 19 milliseconds
I1208 08:41:47.479196 20260 round_trippers.go:570] HTTP Statistics: GetConnection 0 ms ServerProcessing 19 ms Duration 19 ms
I1208 08:41:47.479200 20260 round_trippers.go:577] Response Headers:
I1208 08:41:47.479206 20260 round_trippers.go:580] X-Kubernetes-Pf-Flowschema-Uid: 98385574-9e1b-41c8-83fb-cf2968d4fd62
I1208 08:41:47.479210 20260 round_trippers.go:580] X-Kubernetes-Pf-Prioritylevel-Uid: e4086ae8-e9e4-43b1-95bd-28435bc52785
I1208 08:41:47.479214 20260 round_trippers.go:580] Date: Sun, 08 Dec 2024 16:41:47 GMT
I1208 08:41:47.479219 20260 round_trippers.go:580] Audit-Id: e34db00f-d6a5-4f31-b29a-197a24f8531d
I1208 08:41:47.479223 20260 round_trippers.go:580] Cache-Control: no-cache, private
I1208 08:41:47.479226 20260 round_trippers.go:580] Content-Type: application/json
I1208 08:41:47.479411 20260 request.go:1188] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"POD_NAME","generateName":"X","namespace":"NAMESPACE","uid":"f3d43c8a-5334-4222-a8b0-9895eafbecc1","resourceVersion":"2151197","creationTimestamp":"2024-12-08T00:38:58Z","labels":{"prewarmed":"false"},}}
pod/POD_NAME patched
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment