Skip to content

Instantly share code, notes, and snippets.

@nickboldt
Last active August 21, 2020 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickboldt/bc53f34577719fd08d572383f7d06118 to your computer and use it in GitHub Desktop.
Save nickboldt/bc53f34577719fd08d572383f7d06118 to your computer and use it in GitHub Desktop.
installing CRW 2.3 via operatorhub / olm method
#!/bin/bash
set +e +x
# for a specific version, see either quay or redhat folders:
# https://codeready-workspaces-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/CRW_CI/view/Pipelines/job/crwctl_master/lastSuccessfulBuild/artifact/codeready-workspaces-chectl/dist/channels/quay/
# https://codeready-workspaces-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/CRW_CI/view/Pipelines/job/crwctl_master/lastSuccessfulBuild/artifact/codeready-workspaces-chectl/dist/channels/redhat/codeready-workspaces-2.3.0-GA-crwctl-linux-x64.tar.gz
VER=2.3.0-CI # or specific release like 2.3.0-GA
CHANNEL="quay" # for CI, use Quay, for GA, use redhat
# set project namespace default
if [[ $1 ]]; then namespace="$1"; else namespace="${USER}-crw"; fi
notLoggedIn ()
{
echo "You must 'oc login ...' in before you can proceed with this script."
exit 1
}
# check if logged into a cluster for deployment
oc project || notLoggedIn
checkVersion() {
if [[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]]; then
echo "OpenShift server version $2 >= $1, can proceed."
else
echo "Please connect to an OpenShift instance >= $1"
exit 1
fi
}
# check version >=4.2 (minimum version of OCP needed for OLM)
# but note that CRW 2.3 only supports OCP 4.4+
checkVersion 4.2 "$(oc version | grep Server | sed -r -e "s#.+Version: ##")"
# create OperatorSource
if [[ ${CHANNEL} == "redhat" ]]; then
echo "apiVersion: operators.coreos.com/v1
kind: OperatorSource
metadata:
name: codeready-workspaces-latest
spec:
displayName: Custom Operators
endpoint: https://quay.io/cnr
publisher: Red Hat
registryNamespace: redhat-operators
type: appregistry" > /tmp/operatorSource-CRW-${VER}.yaml
else
echo "apiVersion: operators.coreos.com/v1
kind: OperatorSource
metadata:
name: codeready-workspaces-latest
spec:
displayName: Custom Operators
endpoint: https://quay.io/cnr
publisher: Red Hat
registryNamespace: crw
type: appregistry" > /tmp/operatorSource-CRW-${VER}.yaml
fi
# OLM will create CatalogSource for this OperatorSource with the same name - see file contents above
kubectl apply -f /tmp/operatorSource-CRW-${VER}.yaml -n openshift-marketplace
# get latest crwctl version from Jenkins; if latest build is not a 2.0.0-CI build, set different VER value above
cd /tmp
rm -f ${HOME}/crwctl || true
rm -fr ${HOME}/crwctl_${VER} || true
echo "Fetch codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz ..."
if [[ ${VER} == *"-CI" ]]; then
curl -sSLo /tmp/codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz https://codeready-workspaces-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/CRW_CI/view/Pipelines/job/crwctl_master/lastSuccessfulBuild/artifact/codeready-workspaces-chectl/dist/channels/latest/crwctl-linux-x64.tar.gz || exit 1
else
curl -sSLo /tmp/codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz https://codeready-workspaces-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/CRW_CI/view/Pipelines/job/crwctl_master/lastSuccessfulBuild/artifact/codeready-workspaces-chectl/dist/channels/${CHANNEL}/codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz || exit 1
fi
tar xzf /tmp/codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz -C ${HOME} && rm -f /tmp/codeready-workspaces-${VER}-crwctl-linux-x64.tar.gz
mv ${HOME}/crwctl{,_${VER}} && ln -s ${HOME}/crwctl_${VER} ${HOME}/crwctl
${HOME}/crwctl/bin/crwctl version
# install CodeReady Workspaces 2.3 on OCP 4.4+ into ${USER}-crw namespace
${HOME}/crwctl/bin/crwctl server:start -a olm -n $namespace \
--catalog-source-name=codeready-workspaces-latest \
--catalog-source-namespace=openshift-marketplace \
--package-manifest-name=codeready-workspaces \
--olm-channel=latest
# patch deployment so we can run more than one workspace at a time
oc project $namespace
oc patch checluster codeready-workspaces --type=merge -p '{ "spec": { "server": { "customCheProperties": { "CHE_LIMITS_USER_WORKSPACES_RUN_COUNT": "-1" } } } }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment