Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to component-config-tutorial in migration.md #6766

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions website/content/en/docs/building-operators/golang/testing.md
Original file line number Diff line number Diff line change
@@ -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
---

Expand All @@ -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=<some-registry>/<project-name>:<tag>`.
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=<some-registry>/<project-name>:<tag>`.

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].
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion website/content/en/docs/upgrading-sdk-version/v1.21.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
46 changes: 23 additions & 23 deletions website/content/en/docs/upgrading-sdk-version/v1.7.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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._
46 changes: 23 additions & 23 deletions website/content/en/docs/upgrading-sdk-version/v1.7.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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._

Expand Down
Loading