Annotating Kubernetes resource with expiry time Annotating Kubernetes resource with expiry time kubernetes kubernetes

Annotating Kubernetes resource with expiry time


If you are using *nix shell like bash you can use the date command 🔧 and the kubectl patch command 🧰.

kubectl patch <k8s-resource> <resource-name> -p \ "{\"metadata\":{\"annotations\":{\"expiry-time\":\"`date -d '1 hour' '+%m-%d-%Y-%H:%M:%S'`\"}}}"

If you are on Mac you can substitute the date command with this:

date -v+1d '+%m/%d/%Y -%H:%M:%S'

✌️☮️


This worked..

 kubectl annotate rbacdefinition  joe-access "expires-at=$(date -v+1H  '+%m%d/%Y -%H:%M:%S')"