It is generally not a good idea to do Pod maintenance using oc rsh
. The right way to go here would be to update the container image and redeploy your application, that is how Kubernetes / OpenShift works.
For example, when one of your Pods is restarted for any reason (the underlying Node has an issue, your application crashes, an administrator deletes a Pod, ...) then your change will be gone as the Pod is restarted.
Usually, container images are built via a pipeline or similar, so re-building an image should not be an issue. That being said, a hacky way to run a command in all Pods is the following:
for pod in $(oc get pods -o name); do
oc rsh $pod pip install x
done
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…