feat(appsec): migrate injector config to spec.features.appsec.injector and add GKE Gateway support - #3337
Open
eliottness wants to merge 18 commits into
Open
feat(appsec): migrate injector config to spec.features.appsec.injector and add GKE Gateway support#3337eliottness wants to merge 18 commits into
eliottness wants to merge 18 commits into
Conversation
… version constants
…nce over annotations
…og annotation deprecation
…gke.gatewayClasses
… classes env const
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
🎯 Code Coverage (details) 🔗 Commit SHA: a0667fa | Docs | Datadog PR Page | Give us feedback! |
…tag default, set removal to v1.32
…ent CRD/annotation precedence
jeff-morgan-dd
approved these changes
Aug 10, 2026
RomainMuller
approved these changes
Aug 11, 2026
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?
We are about to mark appsec injector GA
Migrates AppSec proxy injector configuration from
agent.datadoghq.com/appsec.*annotations to a first-class CRD surface atspec.features.appsec.injector.*, and adds GKE Gateway support.datadog.appsec.injector.*layout 1:1, plus a net-newinjector.gke.gatewayClasses.gke-gatewayproxy value,gatewayClasses→DD_APPSEC_PROXY_GKE_GATEWAY_CLASSES,mode: externalrequired whengke-gatewayis explicitly listed inproxies, and a cluster-agent >= 7.82.0 gate.networking.gke.io/gcptrafficextensions(get/create/delete) andeventsgainspatch, granted to both the operator's own ClusterRole and the cluster-agent's.V(0)log on every reconcile when anyappsec.*annotation is present, plus adocs/deprecated_configs.mdentry mapping all 18 annotations to their CRD paths.Motivation
The
appsec.*annotations were a stop-gap. Moving to the CRD gives users schema validation, discoverability in the generated docs, and parity with how every other feature is configured. The GKE Gateway work also needed a configuration surface that annotations could not express cleanly (gatewayClassesis a list and is CRD-only by design).Additional Notes
spec.features.appsecblock present, behavior is unchanged.TestFromAnnotationsstill passes with its original cases and expectations untouched — only its call site moved from the removedFromAnnotationsshim toparseAnnotations(x, nil)+Validate().len > 0for slices. An empty CRD list therefore does not clear an annotation-set value. This asymmetry is intentional and documented on theproxiesfield.zz_generated.deepcopy.goshows ~44 deletions that are purely an import-alias reassignment (core/v1corev1→v1, meta/v1v1→metav1), triggered by the newcorev1.ResourceRequirementsfield landing earlier in declaration order. Verified equivalent by an alias-normalized diff: exactly 2 lines removed, both old import statements, zero semantic code lost.appsec:appears in thedatadogagentprofilesCRD schema becauseDatadogFeaturesis embedded by three CRDs. AppSec is not profile-overridable — that guardrail is the runtimedatadogAgentProfileFeatureAllowlist, which is unchanged and still rejects it.managed-byownership guard, and theappsec.datadoghq.com/enabled=falseopt-out) are authored as leaf Go doc-comments and flow intodocs/configuration.v2alpha1.md.ManageDependencies, so stale-dependency cleanup can remove the AppSec ClusterRole before the cluster-agent finishes its GCPTrafficExtension teardown. This affects all 7 features that use the same disabled-path convention and wants an operator-wide draining state.Minimum Agent Versions
Note: the default cluster-agent image is currently 7.81.1, so GKE Gateway injection is gated off by default until the image is pinned to >= 7.82.0.
Describe your test plan
go test ./...→ 106 ok / 0 FAIL.make lint→ 0 issues.make generate manifestsis idempotent (emptygit status --porcelainafterwards).New coverage in
internal/controller/datadogagent/feature/appsec/:config_test.go— 19 per-field CRD-wins rows (one per destinationConfigfield); annotation fallback; nil injector and every nested-nil combination; empty-slice-does-not-clear; partialresources;claimsdropped; deterministic first-error ordering; and each of the 4 parse-skip predicates paired with a skip-mirror case proving the skip is not over-broad.feature_test.go— CRD-only enable; CRD-over-annotation precedence asserted on the emitted env var rather than just internal state; annotation-only regression; deprecation-log firing (including when disabled); and a GKE version-gate matched pair (7.81.0 → not configured, 7.82.0 → configured) built from one shared fixture so the legs differ only in the image tag. The negative leg additionally assertsisEnabled(),Validate() == nil, andrequiresGKESupport()so it cannot pass for the wrong reason.rbac_test.go— events verbs are exactlycreate+patch; the GKE rule is exactlyget/create/delete.Manual QA: there is no cluster or HTTP surface at this layer — the real user surface is a DatadogAgent goes in, and cluster-agent env vars +
RequiredComponents+ a ClusterRole rule set come out. Real DatadogAgents were driven throughfeature.BuildFeatures(the production entry point) for CRD-only, precedence, both malformed-annotation classes, the version-gate pair, andgetRBACPolicyRules(), capturing observed values rather than pass/fail.Checklist
enhancementqa/skip-qalabelcommit.gpgsign=trueis set locally butuser.signingkeyis unset withgpg.format=ssh, so signing silently no-op'd across all 15 commits. To be re-signed before this leaves draft.