Add update subcommand to kubectl-datadog autoscaling cluster#2961
Draft
Add update subcommand to kubectl-datadog autoscaling cluster#2961
update subcommand to kubectl-datadog autoscaling cluster#2961Conversation
The new 'update' command refreshes a previously-installed kubectl-datadog Karpenter installation on an EKS cluster. It auto-detects immutable parameters (namespace, install-mode, fargate-subnets) from the dd-karpenter CloudFormation stack so the user does not need to repeat install flags, and refuses to act on a Karpenter installed by another tool or coexisting with a foreign one. The install package is refactored to expose Run() and RunOptions so update can delegate to the same idempotent pipeline (CFN, Helm, aws-auth, ConfigMap snapshot). Shared helpers (KarpenterStackName, DDKarpenterStackName, DetectedInstallMode, FindAnyKarpenterInstallation) are extracted and reused by uninstall and update. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🛑 Gate Violations
ℹ️ Info🎯 Code Coverage (details) Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: f1841b7 | Docs | Datadog PR Page | Give us feedback! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2961 +/- ##
==========================================
+ Coverage 41.39% 41.77% +0.37%
==========================================
Files 327 328 +1
Lines 28979 29145 +166
==========================================
+ Hits 11996 12175 +179
+ Misses 16123 16108 -15
- Partials 860 862 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Lift install/update patch coverage above the 80% PR-gate threshold by adding direct unit tests for the helpers that the refactor newly exposed and for the command-construction paths that the existing validate-only tests did not exercise. Adds: - KarpenterStackName, DDKarpenterStackName, DetectedInstallMode decoders (install package) - checkInstallModeTag, checkFargateStackImmutability guards (install package) - displayEKSAutoModeMessage, displaySuccessMessage box renderers (install package) - New (cobra command) flag-registration check + complete() args plumbing in both install and update - newOptions defaults pinning install's --create-karpenter-resources=all vs update's =none divergence
update subcommand to kubectl-datadog autoscaling cluster
…g-cluster-update # Conflicts: # cmd/kubectl-datadog/autoscaling/cluster/install/guess/foreignkarpenter.go
Drop the ForeignKarpenter struct and the FindAnyKarpenterInstallation / FindForeignKarpenterInstallation pair in favour of one FindKarpenterInstallation that returns the first Karpenter controller it finds (assuming at most one per cluster, which our install/update guards enforce). Callers use IsOwn to decide: - install proceeds when no Karpenter is found, or it is ours. - update proceeds only when our Karpenter is found. Update consequently drops its second post-namespace foreign scan, and the RunOptions skip flag is renamed from SkipForeignKarpenterCheck to SkipKarpenterCheck. The file is renamed from foreignkarpenter.go to karpenter.go now that "foreign" is no longer a discriminator.
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 does this PR do?
Adds
kubectl datadog autoscaling cluster update, a new subcommand that refreshes a previously-installed kubectl-datadog Karpenter installation on an EKS cluster, complementing the existinginstallanduninstall.The new command:
dd-karpenter-<cluster>-dd-karpenterCloudFormation stack. The user only needs to pass flags they want to change (e.g.--karpenter-version). Contradictory flags fail with an explanatory error pointing atuninstall.--create-karpenter-resources=none(vsallfor install) so a refresh does not blindly overwrite EC2NodeClass / NodePool resources the user may have hand-edited.Motivation
Today a user can "update" by re-running
installwith exactly the same flags.installis idempotent so this works, but it has two frictions:installthat the user expected an existing installation. Re-running on an empty cluster silently does a fresh install.--karpenter-namespace,--install-mode,--fargate-subnets. Forgetting one either fails the immutability check with a technical error, or silently mutates a parameter.updateaddresses both.Refactor
Preparing for the new command,
installexposes its core as a reusable function:install.Run(ctx, streams, configFlags, clientset, opts)andinstall.RunOptions(withActionLabelandSkipForeignKarpenterCheckknobs forupdate).*cobra.Commandtogenericclioptions.IOStreams.install.KarpenterStackName/DDKarpenterStackName/DetectedInstallModehelpers;uninstallmigrated to use them.guess.KarpenterInstallation(withIsOwn()method) andguess.FindAnyKarpenterInstallationshared scanner, used byupdatefor its installation-presence guard.Describe how you validated your changes
make kubectl-datadogpasses lint (0 issues) and builds.go test ./cmd/kubectl-datadog/autoscaling/...is green, including newupdate_test.gocoveringresolveOptions(auto-detection, contradiction rejection, fargate vs existing-nodes asymmetry),TestFindAnyKarpenterInstallation, andTestKarpenterInstallationIsOwn.TestAutoscalingUpdateadded intest/e2e/tests/autoscaling_suite/: refusal without prior install → install fargate → update with no flags (auto-detect) → idempotency →--create-karpenter-resources=allregeneration → rejection of contradictory--install-mode.Additional Notes
The
dd-cluster-infoConfigMap snapshot is re-recorded at each update (keeps the snapshot fresh, accepting the trade-off that the original install baseline is overwritten).Minimum Agent Versions
N/A — kubectl plugin only.