some improvements
This commit is contained in:
parent
523fdec5ce
commit
498de9b0b8
4 changed files with 4 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
# pvc-reaper
|
# pvc-reaper
|
||||||
|
|
||||||
The PersistentVolumeClaim Reaper cleans up `PersistentVolumes` created by Tekton Pipelines that are stuck in the `terminating` state.
|
The PersistentVolumeClaim Reaper cleans up `PersistentVolumeClaims` created by Tekton Pipelines that are stuck in the `Terminating` state.
|
||||||
|
|
||||||
# Build and run
|
# Build and run
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ spec:
|
||||||
requiredDropCapabilities:
|
requiredDropCapabilities:
|
||||||
- ALL
|
- ALL
|
||||||
readOnlyRootFilesystem: true
|
readOnlyRootFilesystem: true
|
||||||
volumes:
|
|
||||||
- 'secret'
|
|
||||||
hostNetwork: false
|
hostNetwork: false
|
||||||
hostIPC: false
|
hostIPC: false
|
||||||
hostPID: false
|
hostPID: false
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
metadata:
|
metadata:
|
||||||
name: pvc-reaper
|
name: pvc-reaper
|
||||||
namespace: pvc-reaper
|
|
||||||
rules:
|
rules:
|
||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: ["persistentvolumes", "persistentvolumeclaims"]
|
resources: ["persistentvolumes", "persistentvolumeclaims"]
|
||||||
|
|
@ -23,7 +22,6 @@ apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRoleBinding
|
kind: ClusterRoleBinding
|
||||||
metadata:
|
metadata:
|
||||||
name: pvc-reaper
|
name: pvc-reaper
|
||||||
namespace: pvc-reaper
|
|
||||||
roleRef:
|
roleRef:
|
||||||
apiGroup: rbac.authorization.k8s.io
|
apiGroup: rbac.authorization.k8s.io
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
|
|
|
||||||
7
main.go
7
main.go
|
|
@ -27,14 +27,12 @@ var emptyFinalizers = []byte(`{"metadata":{"finalizers":null}}`)
|
||||||
func main() {
|
func main() {
|
||||||
cfg, err := rest.InClusterConfig()
|
cfg, err := rest.InClusterConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error configuring kube client: %s\n", err)
|
log.Fatalf("error configuring kube client: %s\n", err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cl, err := kubernetes.NewForConfig(cfg)
|
cl, err := kubernetes.NewForConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error creating new kube client: %s\n", err)
|
log.Fatalf("error creating new kube client: %s\n", err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
factory := informers.NewSharedInformerFactory(cl, time.Second*30)
|
factory := informers.NewSharedInformerFactory(cl, time.Second*30)
|
||||||
pvcInformer := factory.Core().V1().PersistentVolumeClaims().Informer()
|
pvcInformer := factory.Core().V1().PersistentVolumeClaims().Informer()
|
||||||
|
|
@ -88,6 +86,7 @@ func main() {
|
||||||
|
|
||||||
stop := make(chan struct{})
|
stop := make(chan struct{})
|
||||||
factory.Start(stop)
|
factory.Start(stop)
|
||||||
|
log.Println("started pvc watcher")
|
||||||
|
|
||||||
sigs := make(chan os.Signal)
|
sigs := make(chan os.Signal)
|
||||||
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue