How to modify pod(controlled by statefulset) label

Cluster information:

OCP 1.11

Description

As shown in title, I got some pod, they were controlled by statefulset and the label on pod were wrong so I want to have to modify the label.

I tried to use kubectl label pod --overwrite=true, it’s no problem.

But when using kubectl edit sts to modify the selector, I got : Forbidden: updates to statefulset spec for fields other than 'replicas', 'template', and 'updateStrategy' are forbidden.

Then I use kubectl describe sts, I see the controller-manager is creating new pod (because the pod label was modified), fortunately, pod was not successfully created, I got:create pod {pod_name} in statefulset {sts_name} failed error: the post operation against pod could not be completed at this time ,please try again.

So how can i modify the pod label ?

When using a controller to deploy a pod the desired state is governed by the controller in your case the controller is a statefulset.

Changing a specific pod cannot and should not be possible to maintain version integrity on all controller replicas.
Making changes to a kubernes controller. Will always deploy new pods (always roll forward)

But the pod selector in statefulset is wrong, I need to fix them for some reason. @Theog75

is the problem: The Pod manually created and you want to make it part of the statefulset?
if so you cannot do that - in order for a Pod to be owned by a controller (STS included) it has to be created by the controller - in your case the statefulset.

Why not change the image inside the statefulset and let the statefulset deploy the pod?