Skip to content

Commit

Permalink
Update contributing guide (open-telemetry#537)
Browse files Browse the repository at this point in the history
* Update contributing guide

Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay authored Nov 15, 2021
1 parent cf2e7e1 commit 07cbab2
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ gh pr create
### Pre-requisites
* Install [Go](https://golang.org/doc/install).
* Install [Kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/).
* Install [Operator SDK](https://sdk.operatorframework.io/docs/installation/).
* Have a Kubernetes cluster ready for development. We recommend `minikube` or `kind`.

### Adding new components - webhook, API

The repository structure MUST be compliant with `operator-sdk` scaffolding, which uses `kubebuilder` behind the scenes. This is to ensure a valid bundle generation and it makes it easy to maintain the project and add new components.

Refer to the [Operator SDK documentation](https://sdk.operatorframework.io/docs/building-operators/golang/) how to generate new APIs, Webhook and other parts of the project.

### Local run

Expand All @@ -40,41 +46,39 @@ When running `make run`, the webhooks aren't effective as it starts the manager
1. configure a proxy between the Kubernetes API server and your host, so that it can contact the webhook in your local machine
1. create the TLS certificates and place them, by default, on `/tmp/k8s-webhook-server/serving-certs/tls.crt`. The Kubernetes API server has also to be configured to trust the CA used to generate those certs.

In general, it's just easier to deploy the manager in a Kubernetes cluster instead. For that, you'll need the `cert-manager` installed. You can install it by running:
In general, it's just easier to deploy the operator in a Kubernetes cluster instead. For that, you'll need the `cert-manager` installed. You can install it by running:

```bash
make cert-manager
```

In pursuit of continuous improvement, a variable named `CERTMANAGER_VERSION` which can be run:
The environment variable `CERTMANAGER_VERSION` can be used to override the cert-manager version:
```bash
CERTMANAGER_VERSION=1.60 make cert-manager
```

By default, it will generate an image following the format `quay.io/${USER}/opentelemetry-operator:${VERSION}`. You can set the following env vars in front of the `make` command to override parts or the entirety of the image:
When deploying the operator into the cluster using `make deploy`, an image in the format `ghcr.io/${USER}/opentelemetry-operator` is generated. If this format isn't suitable, it can be overridden by:

* `IMG_PREFIX`, to override the registry, namespace and image name (`quay.io`)
* `IMG_PREFIX`, to override the registry, namespace and image name
* `USER`, to override the namespace
* `IMG_REPO`, to override the repository (`opentelemetry-operator`)
* `VERSION`, to override only the version part
* `IMG`, to override the entire image specification

Ensure the secret [regcred](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) has been created to enable opentelemetry-operator-controller-manager deployment to pull images from your private `quay.io` registry.

```bash
kubectl create secret docker-registry regcred --docker-server=quay.io --docker-username=${USER} --docker-password=${PASSWORD} -n opentelemetry-operator-system
IMG=docker.io/${USER}/opentelemetry-operator:latest make generate bundle container container-push deploy
```

Alternatively, you could create your repository with [Public Visibility](https://docs.projectquay.io/use_quay.html#creating-an-image-repository-via-the-ui).
Your operator will be available in the `opentelemetry-operator-system` namespace.

Once it's ready, the following can be used to build and deploy a manager, along with the required webhook configuration:
#### Using a private container registry

Ensure the secret [regcred](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) has been created to enable opentelemetry-operator-controller-manager deployment to pull images from your private registry.

```bash
make bundle container container-push deploy
kubectl create secret docker-registry regcred --docker-server=<registry> --docker-username=${USER} --docker-password=${PASSWORD} -n opentelemetry-operator-system
```

Your operator will be available in the `opentelemetry-operator-system` namespace.

## Testing

With an existing cluster (such as `minikube`), run:
Expand Down

0 comments on commit 07cbab2

Please sign in to comment.