21_check_tls_certificates.yml - Usage Guide
Purpose
Read-only TLS / certificate inventory (on the first control-plane):
- kubeadm
certs check-expiration(if present) - Control-plane PEM files —
/etc/kubernetes/pki,/var/lib/rancher/k3s/server/tls(openssl expiry + days remaining) - Ingress TLS — for each Ingress: domains, secret, issuer, SAN, expiry date, days remaining, level
- cert-manager
Certificateresources (if the CRD exists) - All
kubernetes.io/tlssecrets — the most critical 25 (by days remaining)
Levels
| Level | Days remaining |
|---|---|
EXPIRED | < 0 |
CRITICAL | ≤ 7 |
WARNING | ≤ 30 |
APPROACHING | ≤ 90 |
OK | > 90 |
Requirements
hosts: master:singlenode—first_control_planeonlybecome: true(PKI directories are usually root)kubectl+openssl+python3KUBECONFIGat play level is~/.kube/config
How to run
ansible-playbook -i inventories/cagatayuresincom/hosts.ini playbooks/21_check_tls_certificates.yml
How to read Ingress output
Each record has:
- domains — Ingress rule / TLS hosts
- secret —
namespace/secretName - issuer / SAN — certificate identity
- REMAINING / EXPIRY / LEVEL — renewal urgency
NO_TLS / SECRET_MISSING / NO_CERT → missing configuration, not expiry.
Notes
- Script:
playbooks/files/k8s_tls_certificates_check.py - Does not change the cluster.