From dc264f185fe611e9c8927eb5a847842c0b356301 Mon Sep 17 00:00:00 2001 From: Yannik Schmidt Date: Tue, 3 Dec 2024 11:25:29 +0100 Subject: [PATCH] Clean up namespace in Helm and config of values --- README.md | 5 ++--- helm/templates/deployment.yaml | 4 ++-- helm/values.yaml | 5 ++--- main.go | 6 ++++++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0116f1e..c4efede 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ It is a Kubernetes operator that cleans unused workspaces periodically. ## Configuration The following values can be configured via environment variables: -- `K8S_NAMESPACE`: The namespace in which theia-ide pods are running. Default is `theia-prod`. -- `WORKSPACE_TTL`: The time to live of a workspace. Default is 2 weeks (1209600 000 000 000). -- `CHECK_INTERVAL`: The interval at which the operator checks for unused workspaces. Default is 1 hour (1800 000 000 000). +- `WORKSPACE_TTL`: The time to live of a workspace. Default is 2 weeks (1209600s). +- `CHECK_INTERVAL`: The interval at which the operator checks for unused workspaces. Default is 1 hour (1800s). ## Deployment `helm upgrade --install theia-workspace-garbage-collector ./helm -f ./helm/values.yaml` \ No newline at end of file diff --git a/helm/templates/deployment.yaml b/helm/templates/deployment.yaml index bb6798f..4812de4 100644 --- a/helm/templates/deployment.yaml +++ b/helm/templates/deployment.yaml @@ -21,8 +21,8 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: K8S_NAMESPACE - value: {{ .Values.env.K8S_NAMESPACE | quote }} + value: {{ .Release.Namespace | quote }} - name: WORKSPACE_TTL - value: {{ .Values.env.WORKSPACE_TTL | quote}} + value: {{ .Values.env.WORKSPACE_TTL | quote }} - name: CHECK_INTERVAL value: {{ .Values.env.CHECK_INTERVAL | quote }} \ No newline at end of file diff --git a/helm/values.yaml b/helm/values.yaml index 939c392..cd385fc 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -8,6 +8,5 @@ serviceAccount: name: garbage-collector-sa env: - K8S_NAMESPACE: "theia-prod" - WORKSPACE_TTL: "1209600000000000" - CHECK_INTERVAL: "1800000000000" + WORKSPACE_TTL: "1209600s" + CHECK_INTERVAL: "1800s" diff --git a/main.go b/main.go index 771ddf0..9fcb019 100644 --- a/main.go +++ b/main.go @@ -53,6 +53,12 @@ func main() { defer stop() fmt.Println("Starting garbage collector...") + + // Print configuration + fmt.Printf("- Namespace: %s\n", namespace) + fmt.Printf("- Check interval: %s\n", checkInterval) + fmt.Printf("- Workspace TTL: %s\n", getEnv("WORKSPACE_TTL", strconv.FormatInt(int64(14*24*time.Hour), 10))) + // Run garbage collection loop for { select {