In this lab, we will be deploying Launcher in single user mode. Eventually an Operator is being created to install launcher in multi-user mode.
- A running OpenShift Cluster and cluster admin access
- A workstation with
oc
CLI - You have already installed CodeReady Workspaces on your cluster as explained here
Note the name of the Realm from Realm Settings
. This is codeready
.
Shift over to the Clients
in the left menu and view the list of clients. We are specifically interested in the client with ClientId codeready-public
Use oc login
to log onto your OpenShift cluster
Run the following script to install the Launcher. This script will create a project named "Launch" and install launcher based on a template.
Note : In the future, this will be replaced by an operator.
curl -s https://raw.githubusercontent.com/VeerMuchandi/CodeReadyWorkspacesAndLauncherTutorial/master/launcherInstall.sh | bash
and watch for the output as shown below
$ curl -s https://raw.githubusercontent.com/VeerMuchandi/CodeReadyWorkspacesAndLauncherTutorial/master/launcherInstall.sh | bash
This script will install the Launcher on OpenShift cluster. Make sure that:
- You have run oc login previously
Press ENTER to continue ...
Creating launch project ...
Already on project "launch" on server "https://master.311.ocpcloud.com:443".
You can add applications to this project with the 'new-app' command. For example, try:
oc new-app centos/ruby-22-centos7~https://github.com/openshift/ruby-ex.git
to build a new example application in Ruby.
Processing the template and installing ...
configmap "launcher" created
configmap "launcher-clusters" created
deploymentconfig.apps.openshift.io "launcher-backend" created
service "launcher-backend" created
deploymentconfig.apps.openshift.io "launcher-creator-backend" created
service "launcher-creator-backend" created
deploymentconfig.apps.openshift.io "launcher-frontend" created
service "launcher-frontend" created
serviceaccount "configmapcontroller" created
rolebinding.authorization.openshift.io "configmapcontroller" created
deploymentconfig.apps.openshift.io "configmapcontroller" created
route.route.openshift.io "launcher" created
secret "launcher" created
Enabling Launcher Creator
deploymentconfig "launcher-frontend" updated
configmap "launcher" replaced
All set! Enjoy!
Wait for a few mins for all the pods to come up.
$ oc get po
NAME READY STATUS RESTARTS AGE
configmapcontroller-1-fkk5g 1/1 Running 0 1m
launcher-backend-2-deploy 1/1 Running 0 1m
launcher-backend-2-h4w42 0/1 Running 0 55s
launcher-creator-backend-2-z4tqk 1/1 Running 0 53s
launcher-frontend-3-xnjrd 1/1 Running 0 39s
Check the route for the launcher
$ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
launcher launcher-launch.apps.311.ocpcloud.com launcher-frontend <all> None
We will be using GitHub as the source control for our code here.
-
Login to GitHub
-
Add the following field values:
Application Name:
Launcher
or a name of your choice Home Page URL:http://localhost
Authorization CallbackURL: usehttp://localhost
for now and we will update this a little later -
Click on
Register Application
-
Note the values of
Client ID
andClient Secret
as they will be required in the next step to configure Keycloak
Navigate back to Keycloak server and select Clients from the left menu. Select codeready-public
client.
- Add all requests from Launcher URL i.e,
*
to theValid Redirect URIs
. As an example in the above case it ishttp://launcher-launch.apps.311.ocpcloud.com/*
- Also add Launcher URL to
Web Origins
. In the above case it ishttp://launcher-launch.apps.311.ocpcloud.com
Save the changes by clicking Save
button at the bottom.
-
Navigate to Identity Providers menu option on the left
-
Click on
Add Provider
on the right and choosegithub
provider -
Configure
github
provider as shown below:Client Id: Use the value noted while configuring Oauth on GitHub Client Secret: Use the value noted while configuring Oauth on GitHub Default Scopes:
admin:repo_hook,read:org,public_repo
Store Tokens:ON
Store Tokens Readable:ON
Enabled:ON
Trust Email:ON
Hide on Login Page:ON
First Login Flow: selectfirst broker login
and Click on Save
- Note the value of
Redirect URI
- Go back to GitHub, Login if you are not already in
Settings
>>Developer Settings
>>OAuth Apps
>>launcher
(or the name that you provided earlier)- Update the Authorization callback URL to the value noted from
Redirect URI
earlier
- Log into the OpenShift cluster as an administrator
- Create an OAuthClient.
- I am calling it
keycloak-client
as shown below. - Change the
secret
value to your own value - set the
redirect URIs
to your Keycloak server route followed by/auth
. As an example in my case it is"http://keycloak-wrkspc.apps.311.ocpcloud.com/auth"
- Run the command to create the OAuthClient
- I am calling it
oc create -f <(echo '
kind: OAuthClient
apiVersion: v1
metadata:
name: keycloak-client
secret: "SUBSTITUTE_YOUR_VALUE"
redirectURIs:
- "http://YOUR_KEYCLOAK_ROUTE/auth"
grantMethod: prompt
')
-
Now navigate back to
Identity Providers
menu on KeyCloak Server -
Click on
Add Provider
on the right and chooseopenshift-v3
provider -
Configure
Openshift v3
provider as shown below:Client Id:
keycloak-client
or the name of of the OAuthClient if you changed it Client Secret: Use your secret value used while creating OAuthClient on OpenShift Base URL:Your OpenShift Master URL
Default Scopes:user:full
Store Tokens:ON
Store Tokens Readable:ON
Enabled:ON
Trust Email:ON
Hide on Login Page:ON
First Login Flow: selectbrowser
and Click on Save
You'll have to repeat this for every user that will be using Launcher. If you add new users in the future, don't forget to repeat this step
- Navigate to
Users
in the menu on the left. You will find the list of users. - You can add new users to this realm here if there are none
Note: Currently CodeReady workspaces is not integrated with OpenShift Authentication. Hence Launcher also doesn't use OpenShift credentials. Launcher will use CodeReady credentials. Eventually once CodeReady workspaces is configured to use OpenShift authentication, we will use same credentials for OpenShift, CodeReady and Launcher.
- Select a user and
Edit
- Navigate to
Role Mappings
tab - Select
broker
from the Client roles drop down. Addread-token
to Assigned Roles by clicking on theAdd selected >>
button
Repeat the above steps for all the users who will be using Launcher.
- Test the route to make sure Launcher is running and you see the following screen.
- Click on
Login
on the top right corner. This will take you to CodeReady Workspaces login page via the Keycloak server. Login with the end user credentials. - Now it will be back to the Launcher page with the user name displayed on the top right corner.
- At this point launcher is ready to use.
In this lab we have learnt to
- Install Launcher
- Integrate Launcher with the Keycloak Server
- Integrate with Github
- Enable users in the Keycloak realm to use Launcher