We are using kubernetes for deployment of our microservices , In production mode we will not be able to access kubernetes directly , So is there any way to perform operation like delete a pod using rest api calls or perform any operation through http requests.
We need to delete a pod or its replica set to restart the pod forcefully.
Like we access a remote kubernetes and delete a particular pod at runtime
Yes by setting up RBAC.
You need following:
Then with given Serivce Account token you can either use kubectl
or actual REST call to k8s apiserver to delete.
If you will not receive the right to access the kubectl command or API for the production, you should implement a liveness probe on the container.
https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/
This you can do entirely in software in your microservices. The liveness check should fail, if your application is no longer "good". You can combine the liveness check with a system condition that you can create manually (a field "restart_request" in the database is set to 1, a file exists or sth like that)
This way, you can restart your containers manually and k8s will restart them for you if they cease to operate properly.