{"slug":"ref-kubernetes-fca046129d725e8b934f","title":"Declarative API Validation — +k8s:isSubresource","summary":"The +k8s:isSubresource tag is a package-level comment that scopes the validation rules within that package to a specific subresource.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nThe +k8s:isSubresource tag is a package-level comment that scopes the validation rules within that package to a specific subresource. It essentially tells the code generator, \"The validation logic defined here is the specific implementation for this subresource and should not be applied to the root object or any other subresource.\"\n\nThis tag is dependent on a corresponding +k8s:supportsSubresource tag being present in the package where the main API type is defined.\n\n+k8s:supportsSubresource opens the door by telling the dispatcher that a subresource is valid. +k8s:isSubresource provides the specialized validation logic that runs when a request comes through that door.\n\nIf you use +k8s:isSubresource without the corresponding +k8s:supportsSubresource declaration on the main type, the specialized validation code will be generated but will be unreachable. The main dispatcher will not recognize the subresource path and will reject the request before it can be routed to your specific validation logic.\n\nThis dependency allows for powerful organization, such as placing your main API types in one package and defining their subresource-specific validations in separate, dedicated packages.\n\nThe path of the subresource to which the validations in this package should apply (e.g., \"/status\", \"/scale\").\n\nThis two-part example demonstrates the intended use case of separating concerns.\n\n1. Declare Support in the Main API Package: First, declare that the Deployment type supports /scale validation in its primary package.\n\nFile: staging/src/k8s.io/api/apps/v1/doc.go\n\nBounded code example (external data; do not execute automatically):\n```go\n// This enables the validation dispatcher to handle requests for \"/scale\".\n// +k8s:supportsSubresource=\"/scale\"\npackage v1\n\n// ... includes the definition for the Deployment type\n```\n\n2. Scope Validation Logic in a Separate Package: Next, create a separate package for the validation rules that are specific only to the /scale subresource.\n\nFile: staging/src/k8s.io/api/apps/v1/validations/scale/doc.go\n\nBounded code example (external data; do not execute automatically): …\n\nAttribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","kubernetes","reference","using-api","declarative","api","validation","k8s","issubresource"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/kubernetes/website/blob/6449f1eced66d36159c06c3cfae1d1aeec40d4a3/content/en/docs/reference/using-api/declarative-validation.md","source_name":"Kubernetes Documentation","source_license":"CC-BY-4.0","source_revision":"6449f1eced66d36159c06c3cfae1d1aeec40d4a3","source_path":"content/en/docs/reference/using-api/declarative-validation.md :: +k8s:isSubresource","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.498505+00:00","url":"https://wikikv.com/k/ref-kubernetes-fca046129d725e8b934f","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-kubernetes-fca046129d725e8b934f","markdown":"https://wikikv.com/k/ref-kubernetes-fca046129d725e8b934f?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-kubernetes-fca046129d725e8b934f","json_ld":"https://wikikv.com/k/ref-kubernetes-fca046129d725e8b934f?format=jsonld"}}