@@ -90,100 +90,125 @@ operator-sdk completion bash
90
90
91
91
## generate
92
92
93
- ### Available Commands
94
-
95
- #### k8s - Generates Kubernetes code for custom resource
93
+ ### k8s
96
94
97
- ##### Use
95
+ Runs the Kubernetes [ code-generators] [ k8s-code-generator ] for all Custom Resource Definitions (CRD) apis under ` pkg/apis/... ` .
96
+ Currently only runs ` deepcopy-gen ` to generate the required ` DeepCopy() ` functions for all custom resource types.
98
97
99
- k8s generator generates code for custom resource given the API spec
100
- to comply with kube-API requirements.
98
+ ** Note** : This command must be run every time the api (spec and status) for a custom resource type is updated.
101
99
102
- ##### Flags
103
-
104
- * ` -h, --help ` - help for k8s
105
-
106
- ##### Example
100
+ #### Example
107
101
108
102
``` bash
109
- operator-sdk generate k8s
110
-
111
- # Output:
112
- Run code-generation for custom resources
103
+ $ tree pkg/apis/app/v1alpha1/
104
+ pkg/apis/app/v1alpha1/
105
+ ├── appservice_types.go
106
+ ├── doc.go
107
+ ├── register.go
108
+
109
+ $ operator-sdk generate k8s
110
+ Running code-generation for custom resource group versions: [app:v1alpha1]
113
111
Generating deepcopy funcs
112
+
113
+ $ tree pkg/apis/app/v1alpha1/
114
+ pkg/apis/app/v1alpha1/
115
+ ├── appservice_types.go
116
+ ├── doc.go
117
+ ├── register.go
118
+ └── zz_generated.deepcopy.go
114
119
```
115
120
116
- #### crd - Generates a custom resource definition (CRD) and the custom resource (CR) files
121
+ ## new
117
122
118
- ##### Use
123
+ Scaffolds a new operator project.
119
124
120
- crd generator generates custom resource definition and custom resource
121
- files for the specified api-version and kind.
125
+ ### Args
122
126
123
- ##### Flags
127
+ * ` project-name ` - name of the new project
124
128
125
- * ` --api-version ` ** (required)** string - Kubernetes apiVersion and has a format of $GROUP_NAME/$VERSION (e.g app.example.com/v1alpha1)
126
- * ` -h, --help ` - help for k8s
127
- * ` --kind ` ** (required)** string - Kubernetes CustomResourceDefinition kind. (e.g AppService)
129
+ ### Flags
128
130
129
- ##### Example
130
131
132
+ * ` --skip-git-init ` Do not init the directory as a git repository
133
+ * ` --type ` Type of operator to initialize: "ansible" or "go" (default "go"). Also requires the following flags if ` --type=ansible `
134
+ * ` --api-version ` CRD APIVersion in the format ` $GROUP_NAME/$VERSION ` (e.g app.example.com/v1alpha1)
135
+ * ` --kind ` CRD Kind. (e.g AppService)
136
+ * ` -h, --help ` - help for new
137
+
138
+ ### Example
139
+
140
+ Go project:
131
141
``` bash
132
- operator-sdk generate crd --api-version app.example.com/v1alpha1 --kind AppService
142
+ mkdir $GOPATH /src/github.com/example.com/
143
+ cd $GOPATH /src/github.com/example.com/
144
+ operator-sdk new app-operator
145
+ ```
133
146
134
- # Output:
135
- Generating custom resource definition (CRD) file
136
- Create < path_to_project> /deploy/appservice_cr.yaml
137
- Create < path_to_project> /deploy/appservice_crd.yaml
147
+ Ansible project:
148
+ ``` bash
149
+ operator-sdk new app-operator --type=ansible --api-version=app.example.com/v1alpha1 --kind=AppService
138
150
```
139
- #### olm-catalog - Generates OLM Catalog manifests
140
151
141
- ##### Flags
152
+ ## add
142
153
143
- * ` --image ` ** (required)** string - The container image name to set in the CSV to deploy the operator e.g: quay.io/example/operator: v0 .0.1
144
- * ` --version ` ** (required)** string - The version of the current CSV e.g: 0.0.1
145
- * ` -h, --help ` - help for olm-catalog
154
+ ### api
146
155
147
- ##### Example
156
+ Adds the
157
+ api definition for a new custom resource under ` pkg/apis ` and generates the CRD and CR files under ` depoy/crds/... ` .
148
158
149
- ``` bash
150
- operator-sdk generate olm-catalog --image=quay.io/example/operator:v0.0.1 --version=0.0.1
159
+ #### Flags
151
160
152
- # Output:
153
- Generating OLM catalog manifests
161
+ * ` --api-version ` CRD APIVersion in the format ` $GROUP_NAME/$VERSION ` (e.g app.example.com/v1alpha1)
162
+ * ` --kind ` CRD Kind. (e.g AppService)
163
+
164
+ #### Example
165
+
166
+ ``` bash
167
+ $ operator-sdk add api --api-version app.example.com/v1alpha1 --kind AppService
168
+ Create pkg/apis/app/v1alpha1/appservice_types.go
169
+ Create pkg/apis/addtoscheme_app_v1alpha1.go
170
+ Create pkg/apis/app/v1alpha1/register.go
171
+ Create pkg/apis/app/v1alpha1/doc.go
172
+ Create deploy/crds/app_v1alpha1_appservice_cr.yaml
173
+ Create deploy/crds/app_v1alpha1_appservice_crd.yaml
174
+ Running code-generation for custom resource group versions: [app:v1alpha1]
175
+ Generating deepcopy funcs
154
176
```
155
177
156
- ### Flags
178
+ ### controller
157
179
158
- * ` -h, --help ` - help for generate
180
+ Adds a new
181
+ controller under ` pkg/controller/<kind>/... ` that, by default, reconciles a custom resource for the specified apiversion and kind.
159
182
160
- ## new
183
+ #### Flags
161
184
162
- The operator-sdk new command creates a new operator application and
163
- generates a default directory layout based on the input ` project-name ` .
185
+ * ` --api-version ` CRD APIVersion in the format ` $GROUP_NAME/$VERSION ` (e.g app.example.com/v1alpha1)
186
+ * ` --kind ` CRD Kind. (e.g AppService)
164
187
165
- ### Args
188
+ #### Example
166
189
167
- * ` project-name ` - the project name of the new
190
+ ``` bash
191
+ $ operator-sdk add controller --api-version app.example.com/v1alpha1 --kind AppService
192
+ Create pkg/controller/appservice/appservice_controller.go
193
+ Create pkg/controller/add_appservice.go
194
+ ```
168
195
169
- ### Flags
196
+ ### crd
170
197
171
- * ` --api-version ` ** (required)** string - Kubernetes apiVersion and has a format of ` $GROUP_NAME/$VERSION ` (e.g app.example.com/v1alpha1)
172
- * ` --kind ` ** (required)** string - Kubernetes CustomResourceDefintion kind. (e.g AppService)
173
- * ` --skip-git-init ` Do not init the directory as a git repository
174
- * ` --type ` Type of operator to initialize (e.g "ansible") (default "go")
175
- * ` -h, --help ` - help for new
198
+ Generates the CRD and the CR files for the specified api-version and kind.
176
199
177
- ### Example
200
+ #### Flags
178
201
179
- ``` bash
180
- mkdir $GOPATH /src/github.com/example.com/
181
- cd $GOPATH /src/github.com/example.com/
182
- operator-sdk new app-operator --api-version=app.example.com/v1alpha1 --kind=AppService
202
+ * ` --api-version ` CRD APIVersion in the format ` $GROUP_NAME/$VERSION ` (e.g app.example.com/v1alpha1)
203
+ * ` --kind ` CRD Kind. (e.g AppService)
183
204
184
- # Output:
185
- Create app-operator/.gitignore
186
- ...
205
+ #### Example
206
+
207
+ ``` bash
208
+ $ operator-sdk add crd --api-version app.example.com/v1alpha1 --kind AppService
209
+ Generating custom resource definition (CRD) files
210
+ Create deploy/crds/app_v1alpha1_appservice_crd.yaml
211
+ Create deploy/crds/app_v1alpha1_appservice_cr.yaml
187
212
```
188
213
189
214
## test
@@ -293,3 +318,4 @@ operator-sdk up local --namespace "testing"
293
318
* ` -h, --help ` - help for up
294
319
295
320
[ utility_link ] : https://github.com/operator-framework/operator-sdk/blob/89bf021063d18b6769bdc551ed08fc37027939d5/pkg/util/k8sutil/k8sutil.go#L140
321
+ [ k8s-code-generator ] : https://github.com/kubernetes/code-generator
0 commit comments