Skip to content

Commit ec03835

Browse files
author
Eric Stroczynski
authored
docs: OLM integration docs reference new commands (new and legacy CLI) (#3320)
1 parent b7bc77b commit ec03835

24 files changed

+1203
-589
lines changed

cmd/operator-sdk/bundle/cmd.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,32 @@ An operator bundle is a portable operator packaging format understood by Kuberne
3838
native software, like the Operator Lifecycle Manager.
3939
4040
More information about operator bundles and metadata:
41-
https://github.com/operator-framework/operator-registry#manifest-format.
42-
43-
More information about the integration with OLM via SDK:
44-
https://sdk.operatorframework.io/docs/olm-integration/
41+
https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md
4542
`,
4643
}
4744
return cmd
4845
}
4946

5047
func NewCmdLegacy() *cobra.Command {
5148
cmd := newCmd()
49+
// TODO(estroz): uncomment this once OLM integration docs are updated.
50+
// cmd.Long += `
51+
// More information about the integration with OLM via SDK:
52+
// https://sdk.operatorframework.io/docs/olm-integration/legacy
53+
// `
5254
cmd.AddCommand(
5355
newCreateCmd(),
54-
newValidateCmd(),
56+
newValidateCmdLegacy(),
5557
)
5658
return cmd
5759
}
5860

