Skip to content

Commit

Permalink
docs: Improve refreshed-at annotation documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
TwiN authored Dec 8, 2024
1 parent 1b7a4af commit c79c7a7
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`
To enable debugging logs, you may set the `DEBUG` environment variable to `true`

0 comments on commit c79c7a7

Please sign in to comment.