2020-04-24 00:08:38 -04:00
|
|
|
// Module included in the following assemblies:
|
|
|
|
|
//
|
|
|
|
|
// * operators/operator_sdk/osdk-cli-reference.adoc
|
|
|
|
|
|
2019-05-13 08:55:00 +10:00
|
|
|
[id="osdk-cli-reference-generate_{context}"]
|
2018-11-20 09:27:37 -05:00
|
|
|
= generate
|
|
|
|
|
|
|
|
|
|
The `operator-sdk generate` command invokes a specific generator to generate
|
|
|
|
|
code as needed.
|
|
|
|
|
|
2020-06-03 11:04:55 -04:00
|
|
|
[id="osdk-cli-reference-generate-crds_{context}"]
|
|
|
|
|
== crds
|
|
|
|
|
|
|
|
|
|
The `generate crds` subcommand generates CRDs or updates them if they exist, under
|
|
|
|
|
`deploy/crds/__crd.yaml`. OpenAPI V3 validation YAML is generated as a
|
|
|
|
|
`validation` object.
|
|
|
|
|
|
|
|
|
|
.`generate crds` flags
|
|
|
|
|
[options="header",cols="1,3"]
|
|
|
|
|
|===
|
|
|
|
|
|Flag |Description
|
|
|
|
|
|
|
|
|
|
|`--crd-version` (string)
|
|
|
|
|
|CRD version to generate (default `v1beta1`)
|
|
|
|
|
|
|
|
|
|
|`-h`, `--help`
|
|
|
|
|
|Help for `generate crds`
|
|
|
|
|
|===
|
|
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
[source,terminal]
|
2020-06-03 11:04:55 -04:00
|
|
|
----
|
|
|
|
|
$ operator-sdk generate crds
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2020-06-03 11:04:55 -04:00
|
|
|
$ tree deploy/crds
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2020-06-03 11:04:55 -04:00
|
|
|
├── deploy/crds/app.example.com_v1alpha1_appservice_cr.yaml
|
|
|
|
|
└── deploy/crds/app.example.com_appservices_crd.yaml
|
|
|
|
|
----
|
|
|
|
|
|
2020-04-24 00:08:38 -04:00
|
|
|
[id="osdk-cli-reference-generate-csv_{context}"]
|
|
|
|
|
== csv
|
|
|
|
|
|
2020-06-01 12:46:06 -06:00
|
|
|
The `csv` subcommand writes a ClusterServiceVersion (CSV) manifest for use with
|
|
|
|
|
Operator Lifecycle Manager (OLM). It also optionally writes
|
|
|
|
|
CustomResourceDefinition (CRD) files to
|
|
|
|
|
`deploy/olm-catalog/<operator_name>/<csv_version>`.
|
2020-04-24 00:08:38 -04:00
|
|
|
|
|
|
|
|
.`generate csv` flags
|
2018-11-20 09:27:37 -05:00
|
|
|
[options="header",cols="1,3"]
|
|
|
|
|
|===
|
2020-04-24 00:08:38 -04:00
|
|
|
|Flag |Description
|
|
|
|
|
|
|
|
|
|
|`--csv-channel` (string)
|
|
|
|
|
|The channel the CSV should be registered under in the package manifest.
|
|
|
|
|
|
|
|
|
|
|`--csv-config` (string)
|
|
|
|
|
|The path to the CSV configuration file. Default:
|
|
|
|
|
`deploy/olm-catalog/csv-config.yaml`.
|
|
|
|
|
|
|
|
|
|
|`--csv-version` (string)
|
|
|
|
|
|The semantic version of the CSV manifest. Required.
|
|
|
|
|
|
|
|
|
|
|`--default-channel`
|
|
|
|
|
|Use the channel passed to `--csv-channel` as the package manifests' default
|
|
|
|
|
channel. Only valid when `--csv-channel` is set.
|
|
|
|
|
|
|
|
|
|
|`--from-version` (string)
|
|
|
|
|
|The semantic version of CSV manifest to use as a base for a new version.
|
|
|
|
|
|
|
|
|
|
|`--operator-name`
|
|
|
|
|
|The Operator name to use while generating the CSV.
|
|
|
|
|
|
|
|
|
|
|`--update-crds`
|
|
|
|
|
|Updates CRD manifests in `deploy/<operator_name>/<csv_version>` using the
|
|
|
|
|
latest CRD manifests.
|
|
|
|
|
|
|
|
|
|
|===
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
[source,terminal]
|
2020-04-24 00:08:38 -04:00
|
|
|
----
|
|
|
|
|
$ operator-sdk generate csv --csv-version 0.1.0 --update-crds
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2020-04-24 00:08:38 -04:00
|
|
|
INFO[0000] Generating CSV manifest version 0.1.0
|
|
|
|
|
INFO[0000] Fill in the following required fields in file deploy/olm-catalog/operator-name/0.1.0/operator-name.v0.1.0.clusterserviceversion.yaml:
|
|
|
|
|
spec.keywords
|
|
|
|
|
spec.maintainers
|
|
|
|
|
spec.provider
|
|
|
|
|
spec.labels
|
|
|
|
|
INFO[0000] Created deploy/olm-catalog/operator-name/0.1.0/operator-name.v0.1.0.clusterserviceversion.yaml
|
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
[id="osdk-cli-reference-generate-k8s_{context}"]
|
|
|
|
|
== k8s
|
|
|
|
|
|
|
|
|
|
The `k8s` subcommand runs the Kubernetes
|
2018-11-20 09:27:37 -05:00
|
|
|
link:https://github.com/kubernetes/code-generator[code-generators] for all CRD
|
|
|
|
|
APIs under `pkg/apis/`. Currently, `k8s` only runs `deepcopy-gen` to generate
|
2019-02-14 11:31:01 -05:00
|
|
|
the required `DeepCopy()` functions for all Custom Resource (CR) types.
|
2018-11-20 09:27:37 -05:00
|
|
|
|
|
|
|
|
[NOTE]
|
|
|
|
|
====
|
|
|
|
|
This command must be run every time the API (`spec` and `status`) for a custom
|
|
|
|
|
resource type is updated.
|
|
|
|
|
====
|
|
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
[source,terminal]
|
2018-11-20 09:27:37 -05:00
|
|
|
----
|
|
|
|
|
$ tree pkg/apis/app/v1alpha1/
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
pkg/apis/app/v1alpha1/
|
|
|
|
|
├── appservice_types.go
|
|
|
|
|
├── doc.go
|
2020-07-31 16:19:58 -06:00
|
|
|
└── register.go
|
|
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
$ operator-sdk generate k8s
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2019-02-14 11:31:01 -05:00
|
|
|
Running code-generation for Custom Resource (CR) group versions: [app:v1alpha1]
|
2018-11-20 09:27:37 -05:00
|
|
|
Generating deepcopy funcs
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
|
2020-07-31 16:19:58 -06:00
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
$ tree pkg/apis/app/v1alpha1/
|
2020-07-31 16:19:58 -06:00
|
|
|
----
|
|
|
|
|
|
|
|
|
|
.Example output
|
|
|
|
|
[source,terminal]
|
|
|
|
|
----
|
2018-11-20 09:27:37 -05:00
|
|
|
pkg/apis/app/v1alpha1/
|
|
|
|
|
├── appservice_types.go
|
|
|
|
|
├── doc.go
|
|
|
|
|
├── register.go
|
|
|
|
|
└── zz_generated.deepcopy.go
|
|
|
|
|
----
|