✅ Restart k8s pod from .net app
Has someone ever restarted/deleted a pod from a .net app? I have a very specific scenario where I must do from the app.
15 Replies
Just shell out to kubectl using
System.Diagnostics.Process
?This isn't how you want to do this. You have to bake the binary into the image then also pull its auth tokens and build the request manually
@ayjay this is not normally a thing you need to do from an application pod but you'll need to mount a service account with the correct rbac on it then use the generate oapi client in dotnet
GitHub
GitHub - kubernetes-client/csharp: Officially supported dotnet Kube...
Officially supported dotnet Kubernetes Client library - GitHub - kubernetes-client/csharp: Officially supported dotnet Kubernetes Client library
Maybe I misunderstood the question. I read it as: I want to write some program (say, a console app) and run that app locally (or somewhere) to restart a pod.
I envisioned something like what k9s does (which I believe just runs kubectl commands...)
Ah maybe that's the case, even in that case tho it's easier to use the client for your language.
K9s uses normal client-go
Using kubectl for the watches would be very inefficient
I hardly do anything with kubernets so I'm sure you know more than I do about it 🙂
Not that shelling out to kubectl won't work or isn't a thing that people do. But it's usually more of a pain than it's worth when the official clients can auth with nicer ergonomics
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
It'll restart the container, the pod won't go away. So if you need a reschedule you need the api call
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
It says both restarted and deleted in the op
:hmm: coin flip here imo
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
Both help in my case, i will try with liveness probe
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View
If you have no further questions, please use /close to mark the forum thread as answered