Skip to content

Instantly share code, notes, and snippets.

@l0rd
Last active April 17, 2017 21:02
Show Gist options
  • Save l0rd/562f1814f17157469ccd964f320a5be4 to your computer and use it in GitHub Desktop.
Save l0rd/562f1814f17157469ccd964f320a5be4 to your computer and use it in GitHub Desktop.
Instructions to run Che on OpenShift

How to run Che on OpenShift

Using minishift

The following instructions has been tested with minishift v1.0.0.beta4

minishift start

Set environment variables (or run scripts/setenv.sh)

eval $(minishift docker-env)
export OPENSHIFT_USERNAME="developer"
export OPENSHIFT_PASSWORD="developer"
export CHE_OPENSHIFT_PROJECT="eclipse-che"
export CHE_HOSTNAME="che.$(minishift ip).nip.io"
export CHE_OPENSHIFT_SERVICE_ACCOUNT="che"
export CHE_LOG_LEVEL="INFO"
export CHE_DEBUGGING_ENABLED="false"

Create Che project (or run scripts/createserverproject.sh)

oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}
oc new-project ${CHE_OPENSHIFT_PROJECT}

Deploy Che (or run scripts/deploy.sh)

oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}

# Deploy configmaps
oc create configmap che \
      --from-literal=hostname-http=${CHE_HOSTNAME} \
      --from-literal=workspace-storage="/home/user/che/workspaces" \
      --from-literal=workspace-storage-create-folders="false" \
      --from-literal=local-conf-dir="/etc/conf" \
      --from-literal=openshift-serviceaccountname=${CHE_OPENSHIFT_SERVICE_ACCOUNT} \
      --from-literal=che-server-evaluation-strategy="single-port" \
      --from-literal=log-level=${CHE_LOG_LEVEL} \
      --from-literal=docker-connector="openshift" \
      --from-literal=port="8080" \
      --from-literal=remote-debugging-enabled=${CHE_DEBUGGING_ENABLED} 

# Deploy PVs (gofabric8 way)
#   gofabric8 should be installed:
#   https://github.com/fabric8io/gofabric8#getting-started
#oc apply -f fabric8-online/apps/che/src/main/fabric8/config-pvc.yml
#oc apply -f fabric8-online/apps/che/src/main/fabric8/data-pvc.yml
#oc apply -f fabric8-online/apps/che/src/main/fabric8/workspace-pvc.yml
#oc login -u system:admin -n ${CHE_OPENSHIFT_PROJECT}
#gofabric8 volumes
#oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}

# Deploy PVs (template way)
oc login -u system:admin -n ${CHE_OPENSHIFT_PROJECT}
oc apply -f os-templates/hostPath/pvconf.yaml
oc apply -f os-templates/hostPath/pvdata.yaml
oc apply -f os-templates/hostPath/pvworkspace.yaml
oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}
oc apply -f fabric8-online/apps/che/src/main/fabric8/config-pvc.yml
oc apply -f fabric8-online/apps/che/src/main/fabric8/data-pvc.yml
oc apply -f fabric8-online/apps/che/src/main/fabric8/workspace-pvc.yml

# Create and configure service account
oc create serviceaccount ${CHE_OPENSHIFT_SERVICE_ACCOUNT}
oc login -u system:admin -n ${CHE_OPENSHIFT_PROJECT}
oadm policy add-role-to-user -n ${CHE_OPENSHIFT_PROJECT} edit system:serviceaccount:${CHE_OPENSHIFT_PROJECT}:${CHE_OPENSHIFT_SERVICE_ACCOUNT}
oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}

#Deploy Che server
echo "apiVersion: \"v1\"
kind: \"DeploymentConfig\"
metadata:
  name: \"che\"
$(cat fabric8-online/apps/che/src/main/fabric8/deployment.yml)
" | oc apply -f -

#Create Che service

#Create Che route

Uninstall everything

oc delete serviceaccount ${CHE_OPENSHIFT_SERVICE_ACCOUNT}

oc login -u system:admin -n ${CHE_OPENSHIFT_PROJECT} 
oc delete pv --all -n ${CHE_OPENSHIFT_PROJECT}
oc delete pvc --all -n ${CHE_OPENSHIFT_PROJECT} 
oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}

oc login -u ${OPENSHIFT_USERNAME} -p ${OPENSHIFT_PASSWORD} -n ${CHE_OPENSHIFT_PROJECT}
oc delete configmap che
@apitt
Copy link

apitt commented Apr 17, 2017

Hi,

I'm trying to run this, but running into a few problems.

Where do you get the files refered to here?
os-templates/hostPath/...
fabric8-online/apps/che/src/main/fabric8/...

Also, I have the "oc" binary (through minishift), but not "oadm". Is that a separate binary I can find somewhere, or is that a convenience alias you have added to your profile (instead of "oc adm")?

I'm really interested in getting this running on OpenShift (without having to install fabric8).

Thanks in advance for any guidance you can offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment