Skip to content

Commit

Permalink
Fix typos, sentence structures, punctuation (#5913)
Browse files Browse the repository at this point in the history
Signed-off-by: Sanja Bonic <86982064+sanjacodes@users.noreply.github.com>
  • Loading branch information
Sanja Bonic authored Jul 5, 2022
1 parent 9762aa2 commit 62cbecc
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ The easy migration path is to initialize a new project, re-recreate APIs, then c
### Prerequisites

- Go through the [installation guide][install-guide].
- User authorized with `cluster-admin` permissions.
- Make sure your user is authorized with `cluster-admin` permissions.
- An accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in in your command line environment.
[quay.io](https://quay.io/)) and be logged in to your command line environment.
- `example.com` is used as the registry Docker Hub namespace in these examples.
Replace it with another value if using a different registry or namespace.
- [Authentication and certificates][image-reg-config] if the registry is private or uses a custom CA.
Expand Down Expand Up @@ -282,13 +282,13 @@ The default port used by the metric endpoint binds to was changed from `:8383` t

### Verify the migration

The project can now be deployed on cluster by running the command:
The project can now be deployed on the cluster by running the command:

```sh
make deploy IMG=example.com/memcached-operator:v0.0.1
```

You can troubleshoot your deployment by checking container logs:
You can troubleshoot your deployment by checking the container logs:
```sh
kubectl logs deployment.apps/memcached-operator-controller-manager -n memcached-operator-system -c manager
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This guide walks through an example of building a simple memcached-operator powe
## Prerequisites

- Go through the [installation guide][install-guide].
- User authorized with `cluster-admin` permissions.
- An accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in in your command line environment.
- Make sure your user is authorized with `cluster-admin` permissions.
- Have an accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in to your command line environment.
- `example.com` is used as the registry Docker Hub namespace in these examples.
Replace it with another value if using a different registry or namespace.
- [Authentication and certificates][image-reg-config] if the registry is private or uses a custom CA.
Expand Down Expand Up @@ -100,7 +100,7 @@ has a custom CA, these [configuration steps][image-reg-config] must be complete.

## Next Steps

Read the [full tutorial][tutorial] for an in-depth walkthough of building a Ansible operator.
Read the [full tutorial][tutorial] for an in-depth walkthrough of building an Ansible operator.


[ansible-link]:https://www.ansible.com/
Expand Down
24 changes: 12 additions & 12 deletions website/content/en/docs/building-operators/ansible/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Ansible Operator Tutorial
linkTitle: Tutorial
weight: 3
description: An in-depth walkthough of building and running an Ansible-based operator.
description: An in-depth walkthrough of building and running an Ansible-based operator.
---

**NOTE:** If your project was created with an `operator-sdk` version prior to `v1.0.0`
Expand All @@ -11,9 +11,9 @@ please [migrate][migration-guide], or consult the [legacy docs][legacy-quickstar
## Prerequisites

- Go through the [installation guide][install-guide].
- User authorized with `cluster-admin` permissions.
- Make sure your user is authorized with `cluster-admin` permissions.
- An accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in in your command line environment.
[quay.io](https://quay.io/)) and be logged in to your command line environment.
- `example.com` is used as the registry Docker Hub namespace in these examples.
Replace it with another value if using a different registry or namespace.
- [Authentication and certificates][image-reg-config] if the registry is private or uses a custom CA.
Expand Down Expand Up @@ -54,7 +54,7 @@ The scaffolded operator has the following structure:
- A reconciler, which is an Ansible Role or Playbook.
- A `watches.yaml` file, which connects the `Memcached` resource to the `memcached` Ansible Role.

See [scaffolded files reference][layout-doc] and [watches reference][ansible-watches] for more detailed information
See [scaffolded files reference][layout-doc] and [watches reference][ansible-watches] for more detailed information.

### Modify the Manager

Expand Down Expand Up @@ -130,12 +130,12 @@ The key-value pairs in the Custom Resource spec are passed
to Ansible as extra variables.

**Note:** The names of all variables in the spec field are converted to
snake_case by the operator before running ansible. For example,
serviceAccount in the spec becomes service_account in ansible. You can
snake_case by the operator before running Ansible. For example,
serviceAccount in the spec becomes service_account in Ansible. You can
disable this case conversion by setting the `snakeCaseParameters` option
to `false` in your `watches.yaml`. It is recommended that you perform some
type validation in Ansible on the variables to ensure that your
application is receiving expected input.
application is receiving the expected input.

## Configure the operator's image registry

Expand All @@ -162,13 +162,13 @@ make docker-build docker-push

There are three ways to run the operator:

- As Go program outside a cluster
- As a Go program outside a cluster
- As a Deployment inside a Kubernetes cluster
- Managed by the [Operator Lifecycle Manager (OLM)][doc-olm] in [bundle][tutorial-bundle] format

### 1. Run locally outside the cluster

Execute the following command, which install your CRDs and run the manager locally:
Execute the following command, which installs your CRDs and runs the manager locally:

```sh
make install run
Expand Down Expand Up @@ -340,14 +340,14 @@ make undeploy

## Next Steps

We recommend reading through the our [Ansible development section][ansible-developer-tips]
We recommend reading through the [Ansible development section][ansible-developer-tips]
for tips and tricks, including how to run the operator locally.

In this tutorial, the scaffolded `watches.yaml` could be used as-is, but
has additional optional features. See [watches reference][ansible-watches].
has additional optional features. See the [watches reference][ansible-watches].

For brevity, some of the scaffolded files were left out of this guide.
See [Scaffolding Reference][layout-doc]
See [Scaffolding Reference][layout-doc].

This example built a namespaced scope operator, but Ansible operators
can also be used with cluster-wide scope.
Expand Down
42 changes: 21 additions & 21 deletions website/content/en/docs/building-operators/golang/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Scaffolded projects now use:
- Updated metrics configuration using [kube-auth-proxy][kube-auth-proxy], a `--metrics-addr` flag, and [kustomize][kustomize]-based deployment of a Kubernetes `Service` and prometheus operator `ServiceMonitor`
- Scaffolded tests that use the [`envtest`][envtest] test framework
- Preliminary support for CLI plugins. For more info see the [plugins design document][plugins-phase1-design-doc]
- A `PROJECT` configuration file to store information about GVKs, plugins, and help the CLI make decisions.
- A new option to create projects using ComponentConfig. For more info, see [enhancement proposal][component-proposal] and the [Component config tutorial][component-config-tutorial]
- Go version `1.15` (previously it was `1.13`).
- A `PROJECT` configuration file to store information about GVKs, plugins, and help the CLI make decisions
- A new option to create projects using ComponentConfig. For more info, see the [enhancement proposal][component-proposal] and the [Component config tutorial][component-config-tutorial]
- Go version `1.15` (previously it was `1.13`)

Generated files with the default API versions:

Expand All @@ -52,9 +52,9 @@ The easy migration path is to initialize a new project, re-recreate APIs, then c
### Prerequisites

- Go through the [installation guide][install-guide].
- User authorized with `cluster-admin` permissions.
- Make sure your user is authorized with `cluster-admin` permissions.
- An accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in in your command line environment.
[quay.io](https://quay.io/)) and be logged in to your command line environment.
- `example.com` is used as the registry Docker Hub namespace in these examples.
Replace it with another value if using a different registry or namespace.
- [Authentication and certificates][image-reg-config] if the registry is private or uses a custom CA.
Expand Down Expand Up @@ -86,10 +86,10 @@ operator-sdk init --domain example.com --repo github.com/example/memcached-opera

### Check if your project is multi-group

Before we start to create the APIs, check if your project has more than one group such as : `foo.example.com/v1` and `crew.example.com/v1`. If you intend to work with multiple groups in your project, then to change the project's layout to support multi-group, run the command `operator-sdk edit --multigroup=true`
Before we start creating the APIs, check if your project has more than one group such as: `foo.example.com/v1` and `crew.example.com/v1`. If you intend to work with multiple groups in your project, then run the command `operator-sdk edit --multigroup=true` to change the project's layout to support multi-group.

**Note:** In multi-group projects, APIs are defined in `apis/<group>/<version>` and controllers are defined in `controllers/<group>`.
For further information see the [Single Group to Multi-Group][multigroup-kubebuilder-doc]
For further information see [Single Group to Multi-Group][multigroup-kubebuilder-doc].

### Migrate APIs and Controllers

Expand All @@ -116,7 +116,7 @@ The `apiextensions.k8s.io/v1beta1` was deprecated in Kubernetes `1.16` and will

If you would like to keep using the previous version, use the flag `--crd-version=v1beta1` in the above command. This is only needed if you want your operator to support Kubernetes `1.15` and earlier.

### API's
### APIs

Now let’s copy the API definition from `pkg/apis/<group>/<version>/<kind>_types.go` to `api/<version>/<kind>_types.go`. For our example, it is only required to copy the code from the `Spec` and `Status` fields.

Expand Down 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 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 @@ -195,7 +195,7 @@ If you would like to use the previous version, use the flag `--webhook-version=v

### Controllers

Now let’s migrate the controller code from `pkg/controller/<kind>/<kind>_controller.go` to `controllers/<kind>_controller.go`. Following the steps:
Now let’s migrate the controller code from `pkg/controller/<kind>/<kind>_controller.go` to `controllers/<kind>_controller.go` following these steps:

1. Copy over any struct fields from the existing project into the new `<Kind>Reconciler` struct.
**Note:** The `Reconciler` struct has been renamed from `Reconcile<Kind>` to `<Kind>Reconciler`. In our example, we would see `ReconcileMemcached` instead of `MemcachedReconciler`.
Expand Down Expand Up @@ -236,7 +236,7 @@ See the complete migrated `memcached_controller.go` code [here][memcached_contro
##### Updating your ServiceAccount

New Go projects come with a ServiceAccount `controller-manager` in `config/rbac/service_account.yaml`.
Your project's RoleBinding and ClusterRoleBinding subjects, and Deployment's `spec.template.spec.serviceAccountName`
Your project's RoleBinding and ClusterRoleBinding subjects, and Deployments `spec.template.spec.serviceAccountName`
that reference a ServiceAccount already refer to this new name. When you run `make deploy`,
your project's name will be prepended to `controller-manager`, making it unique within a namespace,
much like your old `deploy/service_account.yaml`. If you wish to use the old ServiceAccount,
Expand All @@ -246,7 +246,7 @@ make sure to update all RBAC bindings and your manager Deployment.

By checking our new `main.go` we will find that:

- The SDK [leader.Become][leader-lib-doc] was replaced by the [controller-runtime's leader][controller-runtime-leader] with lease mechanism. However, you still able to stick with the [leader.Become][leader-lib-doc] for life if you wish:
- The SDK [leader.Become][leader-lib-doc] was replaced by the [controller-runtime's leader][controller-runtime-leader] with lease mechanism. However, you can still use [leader.Become][leader-lib-doc] if you wish:

```go
func main() {
Expand Down Expand Up @@ -283,7 +283,7 @@ func main() {
}
```

- Ensure that you copy all customizations made in `cmd/manager/main.go` to `main.go`. You’ll also need to ensure that all needed schemes have been registered, if you have been using third-party API's (i.e Route Api from OpenShift).
- Ensure that you copy all customizations made in `cmd/manager/main.go` to `main.go`. You’ll also need to ensure that all needed schemes have been registered, if you have been using third-party APIs (i.e Route Api from OpenShift).

### Migrate your tests

Expand All @@ -297,19 +297,19 @@ To learn more about how you can test your controllers, see the documentation abo

### Migrate your Custom Resources

Custom resource samples are stored in `./config/samples` in the new project structure. Copy the examples from your existing project into this directory. In existing projects, CR files have the format `./deploy/crds/<group>.<domain>_<version>_<kind>_cr.yaml`.
Custom resource samples are stored in `./config/samples` using the new project structure. Copy the examples from your existing project into this directory. In existing projects, CR files have the format `./deploy/crds/<group>.<domain>_<version>_<kind>_cr.yaml`.

In our example, we'll copy the specs from `deploy/crds/cache.example.com_v1alpha1_memcached_cr.yaml`
to `config/samples/cache_v1alpha1_memcached.yaml`

### Configure your Operator

In case your project has customizations in the `deploy/operator.yaml` then, it needs to be port to
`config/manager/manager.yaml`. Note that, `OPERATOR_NAME` and `POD_NAME` env vars are no longer used. For further information came back to the section [Migrate `main.go` ][migration-guide-main-section].
In case your project has customizations in the `deploy/operator.yaml`, it needs to be added to
`config/manager/manager.yaml`. Note that `OPERATOR_NAME` and `POD_NAME` env vars are no longer used. For further information, check out the section [Migrate `main.go` ][migration-guide-main-section].

### Export Metrics

If you are using metrics and would like to keep them exported, see that the `func addMetrics()` is no longer generated in the `main.go` and it is now configurable via [kustomize][kustomize]. Following the steps.
If you are using metrics and would like to keep them exported, see that the `func addMetrics()` is no longer generated in the `main.go` and it is now configurable via [kustomize][kustomize].

#### Configure Prometheus metrics

Expand All @@ -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 able to export metrics from your Custom Resources. In our example, it would 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 @@ -363,15 +363,15 @@ In this way, the following metric with the resource info will be exported:
resource_created_at_seconds{"name", "namespace", "group", "version", "kind"}
```

**Note:** To check it you can create a pod to curl the `metrics/` endpoint but note that it is now protected by the [kube-auth-proxy][kube-auth-proxy] which means that you will need to create a `ClusterRoleBinding` and obtained the token from the ServiceAccount's secret which will be used in the requests. Otherwise, to test you can disable the [kube-auth-proxy][kube-auth-proxy] as well.
**Note:** To check it you can create a pod to curl the `metrics/` endpoint but note that it is now protected by the [kube-auth-proxy][kube-auth-proxy] which means that you will need to create a `ClusterRoleBinding` and obtain the token from the ServiceAccount's secret which will be used in the requests. Otherwise, to test you can disable the [kube-auth-proxy][kube-auth-proxy] as well.

For more info see the [metrics][metrics].

### Operator image

The Dockerfile image also changes and now it is a `multi-stage`, `distroless` and still been `rootless`, however, users can change it to work as however they want.
The Dockerfile image also changes and now it is `multi-stage`, `distroless` and still `rootless`. However, users can change it to work as they want.

See that, you might need to port some customizations made in your old Dockerfile as well. Also, if you wish to still using the previous UBI image replace:
You might need to port some customizations made in your old Dockerfile as well. Also, if you wish to still use the previous UBI image replace:

```docker
# Use distroless as minimal base image to package the manager binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This guide walks through an example of building a simple memcached-operator usin
## Prerequisites

- Go through the [installation guide][install-guide].
- User authorized with `cluster-admin` permissions.
- Make sure your user is authorized with `cluster-admin` permissions.
- An accessible image registry for various operator images (ex. [hub.docker.com](https://hub.docker.com/signup),
[quay.io](https://quay.io/)) and be logged in your command line environment.
[quay.io](https://quay.io/)) and be logged in to your command line environment.
- `example.com` is used as the registry Docker Hub namespace in these examples.
Replace it with another value if using a different registry or namespace.
- [Authentication and certificates][image-reg-config] if the registry is private or uses a custom CA.
Expand Down Expand Up @@ -118,7 +118,7 @@ This is recommended ONLY for development purposes

## Next Steps

Read the [full tutorial][tutorial] for an in-depth walkthough of building a Go operator.
Read the [full tutorial][tutorial] for an in-depth walkthrough of building a Go operator.


[install-guide]:/docs/building-operators/golang/installation
Expand Down
Loading

0 comments on commit 62cbecc

Please sign in to comment.