1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 21:46:22 +01:00
Files
openshift-docs/modules/osdk-cli-reference-add.adoc
2019-07-18 13:26:33 +00:00

93 lines
2.9 KiB
Plaintext

[id="osdk-cli-reference-add_{context}"]
= add
The `operator-sdk add` command adds a controller or resource to the project. The
command must be run from the Operator project root directory.
.`add` subcommands
[options="header",cols="1,3"]
|===
|Subcommand |Description
|`api`
|Adds a new API definition for a new Custom Resource (CR) under `pkg/apis` and
generates the Customer Resource Definition (CRD) and Custom Resource (CR) files
under `deploy/crds/`. If the API already exists at `pkg/apis/<group>/<version>`,
then the command does not overwrite and returns an error.
|`controller`
|Adds a new controller under `pkg/controller/<kind>/`. The controller expects to
use the CR type that should already be defined under
`pkg/apis/<group>/<version>` via the `operator-sdk add api --kind=<kind>
--api-version=<group/version>` command. If the controller package for that
`Kind` already exists at `pkg/controller/<kind>`, then the command does not
overwrite and returns an error.
|`crd`
a|Adds a CRD and the CR files. The `<project-name>/deploy` path must already
exist. The `--api-version` and `--kind` flags are required to generate the new
Operator application.
* Generated CRD filename: `<project-name>/deploy/crds/<group>_<version>_<kind>_crd.yaml`
* Generated CR filename: `<project-name>/deploy/crds/<group>_<version>_<kind>_cr.yaml`
|===
.`add api` flags
[options="header",cols="1,3"]
|===
|Flag |Description
|`--api-version` (string)
|CRD `APIVersion` in the format `$GROUP_NAME/$VERSION` (e.g.,
`app.example.com/v1alpha1`).
|`--kind` (string)
|CRD `Kind` (e.g., `AppService`).
|===
.Example `add api` output
----
$ operator-sdk add api --api-version app.example.com/v1alpha1 --kind AppService
Create pkg/apis/app/v1alpha1/appservice_types.go
Create pkg/apis/addtoscheme_app_v1alpha1.go
Create pkg/apis/app/v1alpha1/register.go
Create pkg/apis/app/v1alpha1/doc.go
Create deploy/crds/app_v1alpha1_appservice_cr.yaml
Create deploy/crds/app_v1alpha1_appservice_crd.yaml
Running code-generation for Custom Resource (CR) group versions: [app:v1alpha1]
Generating deepcopy funcs
$ tree pkg/apis
pkg/apis/
├── addtoscheme_app_appservice.go
├── apis.go
└── app
└── v1alpha1
├── doc.go
├── register.go
├── types.go
----
.Example `add controller` output
----
$ operator-sdk add controller --api-version app.example.com/v1alpha1 --kind AppService
Create pkg/controller/appservice/appservice_controller.go
Create pkg/controller/add_appservice.go
$ tree pkg/controller
pkg/controller/
├── add_appservice.go
├── appservice
│   └── appservice_controller.go
└── controller.go
----
.Example `add crd` output
----
$ operator-sdk add crd --api-version app.example.com/v1alpha1 --kind AppService
Generating Custom Resource Definition (CRD) files
Create deploy/crds/app_v1alpha1_appservice_crd.yaml
Create deploy/crds/app_v1alpha1_appservice_cr.yaml
----