Skip to content

Commit aaa2475

Browse files
committed
doc updates
1 parent a01de38 commit aaa2475

File tree

5 files changed

+125
-44
lines changed

5 files changed

+125
-44
lines changed

cmd/operator-sdk/generate/csv.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ CSV input flags:
178178
`Project relative path to root directory for for CRD manifests`)
179179

180180
cmd.Flags().StringVar(&c.outputDir, "output-dir", scaffold.DeployDir,
181-
"Base directory to output generated CSV. The resulting CSV bundle directory"+
182-
"will be \"<output-dir>/olm-catalog/<operator-name>/<csv-version>\"")
181+
"Base directory to output generated CSV. The resulting CSV bundle directory "+
182+
"will be \"<output-dir>/olm-catalog/<operator-name>/<csv-version>\".")
183183
cmd.Flags().BoolVar(&c.updateCRDs, "update-crds", false,
184184
"Update CRD manifests in deploy/{operator-name}/{csv-version} the using latest API's")
185185
cmd.Flags().StringVar(&c.operatorName, "operator-name", "",

doc/cli/operator-sdk_generate_csv.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ operator-sdk generate csv [flags]
113113
--from-version string Semantic version of an existing CSV to use as a base
114114
-h, --help help for csv
115115
--operator-name string Operator name to use while generating CSV
116-
--output-dir string Base directory to output generated CSV. The resulting CSV bundle directorywill be "<output-dir>/olm-catalog/<operator-name>/<csv-version>" (default "deploy")
116+
--output-dir string Base directory to output generated CSV. The resulting CSV bundle directory will be "<output-dir>/olm-catalog/<operator-name>/<csv-version>". (default "deploy")
117117
--update-crds Update CRD manifests in deploy/{operator-name}/{csv-version} the using latest API's
118118
```
119119

doc/user/olm-catalog/generating-a-csv.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ This document describes how to manage the following lifecycle for your Operator
1010

1111
## Configuration
1212

13-
Operator SDK projects have an expected [project layout][doc-project-layout]. In particular, a few manifests are expected to be present in the `deploy` directory:
13+
### Inputs
1414

15-
* Roles: `role.yaml`
16-
* ClusterRoles: `cluster_role.yaml`
17-
* Deployments: `operator.yaml`
18-
* Custom Resources (CR's): `crds/<full group>_<version>_<kind>_cr.yaml`
19-
* CustomResourceDefinitions (CRD's): `crds/<full group>_<resource>_crd.yaml`.
15+
The CSV generator requires certain inputs to construct a CSV manifest.
2016

21-
`generate csv` extracts manifests from files in `deploy/` by default that match the kinds above and adds them to the CSV. If your manifest files are not in `deploy/`, you can use the `--include=[list of paths]` option to instruct the command to extract manifests from files at those paths, ex. `--include="deploy/prod,deploy/test"`. Setting `--include` overrides default behavior; if you still want default behavior, you must append `deploy/` to the list of paths passed to `--include`.
17+
1. Path to the operator manifests root directory. By default `generate csv` extracts manifests from files in `deploy/` for the following kinds and adds them to the CSV. Use the `--deploy-dir` flag to change this path.
18+
* Roles: `role.yaml`
19+
* ClusterRoles: `cluster_role.yaml`
20+
* Deployments: `operator.yaml`
21+
* Custom Resources (CR's): `crds/<full group>_<version>_<kind>_cr.yaml`
22+
* CustomResourceDefinitions (CRD's): `crds/<full group>_<resource>_crd.yaml`
23+
2. Path to API types root directory. The CSV generator also parses the [CSV annotations][csv-annotations] from the API type definitions to populate certain CSV fields. By default the API types directory is `pkg/apis/`. Use the `--apis-dir` flag to change this path. The CSV generator expects either of the following layouyts for the API types directory
24+
* Mulitple groups: `<API-root-dir>/<group>/<version>/`
25+
* Single groups: `<API-root-dir>/<version>/`
26+
27+
### Output
28+
29+
By default `generate csv` will generate the catalog bundle directory `olm-catalog/...` under `deploy/`. To change where the CSV bundle directory is generated use the `--ouput-dir` flag.
2230

2331
## Versioning
2432

@@ -66,7 +74,7 @@ Be sure to include the `--update-crds` flag if you want to add CRD's to your bun
6674

6775
Below are two lists of fields: the first is a list of all fields the SDK and OLM expect in a CSV, and the second are optional.
6876

69-
Several fields require user input (labeled _user_) or a [code annotation][code-annotations] (labeled _annotation_). This list may change as the SDK becomes better at generating CSV's.
77+
Several fields require user input (labeled _user_) or a [CSV annotation][csv-annotations] (labeled _annotation_). This list may change as the SDK becomes better at generating CSV's.
7078

7179
Required:
7280

@@ -110,10 +118,9 @@ Optional:
110118
[doc-csv]:https://github.com/operator-framework/operator-lifecycle-manager/blob/4197455/Documentation/design/building-your-csv.md
111119
[olm]:https://github.com/operator-framework/operator-lifecycle-manager
112120
[generate-csv-cli]:../../cli/operator-sdk_generate_csv.md
113-
[doc-project-layout]:../../project_layout.md
114121
[doc-csv-design]:../../design/milestone-0.2.0/csv-generation.md
115122
[doc-bundle]:https://github.com/operator-framework/operator-registry/blob/6893d19/README.md#manifest-format
116123
[x-desc-list]:https://github.com/openshift/console/blob/70bccfe/frontend/public/components/operator-lifecycle-manager/descriptors/types.ts#L3-L35
117124
[install-modes]:https://github.com/operator-framework/operator-lifecycle-manager/blob/4197455/Documentation/design/building-your-csv.md#operator-metadata
118125
[olm-capabilities]:../../images/operator-capability-level.png
119-
[code-annotations]:../../proposals/sdk-code-annotations.md
126+
[csv-annotations]: ./csv-annotations.md

website/content/en/docs/cli/operator-sdk_generate_csv.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,109 @@ A CSV semantic version is supplied via the --csv-version flag. If your operator
1111
has already generated a CSV manifest you want to use as a base, supply its
1212
version to --from-version. Otherwise the SDK will scaffold a new CSV manifest.
1313

14-
Configure CSV generation by writing a config file 'deploy/olm-catalog/csv-config.yaml
14+
CSV input flags:
15+
--deploy-dir: The CSV file contents will be generated from the operator manifests
16+
present in this directory.
17+
18+
--apis-dir: The CSV annotation comments will be parsed from the Go types under this path to
19+
fill out metadata for owned APIs in spec.customresourcedefinitions.owned.
20+
21+
--crd-dir: The CRD manifests are updated from this path to the CSV bundle directory.
22+
Note: The CSV generator only uses this to copy the CRD manifests.
23+
The CSV contents for spec.customresourcedefinitions.owned will still be generated
24+
from the CRD manifests in the deploy directory specified by --deploy-dir.
25+
If unset, it defaults to the same value as --deploy-dir.
26+
27+
1528

1629
```
1730
operator-sdk generate csv [flags]
1831
```
1932

33+
### Examples
34+
35+
```
36+
37+
##### Generate CSV from default input paths #####
38+
$ tree pkg/apis/ deploy/
39+
pkg/apis/
40+
├── ...
41+
└── cache
42+
├── group.go
43+
└── v1alpha1
44+
├── ...
45+
└── memcached_types.go
46+
deploy/
47+
├── crds
48+
│   ├── cache.example.com_memcacheds_crd.yaml
49+
│   └── cache.example.com_v1alpha1_memcached_cr.yaml
50+
├── operator.yaml
51+
├── role.yaml
52+
├── role_binding.yaml
53+
└── service_account.yaml
54+
55+
$ operator-sdk generate csv --csv-version=0.0.1 --update-crds
56+
INFO[0000] Generating CSV manifest version 0.0.1
57+
...
58+
59+
$ tree deploy/
60+
deploy/
61+
...
62+
├── olm-catalog
63+
│   └── memcached-operator
64+
│   ├── 0.0.1
65+
│   │   ├── cache.example.com_memcacheds_crd.yaml
66+
│   │   └── memcached-operator.v0.0.1.clusterserviceversion.yaml
67+
│   └── memcached-operator.package.yaml
68+
...
69+
70+
71+
72+
##### Generate CSV from custom input paths #####
73+
$ operator-sdk generate csv --csv-version=0.0.1 --update-crds \
74+
--deploy-dir=config --apis-dir=api --output-dir=production
75+
INFO[0000] Generating CSV manifest version 0.0.1
76+
...
77+
78+
$ tree config/ api/ production/
79+
config/
80+
├── crds
81+
│   ├── cache.example.com_memcacheds_crd.yaml
82+
│   └── cache.example.com_v1alpha1_memcached_cr.yaml
83+
├── operator.yaml
84+
├── role.yaml
85+
├── role_binding.yaml
86+
└── service_account.yaml
87+
api/
88+
├── ...
89+
└── cache
90+
├── group.go
91+
└── v1alpha1
92+
├── ...
93+
└── memcached_types.go
94+
production/
95+
└── olm-catalog
96+
└── memcached-operator
97+
├── 0.0.1
98+
│   ├── cache.example.com_memcacheds_crd.yaml
99+
│   └── memcached-operator.v0.0.1.clusterserviceversion.yaml
100+
└── memcached-operator.package.yaml
101+
102+
```
103+
20104
### Options
21105

22106
```
107+
--apis-dir string Project relative path to root directory for API type defintions (default "pkg/apis")
108+
--crd-dir string Project relative path to root directory for for CRD manifests
23109
--csv-channel string Channel the CSV should be registered under in the package manifest
24-
--csv-config string Path to CSV config file. Defaults to deploy/olm-catalog/csv-config.yaml
25110
--csv-version string Semantic version of the CSV
26111
--default-channel Use the channel passed to --csv-channel as the package manifests' default channel. Only valid when --csv-channel is set
112+
--deploy-dir string Project relative path to root directory for operator manifests (Deployment, RBAC, CRDs) (default "deploy")
27113
--from-version string Semantic version of an existing CSV to use as a base
28114
-h, --help help for csv
29115
--operator-name string Operator name to use while generating CSV
116+
--output-dir string Base directory to output generated CSV. The resulting CSV bundle directory will be "<output-dir>/olm-catalog/<operator-name>/<csv-version>". (default "deploy")
30117
--update-crds Update CRD manifests in deploy/{operator-name}/{csv-version} the using latest API's
31118
```
32119

website/content/en/docs/golang/olm-catalog/generating-a-csv.md

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,31 @@ This document describes how to manage the following lifecycle for your Operator
1010

1111
## Configuration
1212

13-
Operator SDK projects have an expected [project layout][doc-project-layout]. In particular, a few manifests are expected to be present in the `deploy` directory:
13+
### Inputs
1414

15-
* Roles: `role.yaml`
16-
* Deployments: `operator.yaml`
17-
* Custom Resources (CR's): `crds/<full group>_<version>_<kind>_cr.yaml`
18-
* Custom Resource Definitions (CRD's): `crds/<full group>_<resource>_crd.yaml`.
15+
The CSV generator requires certain inputs to construct a CSV manifest.
1916

20-
`generate csv` reads these files and adds their data to a CSV in an alternate form.
17+
1. Path to the operator manifests root directory. By default `generate csv` extracts manifests from files in `deploy/` for the following kinds and adds them to the CSV. Use the `--deploy-dir` flag to change this path.
18+
* Roles: `role.yaml`
19+
* ClusterRoles: `cluster_role.yaml`
20+
* Deployments: `operator.yaml`
21+
* Custom Resources (CR's): `crds/<full group>_<version>_<kind>_cr.yaml`
22+
* CustomResourceDefinitions (CRD's): `crds/<full group>_<resource>_crd.yaml`
23+
2. Path to API types root directory. The CSV generator also parses the [CSV annotations][csv-annotations] from the API type definitions to populate certain CSV fields. By default the API types directory is `pkg/apis/`. Use the `--apis-dir` flag to change this path. The CSV generator expects either of the following layouyts for the API types directory
24+
* Mulitple groups: `<API-root-dir>/<group>/<version>/`
25+
* Single groups: `<API-root-dir>/<version>/`
2126

22-
The following example config containing default values should be copied and written to `deploy/olm-catalog/csv-config.yaml`:
27+
### Output
2328

24-
```yaml
25-
crd-cr-paths:
26-
- deploy/crds
27-
operator-path: deploy/operator.yaml
28-
role-paths:
29-
- deploy/role.yaml
30-
```
31-
32-
Explanation of all config fields:
33-
34-
- `crd-cr-paths`: list of strings - a list of CRD and CR manifest file/directory paths. Defaults to `[deploy/crds]`.
35-
- `operator-path`: string - the operator `Deployment` manifest file path. Defaults to `deploy/operator.yaml`.
36-
- `role-paths`: list of strings - Role and ClusterRole manifest file paths. Defaults to `[deploy/role.yaml]`.
37-
- `operator-name`: string - the name used to create the CSV and manifest file names. Defaults to the project's name.
38-
39-
**Note**: The [design doc][doc-csv-design] has outdated field information which should not be referenced.
40-
41-
Fields in this config file can be modified to point towards alternate manifest locations, and passed to `generate csv --csv-config=<path>` to configure CSV generation. For example, if I have one set of production CR/CRD manifests under `deploy/crds/production`, and a set of test manifests under `deploy/crds/test`, and I only want to include production manifests in my CSV, I can set `crd-cr-paths: [deploy/crds/production]`. `generate csv` will then ignore `deploy/crds/test` when getting CR/CRD data.
29+
By default `generate csv` will generate the catalog bundle directory `olm-catalog/...` under `deploy/`. To change where the CSV bundle directory is generated use the `--ouput-dir` flag.
4230

4331
## Versioning
4432

4533
CSV's are versioned in path, file name, and in their `metadata.name` field. For example, running `operator-sdk generate csv --csv-version 0.0.1` will generate a CSV at `deploy/olm-catalog/<operator-name>/0.0.1/<operator-name>.v0.0.1.clusterserviceversion.yaml`. A versioned directory such as `deploy/olm-catalog/<operator-name>/0.0.1` is known as a [*bundle*][doc-bundle]. Versions allow the OLM to upgrade or downgrade your Operator at runtime, i.e. in a cluster. A valid semantic version is required.
4634

4735
`generate csv` allows you to upgrade your CSV using the `--from-version` flag. If you have an existing CSV with version `0.0.1` and want to write a new version `0.0.2`, you can run `operator-sdk generate csv --csv-version 0.0.2 --from-version 0.0.1`. This will write a new CSV manifest to `deploy/olm-catalog/<operator-name>/0.0.2/<operator-name>.v0.0.2.clusterserviceversion.yaml` containing user-defined data from `0.0.1` and any modifications you've made to `roles.yaml`, `operator.yaml`, CR's, or CRD's.
4836

49-
The SDK can manage CRD's in your Operator bundle as well. You can pass the `--update-crds` flag to `generate csv` to add or update your CRD's in your bundle by copying manifests pointed to by `crd-cr-paths` in your config. CRD's in a bundle are not updated by default.
37+
The SDK can manage CRD's in your Operator bundle as well. You can pass the `--update-crds` flag to `generate csv` to add or update your CRD's in your bundle by copying manifests in `deploy/crds` to your bundle. CRD's in a bundle are not updated by default.
5038

5139
## First Generation
5240

@@ -86,7 +74,7 @@ Be sure to include the `--update-crds` flag if you want to add CRD's to your bun
8674

8775
Below are two lists of fields: the first is a list of all fields the SDK and OLM expect in a CSV, and the second are optional.
8876

89-
Several fields require user input (labeled _user_) or a [code annotation][code-annotations] (labeled _annotation_). This list may change as the SDK becomes better at generating CSV's.
77+
Several fields require user input (labeled _user_) or a [CSV annotation][csv-annotations] (labeled _annotation_). This list may change as the SDK becomes better at generating CSV's.
9078

9179
Required:
9280

@@ -130,10 +118,9 @@ Optional:
130118
[doc-csv]:https://github.com/operator-framework/operator-lifecycle-manager/blob/4197455/Documentation/design/building-your-csv.md
131119
[olm]:https://github.com/operator-framework/operator-lifecycle-manager
132120
[generate-csv-cli]:../../cli/operator-sdk_generate_csv.md
133-
[doc-project-layout]:../../project_layout.md
134121
[doc-csv-design]:../../design/milestone-0.2.0/csv-generation.md
135122
[doc-bundle]:https://github.com/operator-framework/operator-registry/blob/6893d19/README.md#manifest-format
136123
[x-desc-list]:https://github.com/openshift/console/blob/70bccfe/frontend/public/components/operator-lifecycle-manager/descriptors/types.ts#L3-L35
137124
[install-modes]:https://github.com/operator-framework/operator-lifecycle-manager/blob/4197455/Documentation/design/building-your-csv.md#operator-metadata
138125
[olm-capabilities]:../../images/operator-capability-level.png
139-
[code-annotations]:../../proposals/sdk-code-annotations.md
126+
[csv-annotations]: ./csv-annotations.md

0 commit comments

Comments
 (0)