Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managed platform #3

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dist
build
eggs
parts
bin
var
sdist
develop-eggs
Expand All @@ -33,3 +32,4 @@ nosetests.xml
.mr.developer.cfg
.project
.pydevproject
.idea/
1 change: 0 additions & 1 deletion .openshift/action_hooks/build

This file was deleted.

5 changes: 0 additions & 5 deletions .openshift/action_hooks/deploy

This file was deleted.

4 changes: 0 additions & 4 deletions .openshift/action_hooks/post_deploy

This file was deleted.

5 changes: 0 additions & 5 deletions .openshift/action_hooks/pre_build

This file was deleted.

74 changes: 0 additions & 74 deletions .openshift/action_hooks/pre_start_python-2.7

This file was deleted.

4 changes: 0 additions & 4 deletions .openshift/action_hooks/pre_stop_python-2.7

This file was deleted.

14 changes: 14 additions & 0 deletions .s2i/bin/assemble
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
mv /tmp/src/* ./

git clone --depth 1 https://github.com/victims/victims-hash.git
cd victims-hash
rm -rf .git
pip install .
cd ..

git clone --depth 1 https://github.com/victims/victims-web.git
cd victims-web
rm -rf .git

exec /usr/libexec/s2i/assemble
4 changes: 4 additions & 0 deletions .s2i/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
cd victims-web/
exec /usr/libexec/s2i/run

3 changes: 3 additions & 0 deletions .s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_SCRIPT=/opt/app-root/src/victims-web-server
VICTIMS_CONFIG=/opt/app-root/src/victimsconfig.py

76 changes: 51 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,67 @@ This repo allows you to deploy a new instance of the victims-web server on opens

## Running on OpenShift
### Prerequisites
1. You have a valid account with OpenShift
2. You have followed the instructions at https://www.openshift.com/get-started
3. You have *rhc* installed and ready
1. You have a valid account with OpenShift https://www.openshift.com/get-started
2. You have the s2i tool installed locally https://github.com/openshift/source-to-image

### Creating the app
#### One Shot Deployment
This is pretty straight forward, run the following command. The app should be deployed to ```http://victims-NAMESPACE.rhcloud.com```. See bottom for a sample output.
### Log in to Openshift
```sh
rhc app create victims mongodb-2.2 rockmongo-1.1 python-2.7 --from-code git://github.com/victims/victims-server-openshift.git
oc login https://console.starter-us-east-1.openshift.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably say https://youropenshiftinstance.example.com or something like that.

```
_*Note:*_ The above can be used for development purposes and will be deployed on a shared gear. This cannot be used with ```--scaling``` as _rockmongo_ cannot be scaled. If you want to deploy with scaling enabled, use:

### Create a new project
```sh
oc new-project victims
```

### (Optional) Deploy a database
It's recommended to use a MongoDB database hosted outside of Openshift. However for development purposes a temporary database can provisionsed inside Openshift using the provided template:
```sh
oc process -f mongodb-ephemeral.yaml | oc create -f -
```
*Due to the authentication mechanism being updated to SCRAM-SHA1 in Mongo 3.x, we have a requirement to use an earlier version of MongoDB, eg. 2.6*
*The emphemeral template doesn't use permanent storage with a persistent volume, all data will be lost when the pod is migrated!*

### Build the victims-web image with s2i tool
```sh
s2i build -c . centos/python-27-centos7 registry.starter-us-east-1.openshift.com/victims/victims-web
```
*The ''-c' argument tells s2i to use the local copy, not one stored in the local git repository*

### Test the build image
It's now possible to run the image locally to test any changes:
```sh
docker run -it registry.starter-us-east-1.openshift.com/victims/victims-web
```

### Push the image into Openshift
You'll need to login to the openshift docker registry using your token. The token can be obtained by first logging into Openshift:
```sh
rhc app create victims mongodb-2.2 python-2.7 --scaling --from-code git://github.com/victims/victims-server-openshift.git
oc login https://console.starter-us-east-1.openshift.com
```
If you'd like to merge in any upstream changes as they are available, you need to configure remote/upstream. This can be done as follows:
*In this case we're using Openshift online, however if you have a custom install of Openshift Container Platform, please use that URL instead of starter-us-east-1.openshift.com*

Then obtain your token like so:
```sh
git remote add upstream https://github.com/victims/victims-server-openshift.git
oc whoami -t
```
#### Alternative Deployment
This can be useful if the *One Shot* option fails or if you want to configure the instance from build 1.

Then login to the docker registry:
```sh
rhc app create victims mongodb-2.2 rockmongo-1.1 python-2.7
cd victims
git remote add upstream -m master git://github.com/victims/victims-server-openshift.git
git pull -s recursive -X theirs upstream master
# Make any configuration changes here and commit them.
git push origin master
```
### Merging upstream changes
Changes from upstream for the openshift wrapper app can be merged in and the app redeployed by executing:
docker login -u <openshift-username> -p <token> registry.starter-us-east-1.openshift.com
```

Push the build image to the registry:

```sh
git pull --rebase upstream master
git push origin master
sudo docker push registry.starter-us-east-1.openshift.com/victims/victims-web
```
_Note:_ This requires remote/usptream to be configured. (See above)

### Create the app using image
```sh
oc new-app -e MONGODB_DB_HOST=<mongodb-hostname> victims-web -e MONGODB_DB_USERNAME=<mongodb-username> -e MONGODB_DB_PASSWORD=<mongodb-password> --name=web
```

### Importing data
1. Get the app's SSH address by running ```rhc app show victims```
2. SSH into the server.
Expand Down
18 changes: 0 additions & 18 deletions app.py

This file was deleted.

62 changes: 0 additions & 62 deletions bin/control

This file was deleted.

8 changes: 3 additions & 5 deletions bin/victims-hash-java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash
#!/bin/bash

VICTIMS_JAR=${OPENSHIFT_REPO_DIR}/libs/java-hash.jar
source /opt/app-root/bin/activate

if [ -f ${VICTIMS_JAR} ]; then
java -jar $VICTIMS_JAR $@
fi
/opt/app-root/src/victims-hash/bin/process.sh $1
Empty file removed config/.gitkeep
Empty file.
37 changes: 0 additions & 37 deletions config/victimsweb.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions config/victimsweb.env

This file was deleted.

Loading