Skip to content

Commit

Permalink
Merge pull request siamaksade#134 from siamaksade/ocp-4.1-fix
Browse files Browse the repository at this point in the history
Updated che instructions for Che 7
  • Loading branch information
siamaksade authored Oct 10, 2019
2 parents f1562cd + 4555955 commit 7981cff
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 81 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ The application used in this pipeline is a JAX-RS application which is available
## Prerequisites
* 10+ GB memory

## Deploy on RHPDS

If you have access to RHPDS, provisioning of this demo is automated via the service catalog under **OpenShift Demos → OpenShift CI/CD for Monolith**. If you don't know what RHPDS is, read the instructions in the next section.
# Get OpenShift 4

[Download and install CodeReady Containers](https://developers.redhat.com/products/codeready-containers/overview) in order to create a local OpenShift 4 cluster on your workstation. Otherwise [create an OpenShift 4 cluster](https://try.openshift.com) on the public cloud or the infrastructure of your choice.

## Automated Deploy on OpenShift
You can se the `scripts/provision.sh` script provided to deploy the entire demo:

```
./provision.sh --help
./provision.sh deploy --enable-che --ephemeral # with Eclipse Che
./provision.sh deploy
./provision.sh delete
```
If you want to use Quay.io as an external registry with this demo, Go to quay.io and register for free. Then deploy the demo providing your
Expand All @@ -60,7 +61,8 @@ on your Quay.io account and use that instead of the integrated OpenShift
registry, for pushing the built images and also pulling images for deployment.

## Manual Deploy on OpenShift
Follow these [instructions](docs/local-cluster.md) in order to create a local OpenShift cluster. Otherwise using your current OpenShift cluster, create the following projects for CI/CD components, Dev and Stage environments:

Create the following projects for CI/CD components, Dev and Stage environments:

```shell
# Create Projects
Expand Down Expand Up @@ -153,9 +155,10 @@ This demo by default uses the WildFly community image. You can use the JBoss EAP

## Using Eclipse Che for Editing Code

If you deploy the demo template using `DEPLOY_CHE=true` paramter, or the deploy script and use `--deploy-che` flag, then an [Eclipse Che](https://www.eclipse.org/che/) instances will be deployed within the CI/CD project which allows you to use the Eclipse Che web-based IDE for editing code in this demo.
You can install Eclipse Che on OpenShift 4 using the OperatorHub. Follow the [Installing Che on OpenShift 4 from OperatorHub](https://www.eclipse.org/che/docs/che-7/installing-che-on-openshift-4-from-operatorhub/) docs in order to install Eclipse Che 7. Alternatively, if you OpenShift cluster is accessible over the internet, you can use the hosted Eclipse Che service at https://che.openshift.io .


Follow these [instructions](docs/using-eclipse-che.md) to use Eclipse Che for editing code in the above demo flow.
You can then follow these [instructions](docs/using-eclipse-che.md) to use Eclipse Che for editing code in the above demo flow.

# Watch on YouTube

Expand Down
33 changes: 12 additions & 21 deletions cicd-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ parameters:
value: stage
name: STAGE_PROJECT
required: true
- displayName: Deploy Eclipse Che
description: Deploy Eclipse Che in order to use as an online IDE for changing code in this demo
value: "false"
name: DEPLOY_CHE
required: true
- displayName: Ephemeral
description: Use no persistent storage for Gogs and Nexus
value: "true"
Expand Down Expand Up @@ -339,13 +334,15 @@ objects:
GOGS_HOSTNAME="gogs-$CICD_NAMESPACE.$HOSTNAME"
if [ "${EPHEMERAL}" == "true" ] ; then
oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-template.yaml \
oc new-app -f https://raw.githubusercontent.com/siamaksade/gogs-openshift-docker/master/openshift/gogs-template.yaml \
--param=GOGS_VERSION=0.11.34 \
--param=DATABASE_VERSION=9.6 \
--param=HOSTNAME=$GOGS_HOSTNAME \
--param=SKIP_TLS_VERIFY=true
else
oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/gogs-openshift-docker/master/openshift/gogs-persistent-template.yaml \
oc new-app -f https://raw.githubusercontent.com/siamaksade/gogs-openshift-docker/master/openshift/gogs-persistent-template.yaml \
--param=GOGS_VERSION=0.11.34 \
--param=DATABASE_VERSION=9.6 \
--param=HOSTNAME=$GOGS_HOSTNAME \
--param=SKIP_TLS_VERIFY=true
fi
Expand All @@ -361,20 +358,6 @@ objects:
oc set resources dc/sonardb --limits=cpu=200m,memory=512Mi --requests=cpu=50m,memory=128Mi
oc set resources dc/sonarqube --limits=cpu=1,memory=2Gi --requests=cpu=50m,memory=128Mi
if [ "${DEPLOY_CHE}" == "true" ] ; then
oc process -f https://raw.githubusercontent.com/minishift/minishift/master/addons/che/templates/che-workspace-service-account.yaml \
--param SERVICE_ACCOUNT_NAMESPACE=$CICD_NAMESPACE --param=SERVICE_ACCOUNT_NAME=che-workspace | oc create -f -
oc process -f https://raw.githubusercontent.com/minishift/minishift/master/addons/che/templates/che-server-template.yaml \
--param ROUTING_SUFFIX=$HOSTNAME \
--param CHE_MULTIUSER=false \
--param CHE_VERSION="6.19.0" \
--param CHE_INFRA_OPENSHIFT_PROJECT=$CICD_NAMESPACE \
--param CHE_INFRA_KUBERNETES_SERVICE__ACCOUNT__NAME=che-workspace | oc create -f -
oc set resources dc/che --limits=cpu=1,memory=2Gi --requests=cpu=200m,memory=512Mi
fi
if [ "${EPHEMERAL}" == "true" ] ; then
oc new-app -f https://raw.githubusercontent.com/OpenShiftDemos/nexus/master/nexus3-template.yaml --param=NEXUS_VERSION=3.13.0 --param=MAX_MEMORY=2Gi
else
Expand Down Expand Up @@ -446,6 +429,14 @@ objects:
cat /tmp/curl.log
exit 255
fi
oc label dc sonarqube "app.kubernetes.io/part-of"="sonarqube" --overwrite
oc label dc sonardb "app.kubernetes.io/part-of"="sonarqube" --overwrite
oc label dc jenkins "app.kubernetes.io/part-of"="jenkins" --overwrite
oc label dc nexus "app.kubernetes.io/part-of"="nexus" --overwrite
oc label dc gogs "app.kubernetes.io/part-of"="gogs" --overwrite
oc label dc -postgresql "app.kubernetes.io/part-of"="gogs" --overwrite
image: quay.io/openshift/origin-cli:v4.0
name: cicd-demo-installer-job
resources: {}
Expand Down
20 changes: 0 additions & 20 deletions docs/local-cluster.md

This file was deleted.

42 changes: 14 additions & 28 deletions docs/using-eclipse-che.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,38 @@

Here is a step-by-step guide for editing and pushing the code to the Gogs repository using Eclipse Che.

Click on Eclipse Che route url in the CI/CD project which takes you to the workspace administration page. Select the *Java* stack and click on the *Create* button to create a workspace for yourself.
Click on Eclipse Che route url in the CI/CD project which takes you to the workspace administration page. Select the *Java Maven* stack. Under the *Projects* section, enter `openshift-tasks` as the *Project Name* and the following the Gogs repository URL as the Git repository URL (replace _gogs-hostname_ with your own Gogs URL):

![](../images/che-create-workspace.png?raw=true)

Once the workspace is created, click on *Open* button to open your workspace in the Eclipse Che in the browser.

![](../images/che-open-workspace.png?raw=true)
`http://gogs:gogs@[gogs-hostname]/gogs/openshift-tasks.git`

It might take a little while before your workspace is set up and ready to be used in your browser. Once it's ready, click on **Import Project...** in order to import the `openshift-tasks` Gogs repository into your workspace.
Click on *Save* and then on *Create & Open* button to create and open your workspace.

![](../images/che-import-project.png?raw=true)
![](../images/che-create-workspace.png?raw=true)

Enter the Gogs repository HTTPS url for `openshift-tasks` as the Git repository url with Git username and password in the
url: <br/>
`http://gogs:gogs@[gogs-hostname]/gogs/openshift-tasks.git`
![](../images/che-workspace.png?raw=true)

You can find the repository url in Gogs web console. Make sure the check the **Branch** field and enter `eap-7` in order to clone the `eap-7` branch which is used in this demo. Click on **Import**
You will be working on the `eap-7` branch of the Git repository. Click on the branch name on the left lower corner of the screen where it says `master` and then choose the `origin/eap-7` branch to switch your working branch to `eap-7` branch.

![](../images/che-import-git.png?raw=true)
![](../images/che-select-git-ref.png?raw=true)

Change the project configuration to **Maven** and then click **Save**
Follow the steps 6-10 in the above guide to edit the code in your workspace.

![](../images/che-import-maven.png?raw=true)
![](../images/che-edit-file.png?raw=true)

Configure you name and email to be stamped on your Git commity by going to **Profile > Preferences > Git > Committer**.
Click on the `Source Control: Git` in the left sidebar to change to the source control explorer. From the `...` menu, click on `Commit All`. You can also use `Command + Shift + P` to open the commands palette and search for `Commit All`.

![](../images/che-configure-git-name.png?raw=true)
![](../images/che-commit.png?raw=true)

Follow the steps 6-10 in the above guide to edit the code in your workspace.
You will get a dialog asking if Che should add all modified resources for the commit. Click on *Yes*, enter a text as the commit message and then press enter.

![](../images/che-edit-file.png?raw=true)
![](../images/che-commit-all.png?raw=true)

In order to run the unit tests within Eclipse Che, wait till all dependencies resolve first. To make sure they are resolved, run a Maven build using the commands palette icon or by clicking on **Run > Commands Palette > build**.
As soon the changes are committed to the git repository, a new instances of pipeline gets triggers to test and deploy the code changes.

Make sure you run the build again, after fixing the bug in the service class.

Run the unit tests in the IDE after you have corrected the issue by right clicking on the unit test class and then **Run Test > Run JUnit Test**

![](../images/che-run-tests.png?raw=true)

![](../images/che-junit-success.png?raw=true)


Click on **Git > Commit** to commit the changes to the `openshift-tasks` git repository. Make sure **Push committed changes to ...** is checked. Click on **Commit** button.

![](../images/che-commit.png?raw=true)

As soon the changes are committed to the git repository, a new instances of pipeline gets triggers to test and deploy the
code changes.
Binary file added images/che-commit-all.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/che-commit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/che-create-workspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/che-edit-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/che-import-project.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/che-open-workspace.png
Binary file not shown.
Binary file added images/che-select-git-ref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/che-workspace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function usage() {
echo " --user [username] Optional The admin user for the demo projects. Required if logged in as system:admin"
echo " --project-suffix [suffix] Optional Suffix to be added to demo project names e.g. ci-SUFFIX. If empty, user will be used as suffix"
echo " --ephemeral Optional Deploy demo without persistent storage. Default false"
echo " --enable-che Optional Deploy Eclipse Che as an online IDE for code changes. Default false"
echo " --oc-options Optional oc client options to pass to all oc commands e.g. --server https://my.openshift.com"
echo
}
Expand All @@ -37,7 +36,6 @@ ARG_PROJECT_SUFFIX=
ARG_COMMAND=
ARG_EPHEMERAL=false
ARG_OC_OPS=
ARG_DEPLOY_CHE=false
ARG_ENABLE_QUAY=false
ARG_QUAY_USER=
ARG_QUAY_PASS=
Expand Down Expand Up @@ -112,9 +110,6 @@ while :; do
--ephemeral)
ARG_EPHEMERAL=true
;;
--enable-che|--deploy-che)
ARG_DEPLOY_CHE=true
;;
-h|--help)
usage
exit 0
Expand Down Expand Up @@ -175,7 +170,7 @@ function deploy() {

local template=https://raw.githubusercontent.com/$GITHUB_ACCOUNT/openshift-cd-demo/$GITHUB_REF/cicd-template.yaml
echo "Using template $template"
oc $ARG_OC_OPS new-app -f $template -p DEV_PROJECT=dev-$PRJ_SUFFIX -p STAGE_PROJECT=stage-$PRJ_SUFFIX -p DEPLOY_CHE=$ARG_DEPLOY_CHE -p EPHEMERAL=$ARG_EPHEMERAL -p ENABLE_QUAY=$ARG_ENABLE_QUAY -p QUAY_USERNAME=$ARG_QUAY_USER -p QUAY_PASSWORD=$ARG_QUAY_PASS -n cicd-$PRJ_SUFFIX
oc $ARG_OC_OPS new-app -f $template -p DEV_PROJECT=dev-$PRJ_SUFFIX -p STAGE_PROJECT=stage-$PRJ_SUFFIX -p EPHEMERAL=$ARG_EPHEMERAL -p ENABLE_QUAY=$ARG_ENABLE_QUAY -p QUAY_USERNAME=$ARG_QUAY_USER -p QUAY_PASSWORD=$ARG_QUAY_PASS -n cicd-$PRJ_SUFFIX
}

function make_idle() {
Expand Down

0 comments on commit 7981cff

Please sign in to comment.