diff --git a/.gitignore b/.gitignore index 0a764a4..7a7d633 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -env +env.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..a1bd601 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# pvc-reaper + +The PersistentVolumeClaim Reaper cleans up `PersistentVolumes` created by Tekton Pipelines that are stuck in the `terminating` state. + +# Build and run + +``` +echo KO_DOCKER_REPO='gcr.io/my-gcloud-project-name' >env.txt + +./build.sh +``` diff --git a/build.sh b/build.sh index 342b0cc..eab5770 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,7 @@ #!/bin/bash -source env +source env.txt +kubectl -n pvc-reaper delete deploy pvc-reaper ko apply -f config/ sleep 5 -kubectl -n pvc-reaper logs -f $(kubectl -n pvc-reaper get pod -ojsonpath='{.items[*].metadata.name}') +kubectl -n pvc-reaper logs -f $(kubectl -n pvc-reaper get pod -ojsonpath='{.items[0].metadata.name}') diff --git a/config/00-namespace.yaml b/config/00-namespace.yaml index 06ec20a..2e94744 100644 --- a/config/00-namespace.yaml +++ b/config/00-namespace.yaml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: Namespace metadata: diff --git a/config/01-podsecuritypolicy.yaml b/config/01-podsecuritypolicy.yaml index 26f287f..b25db9e 100644 --- a/config/01-podsecuritypolicy.yaml +++ b/config/01-podsecuritypolicy.yaml @@ -1,3 +1,4 @@ +--- apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: diff --git a/config/02-sa.yaml b/config/02-sa.yaml index 9d1ccae..e27a230 100644 --- a/config/02-sa.yaml +++ b/config/02-sa.yaml @@ -1,3 +1,4 @@ +--- apiVersion: v1 kind: ServiceAccount metadata: @@ -10,12 +11,9 @@ metadata: name: pvc-reaper namespace: pvc-reaper rules: -- apiGroups: [""] - resources: ["secrets"] - verbs: ["get"] - apiGroups: [""] resources: ["persistentvolumes", "persistentvolumeclaims"] - verbs: ["get", "list", "watch", "update", "patch", "delete"] + verbs: ["get", "list", "watch", "patch"] - apiGroups: ["policy"] resources: ["podsecuritypolicies"] resourceNames: ["pvc-reaper"] diff --git a/config/deployment.yaml b/config/deployment.yaml index d8d4618..b0794dd 100644 --- a/config/deployment.yaml +++ b/config/deployment.yaml @@ -1,3 +1,4 @@ +--- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/main.go b/main.go index 6f8d6a5..e288292 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,5 @@ +// Copyright (C) 2019 Marius Schellenberger + package main import (