I have an application that runs health checks on pods. Given the health check, I am attempting to patch a pod's label selector from being active: true to active: false. The following is the code for the iteration of pods to change each pod's labels.
CoreV1Api corev1Api = new CoreV1Api();
for (V1Pod pod : fetchPodsByNamespaceAndLabel.getItems()) {
String jsonPatchBody = "[{\"op\":\"replace\",\"path\":\"/spec/template/metadata/labels/active\",\"value\":\"true\"}]";
V1Patch patch = new V1Patch(jsonPatchBody);
corev1Api.patchNamespacedPodCall(pod.getMetadata.getName(), namespace, patch, null, null, null, null, null);
}
I have adapted the jsonPatchBody from the Patch Example on the Kubernetes documentation section for examples.
The output of the run spits out no errors. The expected behavior is for the labels of these pods for active to all be set to true. These changes are not reflected. I believe the issue to be caused by the syntax provided by the body of the patch. Is the above the correct syntax for accessing labels in a pod?