[id="osdk-cli-reference-generate_{context}"]
= generate

The `operator-sdk generate` command invokes a specific generator to generate
code as needed.

.`generate` subcommands
[options="header",cols="1,3"]
|===
|Subcommand |Description

|`k8s`
|Runs the Kubernetes
link:https://github.com/kubernetes/code-generator[code-generators] for all CRD
APIs under `pkg/apis/`. Currently, `k8s` only runs `deepcopy-gen` to generate
the required `DeepCopy()` functions for all Custom Resource (CR) types.
|===

[NOTE]
====
This command must be run every time the API (`spec` and `status`) for a custom
resource type is updated.
====

.Example output
----
$ tree pkg/apis/app/v1alpha1/
pkg/apis/app/v1alpha1/
├── appservice_types.go
├── doc.go
├── register.go

$ operator-sdk generate k8s
Running code-generation for Custom Resource (CR) group versions: [app:v1alpha1]
Generating deepcopy funcs

$ tree pkg/apis/app/v1alpha1/
pkg/apis/app/v1alpha1/
├── appservice_types.go
├── doc.go
├── register.go
└── zz_generated.deepcopy.go
----
