Go to file
Nick Boldt fbe3c1fd19
CRW-563 improve generation of digests from tags in registries and operator (#206)
* implement overwriting csv with generated digests and related images; add tags as comments into sources too; support a quieter console mode; if podman not installed fall back to docker

Change-Id: I47da5adc3db79e64bd595179223a5fee9635343f
Signed-off-by: nickboldt <nboldt@redhat.com>

* do not use dockerContainerExtract.sh -- not required; support a quieter console mode; if podman not installed fall back to docker; allow secondary level of skopeo inspection (for Brew images not yet in RHCC or any other additional parsing rules)

Change-Id: I33fb68842b41f361d638ba20696eabebf9b8efde
Signed-off-by: nickboldt <nboldt@redhat.com>

* if podman not installed fall back to docker; slighly noisier console ouptu while pulling images (long operation)

Change-Id: I7ea9db2baab32ed03cef71aa7aac6c80a95d6850
Signed-off-by: nickboldt <nboldt@redhat.com>

* in case we already have digests in the csv for the registries, replace them with :VERSION tag (so we can rebuild Brew stuff for Quay)

Change-Id: I973f0433fedbbda49235da20229ea982c91e53f4
Signed-off-by: nickboldt <nboldt@redhat.com>
2020-03-26 10:43:12 +02:00
.ci Fix olm minishift installation (#211) 2020-03-26 09:02:25 +02:00
.github Add Anatolii (@tolusha) as code owner 2020-01-13 13:40:03 -05:00
.vscode Improve debug configuration. Add debug binary to .gitignore (#183) 2020-03-04 10:30:42 +02:00
build Duplicate Dockerfile in the build directory (#204) 2020-03-20 13:41:52 +02:00
cmd/manager Enable to debug operator locally (#182) 2020-03-02 14:10:05 +02:00
deploy Store credentials into secrets instead of plain text of CheCluster CR fields (#198) 2020-03-25 09:57:36 +02:00
e2e Add logger to the e2e automation script locally 2020-01-30 16:17:05 +01:00
olm CRW-563 improve generation of digests from tags in registries and operator (#206) 2020-03-26 10:43:12 +02:00
pkg Add error status if operator hasn't got permission to count users. (#208) 2020-03-25 17:01:37 +02:00
templates Fix the Openshift OAuth provisioning for CRW, and move provisioning files (#122) 2019-11-15 11:40:40 +01:00
vendor Update vendor 2019-09-09 13:27:23 +03:00
version Update to 0.5.0. Use CRDs 2019-03-20 09:33:06 +02:00
.dockerignore Add tmp to dockerignore 2019-04-05 18:06:27 +03:00
.gitignore Improve debug configuration. Add debug binary to .gitignore (#183) 2020-03-04 10:30:42 +02:00
Dockerfile Added support for s390x (#203) 2020-03-23 09:20:23 +02:00
Gopkg.lock Update vendor 2019-09-09 13:27:23 +03:00
Gopkg.toml Add dependency on openshift/api 4.2 2019-09-05 11:25:06 +03:00
LICENSE Adding EPL 2.0 LICENSE file 2020-02-24 11:17:49 +01:00
README.md Fix the Openshift OAuth provisioning for CRW, and move provisioning files (#122) 2019-11-15 11:40:40 +01:00
RELEASE.md Update RELEASE.md (#196) 2020-03-16 14:48:45 +02:00
build_deploy_local.sh check script parameter 2019-11-11 09:23:28 +01:00
cico_build_nightly.sh rh-che #1499: Adding scripts for setting up nightly CI for che-operator 2019-08-14 12:03:15 +02:00
cico_functions.sh rh-che #1499: Adding scripts for setting up nightly CI for che-operator 2019-08-14 12:03:15 +02:00
deploy.sh Rename json tags. Update upstream image tag. Remove CRW olm yamls (#13) 2019-04-13 09:03:46 +03:00
local-debug.sh Support single-user mode (#185) 2020-03-17 09:29:53 +02:00
make-release.sh Release 7.10.0 (#195) 2020-03-16 13:49:39 +02:00
release-operator-code.sh feat: Remove image refs in `defaults.go` and replace by env vars (#172) 2020-02-18 10:17:21 +02:00

README.md

Che/CodeReady Workspaces Operator

Che/CodeReady workspaces operator uses Operator SDK and Go Kube client to deploy, update and manage K8S/OpenShift resources that constitute a multi user Eclipse Che/CodeReady Workspaces cluster.

The operator watches for a Custom Resource of Kind CheCluster, and operator controller executes its business logic when a new Che object is created, namely:

  • creates k8s/OpenShift objects
  • verifies successful deployment of Postgres, Keycloak and Che
  • runs exec into Postgres and Keycloak pods to provisions databases, users, realm and clients
  • updates CR spec and status (passwords, URLs, provisioning statuses etc.)
  • continuously watches CR, update Che ConfigMap accordingly and schedule a new Che deployment
  • changes state of certain objects depending on CR fields:
    • turn on/off TLS mode (reconfigure routes, update ConfigMap)
    • turn on/off OpenShift oAuth (login with OpenShift in Che) (create identity provider, oAuth client, update Che ConfigMap)
  • updates Che deployment with a new image:tag when a new operator version brings in a new Che tag

Project State: Beta

The project is in its early development and breaking changes are possible.

How to Deploy

IMPORTANT! Cluster Admin privileges are required

./deploy.sh $namespace

The script will create sa, role, role binding, operator deployment, CRD and CR.

Wait until Che deployment is scaled to 1 and Che route is created.

When on pure k8s, make sure you provide a global ingress domain in deploy/crds/org_v1_che_cr.yaml for example:

  k8s:
    ingressDomain: '192.168.99.101.nip.io'

OpenShift oAuth

Bear in mind that che-operator service account needs to have cluster admin privileges so that the operator can create oauthclient at a cluster scope. There is oc adm command in both deploy scripts. Uncomment it if you need this feature. Make sure your current user has cluster-admin privileges.

TLS

OpenShift

When using self-signed certificates make sure you set server.selfSignedCert to true or create a secret called self-signed-certificate in a target namespace with ca.crt holding your OpenShift router crt body. When server.selfSignedCert the operator will create a test TLS route, GET it, extract certificate chain, convert to a secret self-signed-certificate, and Che/CRW server will automatically add it to Java trust store.

K8S

When enabling TLS, make sure you create a secret with crt and key, and let the Operator know about it in k8s.tlsSecretName

How to Configure

The operator watches all objects it creates and reconciles them with CR state. It means that if you edit a configMap che, the operator will revert changes. Since not all Che configuration properties are custom resource spec fields (there are simply too many of them), the operator creates a second configMap called custom which you can use for any environment variables not supported by CR field. The operator will not reconcile configMap custom.

How to Build Operator Image

docker build -t $registry/$repo:$tag .

You can then use the resulting image in operator deployment (deploy/operator.yaml)

Build and Deploy to a local cluster:

There's a little script that will build a local Docker image and deploy an operator to a selected namespace, as well as create service account, role, role binding, CRD and example CR.

oc new-project $namespace
build_deploy_local.sh $namespace

The above method will work only with Docker 17.x (does not works if you want to build in MiniShift/MiniKube). Mostly useful if you run oc cluster up locally.

How to Run/Debug Locally

You can run/debug this operator on your local machine (not deployed to a k8s cluster), provided that the below pre-reqs are met.

Pre-Reqs: Local kubeconfig

Go client grabs kubeconfig either from InClusterConfig or ~/.kube locally. Make sure you oc login (or your current kubectl context points to a target cluster and namespace), and current user/server account can create objects in a target namespace.

Pre-Reqs: WATCH_NAMESPACE Environment Variable

The operator detects namespace to watch by getting value of WATCH_NAMESPACE environment variable. You can set it in Run configuration in the IDE, or export this env before executing the binary.

This applies both to Run and Debug.

Pre-Reqs: /tmp/keycloak_provision and oauth_provision files

The Operator takes these files and replaces values to get a string used as the exec command to configure Keycloak. Make sure you run the following before running/debugging:

cp templates/keycloak_provision /tmp/keycloak_provision
cp templates/oauth_provision /tmp/oauth_provision

These files are added to a container image, and thus this step is not required when deploying an Operator image.

E2E Tests

e2e directory contains end-to-end tests that create a custom resource, operator deployment, required RBAC.

Pre-reqs to run end-to-end (e2e) tests:

  • a running OpenShift instance (3.11+)
  • current oc/kubectl context as a cluster admin user

How to build tests binary

OOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o $GOPATH/src/github.com/eclipse/che-operator/run-tests $GOPATH/src/github.com/eclipse/che-operator/e2e/*.go

Or you can build in a container:

docker run -ti -v /tmp:/tmp -v ${OPERATOR_REPO}:/opt/app-root/src/go/src/github.com/eclipse/che-operator registry.redhat.io/devtools/go-toolset-rhel7:1.11.5-3 sh -c "OOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /tmp/run-tests /opt/app-root/src/go/src/github.com/eclipse/che-operator/e2e/*.go"
cp /tmp/run-tests ${OPERATOR_REPO}/run-tests

How to run tests

The resulted binary is created in the root of the repo. Make sure it is run from this location since it uses relative paths to yamls that are then deserialized. There's a script run-okd-local.sh which is more of a CI thing, however, if you can run oc cluster up in your environment, you are unlikely to have any issues.

./run-tests

Tests create a number of k8s/OpenShift objects and generally assume that a fresh installation of OpenShift is available. TODO: handle AlreadyExists errors to either remove che namespace or create a new one with a unique name.

What do tests check?

Installation of Che/CRW

A custom resource is created, which signals the operator to deploy Che/CRW with default settings.

Configuration changes in runtime

Once an successful installation of Che/CRW is verified, tests patch custom resource to:

  • enable oAuth
  • enable TLS mode

Subsequent checks verify that the installation is reconfigured, for example uses secure routes or ConfigMap has the right Login-with-OpenShift values

TODO: add more scenarios