toolchain-operator

module
v0.0.0-...-732e647 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2020 License: Apache-2.0

README

= CodeReady Toolchain Operator

image:https://goreportcard.com/badge/github.com/codeready-toolchain/toolchain-operator[Go Report Card, link="https://goreportcard.com/report/github.com/codeready-toolchain/toolchain-operator"]
image:https://godoc.org/github.com/codeready-toolchain/toolchain-operator?status.png[GoDoc,link="https://godoc.org/github.com/codeready-toolchain/toolchain-operator"]
image:https://codecov.io/gh/codeready-toolchain/toolchain-operator/branch/master/graph/badge.svg[Codecov.io,link="https://codecov.io/gh/codeready-toolchain/toolchain-operator"]
image:https://travis-ci.org/codeready-toolchain/toolchain-operator.svg?branch=master["CD Build Status", link="https://travis-ci.org/codeready-toolchain/toolchain-operator"]
image:https://quay.io/repository/codeready-toolchain/toolchain-operator/status["Docker Repository on Quay", link="https://quay.io/repository/codeready-toolchain/toolchain-operator"]

== Build

Requires Go version 1.13 - download for your development environment https://golang.org/dl/[here].

This repository uses https://github.com/golang/go/wiki/Modules[Go modules]. You may need to `export GO111MODULE=on` to turn modules support "on".

== Development

To run this operator locally you need to have at least one Minishift profile started:

```bash
$ minishift start
```

Then you can run the operator locally with the help of `operator-sdk` (you need version v0.10.0 or higher):

```bash
$ make up-local
```

That Makefile target takes care of additional several steps which can be executed separately:

* logging as system:admin user: `$ make login-as-admin`
* creating local test namespace: `$ make create-namespace`
* deploy CRDs: `$ make deploy-crd`
* building the project: `$ make build`
* deploying ClusterRole/ClusterRoleBinding and creating ServiceAccount: `$ make deploy-rbac`

There are a few more targets that you can find useful:

* to login as system:admin user and enter the local test namespace: `$ make use-namespace`
* to remove the local test namespace: `$ make clean-namespace`
* to remove & create the local test namespace, and create ClusterRole/ClusterRoleBinding and ServiceAccount inside of the namespace: `$ make reset-namespace`


=== End-to-End tests
==== OpenShift 4.2+ 

* Make sure you have set the `KUBECONFIG` variable: `export KUBECONFIG=<kubeconfig>` 

* Make sure you have set the `QUAY_NAMESPACE` variable: `export QUAY_NAMESPACE=<quay-username>`

* Log in to the quay.io using `docker login quay.io`

* Make sure that the visibility of the repositories toolchain-operator in quay is set to public (https://quay.io/repository/<your-username>/toolchain-operator?tab=settings)

* Run the make target for executing end-to-end tests: `make test-e2e`

=== Verifying the OpenShift CI configuration

 It's possible to verify the OpenShift CI config from the developer's laptop while all the jobs are executed on the remote, online CI platform:

1. checkout and build the https://github.com/openshift/ci-tools[CI Operator] command line tool
2. login to https://console.svc.ci.openshift.org (via GH OAuth) and copy the login command (you may need to switch to the `application console`)
3. login with the command aferementioned
4. run the CI jobs with
+
```
ci-operator --config ../../openshift/release/ci-operator/config/codeready-toolchain/toolchain-operator/codeready-toolchain-toolchain-operator-master.yaml --git-ref=codeready-toolchain/toolchain-operator@master
```

assuming that the https://github.com/openshift/release[OpenShift Release] repo was checked you.

NOTE: you can ignore the RBAC issues that are displayed in the console


=== Releasing a new version of toolchain-operator

All released operator bundles are stored in the link:./manifests/[manifests/] directory. The already released versions shouldn't be changed.
There are multiple makefile targets that will help you with releasing a new version of toolchain-operator - to see them go to link:./make/manifests.mk[manifests.mk].

==== Prerequisites

* having https://github.com/operator-framework/operator-courier[operator-courier] installed
* having https://github.com/operator-framework/operator-sdk[operator-sdk] of version v0.17.1 installed
* clone https://github.com/operator-framework/community-operators[community-operators] repo in `${GOPATH}/src/github.com/operator-framework/community-operators`


==== Steps

===== 1. Create release manifest
First of all, you need to create a new release - go to the link:./make/manifests.mk[manifests.mk] and check the `CSV_VERSION_TO_GENERATE` variable if it matches your required version.
If it does then run `make create-release-manifest` - it will create a new release manifest within link:./manifests/[manifests/] directory.

===== 2. Test the release manifest
Verify the created manifest, if it contains everything that would you expect, then you can also verify the installation and upgrade directly in your dev cluster.
To do that run `make add-release-manifests-to-os` - it will deploy manifests into your cluster, so you can install the operator.
If you want to also test the upgrade, create a subscription with the `startingCSV` equal to some of the previous releases - eq. run:
```yaml
cat <<EOF | oc apply -f -
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
  name: subscription-codeready-toolchain-operator
  namespace: openshift-operators
spec:
  channel: alpha
  installPlanApproval: Automatic
  name: codeready-toolchain-operator
  source: source-codeready-toolchain-operator
  sourceNamespace: openshift-marketplace
  startingCSV: codeready-toolchain-operator.v0.1.0
EOF
```
To delete the CSVs from the cluster, you can run `make delete-release-manifest-from-os`.

If you want to also try to install it from the quay.io using the `OperatorSource` you can push the bundle into your quay namespace using `make push-latest-release-manifest`
Note: You must `export QUAY_NAMESPACE=<your quay namespace>` before running the script. If you get authorization errors when trying to push the release to quay, you may need to https://github.com/operator-framework/community-operators/blob/master/docs/testing-operators.md#quay-login[retrieve and set the quay token manually] and make the repository public.

===== 3. Create PR in community-operators
As soon as you verify that the release is working correctly, you can create a PR with a new release in https://github.com/operator-framework/community-operators[community-operators] repo.
To copy the manifests to the repo use `make copy-manifests-to-community-operators` and then create a PR there. Please follow the instructions that are written in the template of the PR description.

===== 4. Prepare for the next release
Increment the `CSV_VERSION_TO_GENERATE` variable in the link:./make/manifests.mk[manifests.mk] file to the next expected version.

===== 5. Open PR in toolchain-operator
Open also a PR with the manifests (and all other changes) inside of the toolchain-operator repository.

===== 6. Wait for community-operators PR to be merged
Once the PR in community-operators repo is merged, then the release will be available in Operator Hub.
So, merge the PR in toolchain-operator repo and verify the new release in your dev cluster.

Directories

Path Synopsis
cmd
pkg
apis/toolchain
Package toolchain contains toolchain API versions.
Package toolchain contains toolchain API versions.
apis/toolchain/v1alpha1
Package v1alpha1 contains API Schema definitions for the toolchain v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=toolchain.openshift.dev Package v1alpha1 contains API Schema definitions for the toolchain v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=toolchain.openshift.dev
Package v1alpha1 contains API Schema definitions for the toolchain v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=toolchain.openshift.dev Package v1alpha1 contains API Schema definitions for the toolchain v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=toolchain.openshift.dev

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL