diff --git a/website/content/en/docs/building-operators/golang/migration.md b/website/content/en/docs/building-operators/golang/migration.md index 5a53535b45..67bd3bb89d 100644 --- a/website/content/en/docs/building-operators/golang/migration.md +++ b/website/content/en/docs/building-operators/golang/migration.md @@ -156,7 +156,7 @@ type MemcachedList struct {...} ### Webhooks -SDK version `1.0.0` and later has support for webhooks by the CLI. If your project doesn't require any webhooks, you can skip this section. However, if you have been using it via customizations in your project, you should use the tool to re-scaffold the webhooks. +SDK version `1.0.0` and later has support for webhooks by the CLI. If your project doesn't require any webhooks, you can skip this section. However, if you have been using it via customizations in your project, you should use the tool to re-scaffold the webhooks. A webhook can only be scaffolded for a pre-existent API in your project. Then, for each case you will run the command `operator-sdk create webhook` providing the `--group`, `--kind` and `version` of the API based on the flags that need to be used. @@ -225,7 +225,7 @@ In the Memcached example, they look like the following: //+kubebuilder:rbac:groups=core,resources=pods,verbs=get;list ``` -To update `config/rbac/role.yaml` after changing the markers, run `make manifests`. +To update `config/rbac/role.yaml` after changing the markers, run `make manifests`. By default, new projects are cluster-scoped (i.e. they have cluster-scoped permissions and watch all namespaces). Read the [operator scope documentation][operator-scope] for more information about changing the scope of your operator. @@ -330,7 +330,7 @@ kubectl apply -f https://raw.githubusercontent.com/coreos/prometheus-operator/re #### Use Handler from `operator-lib` -By using the [InstrumentedEnqueueRequestForObject](https://pkg.go.dev/github.com/operator-framework/operator-lib@v0.1.0/handler?tab=doc#InstrumentedEnqueueRequestForObject) you will be able to export metrics from your Custom Resources. In our example, it would look like: +By using the [InstrumentedEnqueueRequestForObject](https://pkg.go.dev/github.com/operator-framework/operator-lib@v0.1.0/handler?tab=doc#InstrumentedEnqueueRequestForObject) you will be able to export metrics from your Custom Resources. In our example, it would look like: ```go import ( @@ -445,7 +445,6 @@ For further steps regarding the deployment of the operator, creation of custom r [healthz-ping]: https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/healthz#CheckHandler [controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime/releases [component-proposal]: https://github.com/kubernetes-sigs/controller-runtime/blob/master/designs/component-config.md -[component-config-tutorial]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/component-config-tutorial/tutorial.md [plugins-phase1-design-doc]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/extensible-cli-and-scaffolding-plugins-phase-1.md [migration-doc]: /docs/upgrading-sdk-version/ [tutorial-deploy]: /docs/building-operators/golang/tutorial/#run-the-operator diff --git a/website/content/en/docs/building-operators/golang/references/logging.md b/website/content/en/docs/building-operators/golang/references/logging.md index ad87f356df..62f04325cd 100644 --- a/website/content/en/docs/building-operators/golang/references/logging.md +++ b/website/content/en/docs/building-operators/golang/references/logging.md @@ -6,7 +6,7 @@ weight: 20 # Overview -Operator SDK-generated operators use the [`logr`][godoc_logr] interface to log. This log interface has several backends such as [`zap`][repo_zapr], which the SDK uses in generated code by default. [`logr.Logger`][godoc_logr_logger] exposes [structured logging][site_struct_logging] methods that help create machine-readable logs and adding a wealth of information to log records. +Operator SDK-generated operators use the [`logr`][godoc_logr] interface to log. This log interface has several backends such as [`zap`][repo_zapr], which the SDK uses in generated code by default. [`logr.Logger`][godoc_logr_logger] exposes structured logging methods that help create machine-readable logs and adding a wealth of information to log records. ## Default zap logger @@ -258,7 +258,6 @@ If you do not want to use `logr` as your logging tool, you can remove `logr`-spe [godoc_logr]:https://pkg.go.dev/github.com/go-logr/logr [repo_zapr]:https://pkg.go.dev/github.com/go-logr/zapr [godoc_logr_logger]:https://pkg.go.dev/github.com/go-logr/logr#Logger -[site_struct_logging]:https://www.client9.com/structured-logging-in-golang/ [code_memcached_controller]: https://github.com/operator-framework/operator-sdk/blob/v1.2.0/testdata/go/memcached-operator/controllers/memcached_controller.go [logfmt_repo]:https://github.com/jsternberg/zap-logfmt [controller_runtime_zap]:https://github.com/kubernetes-sigs/controller-runtime/tree/master/pkg/log/zap diff --git a/website/content/en/docs/building-operators/golang/testing.md b/website/content/en/docs/building-operators/golang/testing.md index 82af51e5b0..7940ad6c21 100644 --- a/website/content/en/docs/building-operators/golang/testing.md +++ b/website/content/en/docs/building-operators/golang/testing.md @@ -1,7 +1,7 @@ --- title: Testing your Operator project linkTitle: Testing with EnvTest -description: Learn how to ensure the quality of your Operator project +description: Learn how to ensure the quality of your Operator project weight: 70 --- @@ -20,13 +20,13 @@ These tests are runnable as native Go tests: go test controllers/ -v -ginkgo.v ``` -The projects generated by using the SDK tool have a Makefile which contains the target tests which executes when you run `make test`. Note that this target will also execute when you run `make docker-build IMG=/:`. +The projects generated by using the SDK tool have a Makefile which contains the target tests which executes when you run `make test`. Note that this target will also execute when you run `make docker-build IMG=/:`. -Operator SDK adopted this stack to write tests for its operators. It might be useful to check [writing controller tests][writing-controller-tests] documentation and examples to learn how to better write tests for your operator. See, for example, that [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) is covered by tests using the same stack as well. +Operator SDK adopted this stack to write tests for its operators. It might be useful to check [writing controller tests][writing-controller-tests] documentation and examples to learn how to better write tests for your operator. See, for example, that [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) is covered by tests using the same stack as well. ## e2e Integration tests -- **For Golang-based operators**: you can create the e2e tests using Go. See the `test` directory for the Memcached sample +- **For Golang-based operators**: you can create the e2e tests using Go. See the `test` directory for the Memcached sample under the [testdata/go/v3/memcached-operator][sample] to see an example of e2e tests. - **For Ansible-based operators**: you can use [Molecule][molecule], an Ansible testing framework. For further information see [Testing with Molecule][molecule-tests]. - **For Helm-based operators**: you can also use [Chart tests][helm-chart-tests]. @@ -62,4 +62,4 @@ To implement application-specific tests, the SDK's test harness, [scorecard][sco [helm-legacy-shell]: https://github.com/operator-framework/operator-sdk/blob/v1.0.0/hack/tests/e2e-helm.sh [ansible-legacy-shell]: https://github.com/operator-framework/operator-sdk/blob/v1.0.0/hack/tests/e2e-ansible.sh [chainsaw]: https://kyverno.github.io/chainsaw/latest/ -[from-kuttl-to-chainsaw]: https://kyverno.github.io/chainsaw/latest/more/kuttl-migration/ +[from-kuttl-to-chainsaw]: https://kyverno.github.io/chainsaw/latest/guides/kuttl-migration diff --git a/website/content/en/docs/upgrading-sdk-version/v1.21.0.md b/website/content/en/docs/upgrading-sdk-version/v1.21.0.md index 37b59dda45..5482f3755f 100644 --- a/website/content/en/docs/upgrading-sdk-version/v1.21.0.md +++ b/website/content/en/docs/upgrading-sdk-version/v1.21.0.md @@ -18,7 +18,7 @@ such as `api/webhook_suitetest.go` directory as for your controllers in `control _See [#4863](https://github.com/operator-framework/operator-sdk/pull/4863) for more details._ -## For Golang-based operators, update Dockerfile if you are using the [declarative/v1 plugin](https://book.kubebuilder.io/plugins/declarative-v1.html) +## For Golang-based operators, update Dockerfile if you are using the [declarative/v1 plugin](https://book-v3.book.kubebuilder.io/plugins/declarative-v1.html) If you are using the declarative/v1 plugin for your scaffolds, then following the steps to update the Dockerfile. a) After `COPY controllers/ controllers/` add: diff --git a/website/content/en/docs/upgrading-sdk-version/v1.7.0.md b/website/content/en/docs/upgrading-sdk-version/v1.7.0.md index 892a7d1099..f43e4b8dc1 100644 --- a/website/content/en/docs/upgrading-sdk-version/v1.7.0.md +++ b/website/content/en/docs/upgrading-sdk-version/v1.7.0.md @@ -5,13 +5,13 @@ weight: 998993000 ## Add the manager config patch to config/default/kustomization.yaml -The scaffolded `--config` flag was not added to either ansible-/helm-operator binary when [config file](https://master.book.kubebuilder.io/component-config-tutorial/tutorial.html) support was originally added, so does not currently work. The `--config` flag supports configuration of both binaries by file; this method of configuration only applies to the underlying [controller manager](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/manager#Manager), not the operator as a whole. To optionally configure the operator's Deployment with a config file, make the following update to config/default/kustomization.yaml: -```diff -# If you want your controller-manager to expose the /metrics # endpoint w/o any authn/z, please comment the following line. -- manager_auth_proxy_patch.yaml -+# Mount the controller config file for loading manager configurations -+# through a ComponentConfig type -+- manager_config_patch.yaml +The scaffolded `--config` flag was not added to either ansible-/helm-operator binary when [config file](https://book-v3.book.kubebuilder.io/component-config-tutorial/tutorial.html) support was originally added, so does not currently work. The `--config` flag supports configuration of both binaries by file; this method of configuration only applies to the underlying [controller manager](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/manager#Manager), not the operator as a whole. To optionally configure the operator's Deployment with a config file, make the following update to config/default/kustomization.yaml: +```diff +# If you want your controller-manager to expose the /metrics # endpoint w/o any authn/z, please comment the following line. +- manager_auth_proxy_patch.yaml ++# Mount the controller config file for loading manager configurations ++# through a ComponentConfig type ++- manager_config_patch.yaml ``` This feature is opt-in: flags can be used as-is or to override config file values. @@ -32,16 +32,16 @@ rules: \- apiGroups: - - coordination.k8s.io resources: - configmaps -+ verbs: -+- get -+- list -+- watch -+- create -+- update -+- patch -+- delete -+- apiGroups: -+- coordination.k8s.io ++ verbs: ++- get ++- list ++- watch ++- create ++- update ++- patch ++- delete ++- apiGroups: ++- coordination.k8s.io + resources: - leases verbs: @@ -56,11 +56,11 @@ Importing `setup-envtest.sh` needs bash, so your Makefile's `SHELL` variable sho ```diff else GOBIN=$(shell go env GOBIN) endif -+# Setting SHELL to bash allows bash commands to be executed by recipes. -+# This is a requirement for 'setup-envtest.sh' in the test target. -+# Options are set to exit when a recipe line exits non-zero or a piped command fails. -+SHELL = /usr/bin/env bash -o pipefail -+.SHELLFLAGS = -ec -+ all: build ++# Setting SHELL to bash allows bash commands to be executed by recipes. ++# This is a requirement for 'setup-envtest.sh' in the test target. ++# Options are set to exit when a recipe line exits non-zero or a piped command fails. ++SHELL = /usr/bin/env bash -o pipefail ++.SHELLFLAGS = -ec ++ all: build ``` _See [#4835](https://github.com/operator-framework/operator-sdk/pull/4835) for more details._ diff --git a/website/content/en/docs/upgrading-sdk-version/v1.7.1.md b/website/content/en/docs/upgrading-sdk-version/v1.7.1.md index 52bd5797f7..6627e4320c 100644 --- a/website/content/en/docs/upgrading-sdk-version/v1.7.1.md +++ b/website/content/en/docs/upgrading-sdk-version/v1.7.1.md @@ -5,13 +5,13 @@ weight: 998992999 ## Add the manager config patch to config/default/kustomization.yaml -The scaffolded `--config` flag was not added to either ansible-/helm-operator binary when [config file](https://master.book.kubebuilder.io/component-config-tutorial/tutorial.html) support was originally added, so does not currently work. The `--config` flag supports configuration of both binaries by file; this method of configuration only applies to the underlying [controller manager](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/manager#Manager), not the operator as a whole. To optionally configure the operator's Deployment with a config file, make the following update to config/default/kustomization.yaml: -```diff -# If you want your controller-manager to expose the /metrics # endpoint w/o any authn/z, please comment the following line. -\- manager_auth_proxy_patch.yaml -+# Mount the controller config file for loading manager configurations -+# through a ComponentConfig type -+- manager_config_patch.yaml +The scaffolded `--config` flag was not added to either ansible-/helm-operator binary when [config file](https://book-v3.book.kubebuilder.io/component-config-tutorial/tutorial.html) support was originally added, so does not currently work. The `--config` flag supports configuration of both binaries by file; this method of configuration only applies to the underlying [controller manager](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/manager#Manager), not the operator as a whole. To optionally configure the operator's Deployment with a config file, make the following update to config/default/kustomization.yaml: +```diff +# If you want your controller-manager to expose the /metrics # endpoint w/o any authn/z, please comment the following line. +\- manager_auth_proxy_patch.yaml ++# Mount the controller config file for loading manager configurations ++# through a ComponentConfig type ++- manager_config_patch.yaml ``` This feature is opt-in: flags can be used as-is or to override config file values. @@ -33,16 +33,16 @@ rules: - - coordination.k8s.io resources: - configmaps -+ verbs: -+- get -+- list -+- watch -+- create -+- update -+- patch -+- delete -+- apiGroups: -+- coordination.k8s.io ++ verbs: ++- get ++- list ++- watch ++- create ++- update ++- patch ++- delete ++- apiGroups: ++- coordination.k8s.io + resources: - leases verbs: @@ -57,12 +57,12 @@ Importing `setup-envtest.sh` needs bash, so your Makefile's `SHELL` variable sho ```diff else GOBIN=$(shell go env GOBIN) endif -+# Setting SHELL to bash allows bash commands to be executed by recipes. -+# This is a requirement for 'setup-envtest.sh' in the test target. -+# Options are set to exit when a recipe line exits non-zero or a piped command fails. -+SHELL = /usr/bin/env bash -o pipefail -+.SHELLFLAGS = -ec -+ all: build ++# Setting SHELL to bash allows bash commands to be executed by recipes. ++# This is a requirement for 'setup-envtest.sh' in the test target. ++# Options are set to exit when a recipe line exits non-zero or a piped command fails. ++SHELL = /usr/bin/env bash -o pipefail ++.SHELLFLAGS = -ec ++ all: build ``` _See [#4835](https://github.com/operator-framework/operator-sdk/pull/4835) for more details._