Add pvc and cert-expiry Kubernetes probes - #36
Merged
Conversation
Two new probes under the existing probe seam: - pvc: healthy iff the PersistentVolumeClaim is Bound. Detail names the phase and the bound capacity when present. This is bind health only; true PVC usage needs kubelet volume stats that kubectl does not expose, so usage thresholds stay future work. - cert-expiry: reads a TLS Secret, base64-decodes data[key] (default tls.crt), parses the X.509 notAfter with cryptography, and reports unhealthy when the cert expires within `days` (default 14) or is already expired. cryptography is imported lazily so the dep stays optional; without it the probe points at the new `certs` extra. Both register in PROBES and __all__, expose object_ref for `get -o yaml`, and validate bad params at construction so the policy loader rejects them. Adds the optional `certs = ["cryptography>=42"]` extra and refreshes the lock. Tests mint short- and long-lived self-signed certs in-process and drive the probes through a scripted provider.
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 characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two new probes on the existing probe seam, plus an optional
certsextra.pvcname: str.kubectl get pvc <name> -o json; healthy iffstatus.phase == "Bound".object_ref -> ["pvc", name].cert-expirysecret: str,days: int = 14,key: str = "tls.crt".kubectl get secret <secret> -o json, base64-decodedata[key], parse the X.509notAfterwithcryptography.daysor is already expired; detail reports days remaining.cryptographyis imported lazily insidecheck()so the dep stays optional. Without it, the probe returns a pointer to thecertsextra instead of crashing.object_ref -> ["secret", secret].Wiring
PROBESand__all__.certs = ["cryptography>=42"]and refresheduv.lock.Tests
tests/test_pvc_probe.py: Bound/Pending/missing-phase/kubectl-failure, object_ref, build-from-spec.tests/test_cert_expiry_probe.py: mints short- and long-lived self-signed certs in-process, asserts unhealthy/healthy, covers expired, missing key, custom key, unparseable cert, negative-days rejection, object_ref, build-from-spec. Guarded withpytest.importorskip("cryptography").All gates pass locally: ruff check, ruff format --check, mypy, pytest (244 passed).