Created
June 20, 2019 14:49
-
-
Save ryran/f0a0da3df85df228068de2b06e3d78a5 to your computer and use it in GitHub Desktop.
Revisions
-
ryran created this gist
Jun 20, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/bin/bash tmp=$(mktemp -d) trap "cd - >/dev/null; rm -rf $tmp" EXIT cd $tmp echo >&2 echo "Checking expiration dates for all certs in all namespaces ..." >&2 echo "(Pipe to 'sort' to see soonest-to-expire at the top)" >&2 echo >&2 for ns in $(oc get ns --no-headers | awk '{print $1}'); do for secret in $(oc get secrets -n $ns | awk 'BEGIN{IGNORECASE=1}; $2~/tls/ {print $1}'); do oc -n $ns extract secret/$secret --confirm --keys tls.crt >/dev/null || continue [[ -f tls.crt ]] || continue enddate=$(openssl x509 -noout -enddate -in tls.crt | cut -d= -f2) echo -e "$(date --date="$enddate" +"%F %R %Z")\t$ns / $secret" done done