To restart pods in Kubernetes, you can use the `kubectl rollout restart` command, which triggers a rolling restart of the deployment. This command updates the pod template by incrementing the deployment's template annotation, causing Kubernetes to recreate the pods.
kubectl rollout restart deployment <deployment-name>
Alternatively, modify a label or annotation in the pod's YAML file to trigger a restart:
kubectl edit deployment <deployment-name>
Add or modify a label or annotation, such as:
spec:
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: '2023-10-01T12:00:00Z'