[tools] Add d8 tools pki certs renew for control-plane certificates#368
[tools] Add d8 tools pki certs renew for control-plane certificates#368trofimovdals wants to merge 10 commits into
Conversation
Signed-off-by: dmitry.trofimov <dmitry.trofimov@flant.com>
Signed-off-by: dmitry.trofimov <dmitry.trofimov@flant.com>
There was a problem hiding this comment.
Pull request overview
Adds a d8 tools pki certs renew command tree to the deckhouse-cli, mirroring kubeadm certs renew. The command re-signs control-plane leaf certificates and kubeconfig client certificates locally using the upgraded go_lib/controlplane renewal API (bumped in go.mod/go.sum), reading certificate parameters from the existing files on disk and using the on-disk CA key. It supports renew all (with optional --san for adding an IP SAN to serving certs, plus --dry-run) and renew PATH for renewing a single file (auto-detecting kubeconfig vs PEM cert). Also refactors the existing certs check builder to use the renewal API's new per-entry error model in place of the old IgnoreReadErrors/joined-error scheme.
Changes:
- New
renewcommand (cmd/renew.go) and renewal logic (renew.go) with per-artifact outcome handling (missing/external/expired CA), CA-outlives-renewed warnings, and dry-run support. - Refactor of
certs.go(BuildFullScanReport/BuildSingleFileReport) to consume the newpki/kubeconfigtyped-entry reports and centralize entry building viaappendPKIEntry/appendKubeconfigEntry. - Bump of
go_lib/controlplanedependency to a version exposing the renewal API.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/tools/pki/certs/renew.go | New renewal orchestration: full-tree and single-file renewal, error formatting per entry type, dry-run banner/footer, CA-outlives-renewed warning check. |
| internal/tools/pki/certs/cmd/renew.go | New cobra renew and renew all subcommand wiring with --path, --kubeconfig-dir, --dry-run, --san flags. |
| internal/tools/pki/certs/cmd/certs.go | Registers the new renew subcommand under certs. |
| internal/tools/pki/certs/certs.go | Refactors report builders to use the new per-entry typed errors from pki/kubeconfig packages; drops old onlyNotExistErrors/multiUnwrapper helpers. |
| go.mod / go.sum | Bumps deckhouse/go_lib/controlplane to the version with the renewal API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Add d8 tools pki certs renew to deckhouse-cli to re-sign expired or soon-to-expire control-plane certificates locally using the go_lib/controlplane renewal API from the companion PR deckhouse/deckhouse#20129.
renew allre-signs every known control-plane leaf certificate and kubeconfig client certificate; renew PATH re-signs a single file, auto-detecting whether it is a PEM certificate or a kubeconfig--dry-runruns all checks and signing in memory without writing any files--san(on renew all) adds a new IP SAN to serving certificates that already carry IP SANs (apiserver, etcd/server, etcd/peer) - supports the master-node-IP-change recovery flow without downloading kubeadm or reconstructing cluster config--pathand--kubeconfig-dirfor non-standard layouts;--kubeconfig-dirdefaults to the parent of--pathExamples
d8 tools pki certs renew all
d8 tools pki certs renew all --san 192.168.0.123
d8 tools pki certs renew all --dry-run with missing ca
d8 tools pki certs renew apiserver.crt from non default dir