OS Manuals

/usr/bin/controller-gen

Tools to use with the controller-runtime libraries

From controller-gen 0.23.0-r1 (os), captured 2026-11-05 by running controller-gen --help (exit 0). permalink

Generate Kubernetes API extension resources and code.

Usage:
  controller-gen [flags]

Examples:
	# Generate RBAC manifests and crds for all types under apis/,
	# outputting crds to /tmp/crds and everything else to stdout
	controller-gen rbac:roleName=<role name> crd paths=./apis/... output:crd:dir=/tmp/crds output:stdout

	# Generate deepcopy/runtime.Object implementations for a particular file
	controller-gen object paths=./apis/v1beta1/some_types.go

	# Generate OpenAPI v3 schemas for API packages and merge them into existing CRD manifests
	controller-gen schemapatch:manifests=./manifests output:dir=./manifests paths=./pkg/apis/...

	# Run all the generators for a given project
	controller-gen paths=./apis/...

	# Explain the markers for generating CRDs, and their arguments
	controller-gen crd -ww

	# Generate applyconfigurations for CRDs for use with Server Side Apply. They will be placed
	# into a "applyconfiguration/" subdirectory

	controller-gen applyconfiguration paths=./apis/...


Flags:
  -h, --detailed-help count       print out more detailed help
                                  (up to -hhh for the most detailed output, or -hhhh for json output)
      --help                      print out usage and a summary of options
      --load-build-tags strings   build tags to use when loading Go packages (default [ignore_autogenerated])
      --version                   show version
  -w, --which-markers count       print out all markers available with the requested generators
                                  (up to -www for the most detailed output, or -wwww for json output)


Options


generators

+applyconfiguration[:externalApplyConfigurations=<[]string>][,headerFile=<string>][,omitToolVersion=<bool>]                                                                                                                                                                    package  generates code containing apply configuration type implementations.
+crd[:allowDangerousTypes=<bool>][,crdVersions=<[]string>][,deprecatedV1beta1CompatibilityPreserveUnknownFields=<bool>][,generateEmbeddedObjectMeta=<bool>][,headerFile=<string>][,ignoreUnexportedFields=<bool>][,maxDescLen=<int>][,omitToolVersion=<bool>][,year=<string>]  package  generates CustomResourceDefinition objects.
+object[:headerFile=<string>][,year=<string>]                                                                                                                                                                                                                                  package  generates code containing DeepCopy, DeepCopyInto, and
+rbac[:fileName=<string>][,headerFile=<string>],roleName=<string>[,year=<string>]                                                                                                                                                                                              package  generates ClusterRole objects.
+schemapatch[:generateEmbeddedObjectMeta=<bool>],manifests=<string>[,maxDescLen=<int>]                                                                                                                                                                                         package  patches existing CRDs with new schemata.
+webhook[:headerFile=<string>][,year=<string>]                                                                                                                                                                                                                                 package  generates (partial) {Mutating,Validating}WebhookConfiguration objects.


generic

+paths=<[]string>  package  represents the package roots that controller-gen uses as input


output rules (optionally as output:<generator>:...)

+output:stdout                                     package  outputs everything to standard-out, with no separation.
+output:none                                       package  skips outputting anything.
+output:dir=<string>                               package  outputs each artifact to the given directory, regardless
+output:artifacts[:code=<string>],config=<string>  package  outputs artifacts to different locations, depending on
Options (5)
OptionDescriptionSource
-h, --detailed-help countprint out more detailed help (up to -hhh for the most detailed output, or -hhhh for json output)help
--helpprint out usage and a summary of optionshelp
--load-build-tags stringsbuild tags to use when loading Go packages (default [ignore_autogenerated])help
--versionshow versionhelp
-w, --which-markers countprint out all markers available with the requested generators (up to -www for the most detailed output, or -wwww for json output)help

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.