/launcher-operator

This operator helps enabling the Launcher on an Openshift cluster.

Primary LanguageGo

Launcher Operator

This operator helps enabling the Launcher on an Openshift cluster.

Give cluster admin permissions to the user <user>

The user needs cluster-admin permissions to install the Launcher operator

$ oc adm policy --as system:admin add-cluster-role-to-user cluster-admin <user>

Create a namespace / project where to create the launcher

Install the Launcher operator

Login with the OpenShift client using a user with cluster-admin permissions.

$ oc login

Clone this repository:

$ git clone https://github.com/fabric8-launcher/launcher-operator
$ cd launcher-operator

Choose the project that will run the operator and then install all the operator resources, or create a new project:

$ oc new-project launcher-infra

Install the Launcher operator

$ oc create -R -f ./deploy

Install the Launcher (via the installed operator)

  1. Log into GitHub and create a OAuth Application for the Launcher named 'launcher': -- https://github.com/settings/applications/new

    • Using http://temporary as 'Homepage URL' an 'Authorization callback URL' (You will know the frontend url later)
  2. Create a secret for your GitHub Oauth settings

$ oc create secret generic launcher-oauth-github --from-literal=clientId=<YOUR_GITHUB_OAUTH_APP_CLIENT_ID> --from-literal=secret=<YOUR_GITHUB_OAUTH_APP_CLIENT_SECRET>
  1. Customize the Launcher Resource with your OpenShift Console URL and create it
$ oc create -f example/launcher_cr.yaml
  1. Get the Launcher URL:
$ oc get route launcher --template={{.spec.host}}
  1. Create a OAuth client in OpenShift:
$ cat <<EOF | oc create -f -
kind: OAuthClient
apiVersion: oauth.openshift.io/v1
metadata:
  name: launcher
secret: my-secret-password
redirectURIs:
  - "https://$(oc get route launcher --template={{.spec.host}})"
grantMethod: prompt
EOF
  1. Edit you GitHub OAuth application, created in step 1, and set both the 'Homepage URL' and 'Authorization callback URL' to the launcher frontend URL, retrieved in step 4.

Example Launcher CR

Find an example of the Launcher CR in example/launcher_cr.yaml


Develop

Install the operator-sdk using the instructions.

Register the crd:

$ oc create -f deploy/crds/launcher_v1alpha2_launcher_crd.yaml  

Install dependencies:

$ dep ensure -v

Start the operator (just restart this command to apply your changes):

operator-sdk up local --namespace myproject

Run this command when changing the API types (pkg/apis/launcher/v1alpha2/launcher_types.go)

operator-sdk generate k8s

Then create your launcher CR and watch the logs in the console output.

Update the launcher template to the latest version from GitHub

$ ./update-template.sh

Build and push the operator to registry

$ operator-sdk build fabric8/launcher-operator:vX.Y.Z
$ docker push fabric8/launcher-operator:vX.Y.Z

Update the version in the operator yaml file and push it.