5961
func NewCmd() *cobra.Command {
6062
cmd := newCmd()
63+
cmd.Long += `
64+
More information about the integration with OLM via SDK:
65+
https://sdk.operatorframework.io/docs/olm-integration
66+
`
6167
cmd.AddCommand(
6268
newValidateCmd(),
6369
)

cmd/operator-sdk/bundle/validate.go

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,53 +38,90 @@ import (
3838
internalregistry "github.com/operator-framework/operator-sdk/internal/registry"
3939
)
4040

41-
type bundleValidateCmd struct {
42-
bundleCmd
41+
const (
42+
longHelp = `The 'operator-sdk bundle validate' command can validate both content and format of an operator bundle
43+
image or an operator bundle directory on-disk containing operator metadata and manifests. This command will exit
44+
with an exit code of 1 if any validation errors arise, and 0 if only warnings arise or all validators pass.
4345
44-
outputFormat string
45-
}
46+
More information about operator bundles and metadata:
47+
https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md
4648
47-
// newValidateCmd returns a command that will validate an operator bundle image.
48-
func newValidateCmd() *cobra.Command {
49-
c := bundleValidateCmd{}
50-
cmd := &cobra.Command{
51-
Use: "validate",
52-
Short: "Validate an operator bundle image",
53-
Long: `The 'operator-sdk bundle validate' command can validate both content and
54-
format of an operator bundle image or an operator bundles directory on-disk
55-
containing operator metadata and manifests. This command will exit with an
56-
exit code of 1 if any validation errors arise, and 0 if only warnings arise or
57-
all validators pass.
49+
NOTE: if validating an image, the image must exist in a remote registry, not just locally.
50+
`
5851

59-
More information about operator bundles and metadata:
60-
https://github.com/operator-framework/operator-registry#manifest-format.
52+
examples = `The following command flow will generate test-operator bundle manifests and metadata,
53+
then validate them for 'test-operator' version v0.1.0:
54+
55+
# Generate manifests and metadata locally.
56+
$ make bundle
57+
58+
# Validate the directory containing manifests and metadata.
59+
$ operator-sdk bundle validate ./bundle
60+
61+
To build and validate an image built with the above manifests and metadata:
62+
63+
# Create a registry namespace or use an existing one.
64+
$ export NAMESPACE=<your registry namespace>
65+
66+
# Build and push the image using the docker CLI.
67+
$ docker build -f bundle.Dockerfile -t quay.io/$NAMESPACE/test-operator:v0.1.0 .
68+
$ docker push quay.io/$NAMESPACE/test-operator:v0.1.0
6169
62-
NOTE: if validating an image, the image must exist in a remote registry, not
63-
just locally.
64-
`,
65-
Example: `The following command flow will generate test-operator bundle image manifests
66-
and validate them, assuming a bundle for 'test-operator' version v0.1.0 exists at
67-
<project-root>/deploy/olm-catalog/test-operator/manifests:
70+
# Ensure the image with modified metadata and Dockerfile is valid.
71+
$ operator-sdk bundle validate quay.io/$NAMESPACE/test-operator:v0.1.0
72+
`
73+
74+
examplesLegacy = `The following command flow will generate test-operator bundle manifests and metadata,
75+
then validate them for 'test-operator' version v0.1.0:
6876
69-
# Generate manifests locally.
70-
$ operator-sdk bundle create --generate-only
77+
# Generate manifests and metadata locally.
78+
$ operator-sdk generate bundle --version 0.1.0
7179
7280
# Validate the directory containing manifests and metadata.
7381
$ operator-sdk bundle validate ./deploy/olm-catalog/test-operator
7482
75-
To build and validate an image:
83+
To build and validate an image built with the above manifests and metadata:
7684
7785
# Create a registry namespace or use an existing one.
7886
$ export NAMESPACE=<your registry namespace>
7987
8088
# Build and push the image using the docker CLI.
81-
$ operator-sdk bundle create quay.io/$NAMESPACE/test-operator:v0.1.0
89+
$ docker build -f bundle.Dockerfile -t quay.io/$NAMESPACE/test-operator:v0.1.0 .
8290
$ docker push quay.io/$NAMESPACE/test-operator:v0.1.0
8391
8492
# Ensure the image with modified metadata and Dockerfile is valid.
8593
$ operator-sdk bundle validate quay.io/$NAMESPACE/test-operator:v0.1.0
94+
`
95+
)
96+
97+
type bundleValidateCmd struct {
98+
bundleCmd
99+
100+
outputFormat string
101+
}
86102

87-
`,
103+
// newValidateCmd returns a command that will validate an operator bundle.
104+
func newValidateCmd() *cobra.Command {
105+
cmd := makeValidateCmd()
106+
cmd.Long = longHelp
107+
cmd.Example = examples
108+
return cmd
109+
}
110+
111+
// newValidateCmdLegacy returns a command that will validate an operator bundle for the legacy CLI.
112+
func newValidateCmdLegacy() *cobra.Command {
113+
cmd := makeValidateCmd()
114+
cmd.Long = longHelp
115+
cmd.Example = examplesLegacy
116+
return cmd
117+
}
118+
119+
// makeValidateCmd makes a command that will validate an operator bundle. Help text must be customized.
120+
func makeValidateCmd() *cobra.Command {
121+
c := bundleValidateCmd{}
122+
cmd := &cobra.Command{
123+
Use: "validate",
124+
Short: "Validate an operator bundle",
88125
RunE: func(cmd *cobra.Command, args []string) (err error) {
89126
if viper.GetBool(flags.VerboseOpt) {
90127
log.SetLevel(log.DebugLevel)

website/content/en/build/_index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ <h2 class="of-heading of-heading--xl">READ THE USER GUIDES</h2>
6868
<div class="of-section--largetext__item">
6969
<h2 class="of-heading of-heading--xl">PUBLISH YOUR OPERATOR</h2>
7070
<p class="of-section--largetext__content">Learn about how you can package your Operator and share with the Kubernetes community using Operator Lifecycle Manager's package management.</p>
71-
<a href="/docs/olm-integration/user-guide" class="of-button of-button--tertiary">Learn More
71+
<a href="/docs/olm-integration/quickstart-bundle" class="of-button of-button--tertiary">Learn More
7272
<svg class="of-button__icon" enable-background="new 0 0 22 22" version="1.1" viewBox="0 0 22 22" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
7373
<path d="M19.5,8l-7.3-7.6c-0.4-0.4-1.1-0.4-1.5,0L9.3,1.8c-0.4,0.4-0.4,1.1,0,1.6l5.2,5.5H1.1C0.5,8.9,0,9.3,0,10V12 c0,0.6,0.5,1.1,1.1,1.1h13.5l-5.2,5.5c-0.4,0.4-0.4,1.1,0,1.6l1.4,1.5c0.4,0.4,1.1,0.4,1.5,0l9.4-9.9c0.4-0.4,0.4-1.1,0-1.6L19.5,8z "/>
7474
</svg>

website/content/en/docs/ansible/quickstart.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ INFO[0000] operator-sdk Version: 0.0.5+git
243243

244244
OLM will manage creation of most if not all resources required to run your operator,
245245
using a bit of setup from other `operator-sdk` commands. Check out the OLM integration
246-
[user guide][olm-user-guide] for more information.
246+
[user guide][quickstart-bundle] for more information.
247247

248248
### Create a Memcached CR
249249

@@ -376,4 +376,5 @@ For more information, refer [cli][addcli] doc.
376376
[docker-tool]:https://docs.docker.com/install/
377377
[kubectl-tool]:https://kubernetes.io/docs/tasks/tools/install-kubectl/
378378
[addcli]: /docs/cli/operator-sdk_add_api
379-
[olm-user-guide]: /docs/olm-integration/user-guide
379+
<!-- TODO: update this link to the non-legacy doc once the ansible plugin is publicly available -->
380+
[quickstart-bundle]: /docs/olm-integration/legacy/quickstart-bundle

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ An operator bundle is a portable operator packaging format understood by Kuberne
1212
native software, like the Operator Lifecycle Manager.
1313

1414
More information about operator bundles and metadata:
15-
https://github.com/operator-framework/operator-registry#manifest-format.
16-
17-
More information about the integration with OLM via SDK:
18-
https://sdk.operatorframework.io/docs/olm-integration/
15+
https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md
1916

2017

2118
### Options
@@ -28,5 +25,5 @@ https://sdk.operatorframework.io/docs/olm-integration/
2825

2926
* [operator-sdk](../operator-sdk) - An SDK for building operators with ease
3027
* [operator-sdk bundle create](../operator-sdk_bundle_create) - Create an operator bundle image
31-
* [operator-sdk bundle validate](../operator-sdk_bundle_validate) - Validate an operator bundle image
28+
* [operator-sdk bundle validate](../operator-sdk_bundle_validate) - Validate an operator bundle
3229

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@ title: "operator-sdk bundle validate"
33
---
44
## operator-sdk bundle validate
55

6-
Validate an operator bundle image
6+
Validate an operator bundle
77

88
### Synopsis
99

10-
The 'operator-sdk bundle validate' command can validate both content and
11-
format of an operator bundle image or an operator bundles directory on-disk
12-
containing operator metadata and manifests. This command will exit with an
13-
exit code of 1 if any validation errors arise, and 0 if only warnings arise or
14-
all validators pass.
10+
The 'operator-sdk bundle validate' command can validate both content and format of an operator bundle
11+
image or an operator bundle directory on-disk containing operator metadata and manifests. This command will exit
12+
with an exit code of 1 if any validation errors arise, and 0 if only warnings arise or all validators pass.
1513

1614
More information about operator bundles and metadata:
17-
https://github.com/operator-framework/operator-registry#manifest-format.
15+
https://github.com/operator-framework/operator-registry/blob/master/docs/design/operator-bundle.md
1816

19-
NOTE: if validating an image, the image must exist in a remote registry, not
20-
just locally.
17+
NOTE: if validating an image, the image must exist in a remote registry, not just locally.
2118

2219

2320
```
@@ -27,29 +24,27 @@ operator-sdk bundle validate [flags]
2724
### Examples
2825

2926
```
30-
The following command flow will generate test-operator bundle image manifests
31-
and validate them, assuming a bundle for 'test-operator' version v0.1.0 exists at
32-
<project-root>/deploy/olm-catalog/test-operator/manifests:
27+
The following command flow will generate test-operator bundle manifests and metadata,
28+
then validate them for 'test-operator' version v0.1.0:
3329
34-
# Generate manifests locally.
35-
$ operator-sdk bundle create --generate-only
30+
# Generate manifests and metadata locally.
31+
$ operator-sdk generate bundle --version 0.1.0
3632
3733
# Validate the directory containing manifests and metadata.
3834
$ operator-sdk bundle validate ./deploy/olm-catalog/test-operator
3935
40-
To build and validate an image:
36+
To build and validate an image built with the above manifests and metadata:
4137
4238
# Create a registry namespace or use an existing one.
4339
$ export NAMESPACE=<your registry namespace>
4440
4541
# Build and push the image using the docker CLI.
46-
$ operator-sdk bundle create quay.io/$NAMESPACE/test-operator:v0.1.0
42+
$ docker build -f bundle.Dockerfile -t quay.io/$NAMESPACE/test-operator:v0.1.0 .
4743
$ docker push quay.io/$NAMESPACE/test-operator:v0.1.0
4844
4945
# Ensure the image with modified metadata and Dockerfile is valid.
5046
$ operator-sdk bundle validate quay.io/$NAMESPACE/test-operator:v0.1.0
5147
52-
5348
```
5449

5550
### Options

website/content/en/docs/golang/legacy/quickstart.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ if err != nil {
319319
reqLogger.Info("Memcached resource not found. Ignoring since object must be deleted")
320320
return reconcile.Result{}, nil
321321
}
322+
}
322323
...
323324
```
324325

@@ -411,7 +412,7 @@ You can use a specific kubeconfig via the flag `--kubeconfig=<path/to/kubeconfig
411412

412413
OLM will manage creation of most if not all resources required to run your operator,
413414
using a bit of setup from other `operator-sdk` commands. Check out the OLM integration
414-
[user guide][olm-user-guide] for more information.
415+
[user guide][quickstart-bundle] for more information.
415416

416417
## Create a Memcached CR
417418

@@ -639,19 +640,23 @@ By default, SDK operator projects are set up to [export metrics][metrics_doc] th
639640

640641
```go
641642
func serveCRMetrics(cfg *rest.Config) error {
642-
...
643-
filteredGVK, err := k8sutil.GetGVKsFromAddToScheme(apis.AddToScheme)
643+
...
644+
645+
filteredGVK, err := k8sutil.GetGVKsFromAddToScheme(apis.AddToScheme)
644646
if err != nil {
645647
return err
646648
}
647649

648-
...
650+
...
649651

650652
// Generate and serve custom resource specific metrics.
651653
err = kubemetrics.GenerateAndServeCRMetrics(cfg, ns, filteredGVK, metricsHost, operatorMetricsPort)
652654
if err != nil {
653655
return err
654656
}
657+
658+
...
659+
}
655660
```
656661

657662
The `kubemetrics.GenerateAndServeCRMetrics` function requires an RBAC rule to list all GroupVersionKinds in the list of watched namespaces, so you might need to [filter](https://github.com/operator-framework/operator-sdk/blob/v0.15.2/pkg/k8sutil/k8sutil.go#L161) the kinds returned by [`k8sutil.GetGVKsFromAddToScheme`](https://godoc.org/github.com/operator-framework/operator-sdk/pkg/k8sutil#GetGVKsFromAddToScheme) more stringently to avoid authorization errors such as `Failed to list *unstructured.Unstructured`.
@@ -860,6 +865,6 @@ When the operator is not running in a cluster, the Manager will return an error
860865
[scheme_builder]: https://godoc.org/sigs.k8s.io/controller-runtime/pkg/scheme#Builder
861866
[typical-status-properties]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
862867
[godoc-conditions]: https://godoc.org/github.com/operator-framework/operator-sdk/pkg/status#Conditions
863-
[olm-user-guide]: /docs/olm-integration/user-guide
868+
[quickstart-bundle]: /docs/olm-integration/legacy/quickstart-bundle
864869
[new_docs]:/docs/golang/quickstart
865-
[new_CLI]:/docs/new-cli
870+
[new_CLI]:/docs/new-cli

website/content/en/docs/golang/legacy/references/markers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ This section details ClusterServiceVersion (CSV) [code markers][code-markers-des
1414

1515
## Usage
1616

17-
All markers have a `+operator-sdk:gen-csv` prefix, denoting that they're parsed while executing [`operator-sdk generate csv`][generate-csv-cli].
17+
All markers have a `+operator-sdk:gen-csv` prefix, denoting that they're parsed while executing
18+
[`operator-sdk generate bundle`][cli-gen-bundle] or [`operator-sdk generate packagemanifests`][cli-gen-packagemanifests].
1819

1920
### Paths
2021

@@ -203,6 +204,7 @@ customresourcedefinitions:
203204
204205
[markers]:https://pkg.go.dev/sigs.k8s.io/controller-tools/pkg/markers
205206
[code-markers-design]:https://github.com/operator-framework/operator-sdk/blob/master/proposals/sdk-code-annotations.md
206-
[generate-csv-cli]:/docs/cli/operator-sdk_generate_csv
207+
[cli-gen-bundle]:/docs/cli/operator-sdk_generate_bundle
208+
[cli-gen-packagemanifests]:/docs/cli/operator-sdk_generate_packagemanifests
207209
[csv-x-desc]:https://github.com/openshift/console/blob/feabd61/frontend/packages/operator-lifecycle-manager/src/components/descriptors/types.ts#L3-L39
208210
[csv-spec]:https://github.com/operator-framework/operator-lifecycle-manager/blob/e0eea22/doc/design/building-your-csv.md

website/content/en/docs/golang/references/markers.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ This section details ClusterServiceVersion (CSV) [code markers][code-markers-des
1414

1515
## Usage
1616

17-
All markers have a `+operator-sdk:gen-csv` prefix, denoting that they're parsed while executing [`operator-sdk generate csv`][generate-csv-cli].
17+
All markers have a `+operator-sdk:gen-csv` prefix, denoting that they're parsed while executing
18+
[`operator-sdk generate kustomize manifests`][cli-gen-kustomize-manifests].
1819

1920
### Paths
2021

@@ -203,6 +204,6 @@ customresourcedefinitions:
203204
204205
[markers]:https://pkg.go.dev/sigs.k8s.io/controller-tools/pkg/markers
205206
[code-markers-design]:https://github.com/operator-framework/operator-sdk/blob/master/proposals/sdk-code-annotations.md
206-
[generate-csv-cli]:/docs/cli/operator-sdk_generate_csv
207+
[cli-gen-kustomize-manifests]:/docs/new-cli/operator-sdk_generate_kustomize_manifests
207208
[csv-x-desc]:https://github.com/openshift/console/blob/feabd61/frontend/packages/operator-lifecycle-manager/src/components/descriptors/types.ts#L3-L39
208209
[csv-spec]:https://github.com/operator-framework/operator-lifecycle-manager/blob/e0eea22/doc/design/building-your-csv.md

website/content/en/docs/helm/quickstart.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ INFO[0000] operator-sdk Version: v0.2.0+git
224224

225225
OLM will manage creation of most if not all resources required to run your operator,
226226
using a bit of setup from other `operator-sdk` commands. Check out the OLM integration
227-
[user guide][olm-user-guide] for more information.
227+
[user guide][quickstart-bundle] for more information.
228228

229229
## Deploy the Nginx custom resource
230230

@@ -313,4 +313,5 @@ For more information, refer [cli][addcli] doc.
313313
[helm-values]:https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing
314314
[helm-official]:https://helm.sh/docs/
315315
[addcli]: /docs/cli/operator-sdk_add_api
316-
[olm-user-guide]: /docs/olm-integration/user-guide
316+
<!-- TODO: update this link to the non-legacy doc once the helm plugin is publicly available -->
317+
[quickstart-bundle]: /docs/olm-integration/legacy/quickstart-bundle

0 commit comments

Comments
 (0)