feat: native watch mode and multi-config directory support (v3.0.0) - #9
Merged
Merged
Conversation
- -w/--watch: long-running, event-driven re-sync via the Kubernetes watch API. Fetches once on startup, then re-runs the fetch pipeline only when the secret changes. Reconnects with exponential backoff and always re-syncs on reconnection; idle watchers issue no periodic API calls. - -d/--config-dir: load one YAML config per secret in a single process. - --resync: configurable safety-net re-sync interval (default 24h). - K8sClient now surfaces the secret resourceVersion and uses a dedicated no-total-timeout client for long-lived watch streams. - Dockerfile: add socat for HAProxy Runtime API reload commands. - Version 3.0.0, README, CHANGELOG, config example, rpm spec updated. - Tests: watcher event/reactivity, no-reload-on-unchanged, reconnect on stream close, loadConfigs directory ordering.
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.
Summary
Adds a native, event-driven watch mode plus multi-config directory support, so
fetch-k8s-certbecomes the long-running process instead of being wrapped in shell poll loops (e.g.while true; ...; sleep).Changes
-w/--watch: long-running mode thatallowWatchBookmarks+fieldSelector=metadata.name),reloadCommandpipeline on every change,--resync, default 24h, and is a no-op whenever files are unchanged).-d/--config-dir: load one*.yamlconfig per secret and manage them all in one process. Works in both one-shot and watch mode.-fremains fully backwards-compatible.--resync: duration flag (default 24h,0disables).K8sClient:GetTLSBundleWithRVexposes the secretresourceVersionso watches resume from a consistent point.WatchSecretstreams the watch using a dedicatedhttp.Clientwithout the 30s total timeout (shared transport with the ordinary client).watcher.goimplementsSecretWatcher(initial sync, stream decoding, backoff, periodic resync).socatto the alpine image for HAProxy Runtime API reload commands.main.go, Makefile, README, config example, Debian package reference, rpm spec, and CHANGELOG.ADDED/MODIFIEDupdate files + trigger reload), no reload when content unchanged, reconnect-on-stream-close, andloadConfigsdirectory ordering.go vet,gofmt -s,golangci-lint, andgo test -race ./...all pass.Motivation
Replaces external poll loops (60s–24h
sleeppatterns) with an event-driven daemon, enabling zero-downtime certificate updates for services like HAProxy (Runtime APIset ssl cert/commit ssl cert) with no container restarts.Notes for reviewers
listandwatchverbs on secrets (in addition toget) for watch mode;getremains sufficient for one-shot mode.-fone-shot behaves exactly as before.