This project helps to manage periodically restart deployment job for Kubernetes. It all centralized using one config or via annotations so you don't have to configure cronjob for every deployments manually. This project can work with either deployment or statefulsets.
You can either apply the config using config file or via annotations on the deployments or statefulsets.
The config file is pretty simple consisting the list of deployments and statefulsets.
deployments:
- name: demo-deployment
namespace: default
schedule: "* * * * *"
- name: ingress-nginx-controller
namespace: ingress-nginx
schedule: "* * * * *"
statefulsets:
- name: demo-statefulsets-redis-replicas
namespace: default
schedule: "*/5 * * * *"
You can add kube.restart/schedule
annotation to the deployments or statefulsets to configure the restart schedule.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kube.restart/schedule: '1 * * * *'
name: demo-deployment
namespace: default
...
make build
make build
CONFIG_PATH=<CONFIG_PATH> ./service --kubeconfig=<KUBECONFIG_PATH>
helm repo add kube-restart https://bahybintang.github.io/kube-restart
helm install kube-restart kube-restart/kube-restart
You can specify config in the Helm values, see this example.