From c79c7a7913c9145faa3751824f71d21813ea58d5 Mon Sep 17 00:00:00 2001 From: TwiN Date: Sun, 8 Dec 2024 16:04:50 -0500 Subject: [PATCH] docs: Improve refreshed-at annotation documentation --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b6828c8..564ea49 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,6 @@ kubectl annotate pod hello-world k8s-ttl-controller.twin.sh/ttl=1h The pod `hello-world` would be deleted in approximately 40 minutes, because 20 minutes have already elapsed, leaving 40 minutes until the target TTL of 1h is reached. -In the same way, you can refresh the TTL by placing the annotation `k8s-ttl-controller.twin.sh/refreshed-at`, like this: -```console -kubectl annotate pod hello-world k8s-ttl-controller.twin.sh/refreshed-at=2024-12-08T20:48:11Z -# Alternatively: -kubectl annotate pod hello-world k8s-ttl-controller.twin.sh/refreshed-at=$(date -u +"%Y-%m-%dT%H:%M:%SZ") -``` - Alternatively, you can create resources with the annotation already present: ```yaml apiVersion: v1 @@ -50,6 +43,16 @@ The above would cause the pod to be deleted 1 hour after its creation. This is especially useful if you want to create temporary resources without having to worry about unnecessary resources accumulating over time. +You can delay a resource from being deleted by using the `k8s-ttl-controller.twin.sh/refreshed-at` annotation, as +the value of said annotation will be used instead of `metadata.creationTimestamp` to calculate the TTL: +```console +kubectl annotate pod hello-world k8s-ttl-controller.twin.sh/refreshed-at=2024-12-08T20:48:11Z +``` +You can use the following to save yourself from timezone shenanigans: +```console +kubectl annotate pod hello-world k8s-ttl-controller.twin.sh/refreshed-at=$(date -u +"%Y-%m-%dT%H:%M:%SZ") +``` + ## Deploying on Kubernetes ### Using Helm @@ -179,4 +182,4 @@ make kind-clean ## Debugging -To enable debugging logs, you may set the `DEBUG` environment variable to `true` \ No newline at end of file +To enable debugging logs, you may set the `DEBUG` environment variable to `true`