Restarts some Pods in Kubernetes, selected by labels
-grace-period int
the duration in seconds before the object should be deleted. (default 30)
-namespace string
specify the namespace of the pods (default "default")
-selector string
label selector
Delete all Pods in default Namespace
pod-restarter -namespace=default
Delete all Pods with label "app=nginx" in default Namespace
pod-restarter -namespace=default -selector="app=nginx"
- https://github.com/kubernetes/client-go
- https://github.com/kubernetes/client-go/blob/master/examples/out-of-cluster-client-configuration/main.go
- https://github.com/kubernetes/client-go/blob/master/examples/in-cluster-client-configuration/main.go
- Check if the Pod is created by a controller. If yes, check delete the pod, if no, check whether the flag "-ignore-naked-pods" is set.