Skip to content

Instantly share code, notes, and snippets.

@imcleod
Created January 27, 2016 22:44
Show Gist options
  • Select an option

  • Save imcleod/f57cd2420085989f2e49 to your computer and use it in GitHub Desktop.

Select an option

Save imcleod/f57cd2420085989f2e49 to your computer and use it in GitHub Desktop.
* Set up the ADB Vagrant box running OpenShift using the instructions here:
https://github.com/projectatomic/adb-atomic-developer-bundle/tree/master/components/centos/centos-openshift-setup
* Up that Vagrant box and ssh in as the vagrant user
* Login to openshift - you can make up a user and password - no joke
[vagrant@centos7-adb ~]$ oc login
Authentication required for https://10.1.2.2:8443 (openshift)
Username: vagrant
Password:
Login successful.
* Create a project (aka namespace) for our application
$ oc new-project mlbparks
* Clone my modified version of the OpenShift Nulecule
$ git clone https://github.com/imcleod/openshift3mlbparks.git
$ cd openshift3mlbparks.git
$ docker built -t mlbparks-nested ./
* Clone the library of example Nulecules - We will use this to build a local mongodb container.
(The public container has gone missing. We'll fix this at some point)
$ git clone https://github.com/projectatomic/nulecule-library.git
$ cd nulecule-library/mongodb-centos7-atomicapp
$ docker build -t projectatomic/mongodb-centos7-atomicapp ./
* Generate a candidate answers file:
$ atomic run mlbparks-nested --mode=genanswers mlbparks-nested
(Having to specify the container name twice is a bug. It's being worked.)
* Edit that answers file:
-ensure that some key shared information matches up between the two conatiner types we will be launching.
-change the provider to openshift
-point to our login credentials and configuration
Here is what mine looks like:
[mlbparks-app]
app_application_name = mlbparks
app_mongodb_user = user
app_mongodb_password = password
app_mongodb_database = root
app_mongodb_admin_password = password
[mongodb-atomicapp]
mongodb_admin_password = password
image = centos/mongodb-26-centos7
mongodb_password = password
mongodb_username = user
mongodb_quiet = True
mongodb_noprealloc = True
mongodb_smallfiles = True
mongodb_database = root
[general]
namespace = mlbparks
provider = openshift
providerconfig = /home/vagrant/.kube/config
* Run the Nulecule by launching the atomicapp container with the atomic command, passing in our answers file:
$ atomic run mlbparks-nested --answers=answers.conf
[tons of output]
* Wait - possibly several minutes. While you are waiting you can run commands like this:
$ oc get all
$ oc get pods
$ oc logs -f mlbparks-1-build
This last command, if run while the application is still building, will show the mlbparks app components being pulled down and built.
The mlbparks application is actually being composed from external bits after being launched.
When this process is complete you will see something like the following:
[vagrant@centos7-adb ~]$ oc get pods
NAME READY STATUS RESTARTS AGE
mlbparks-1-build 0/1 Completed 0 21h
mlbparks-1-jwdq7 1/1 Running 0 21h
mongodb 1/1 Running 0 21h
The process for actually accessing the running application is a little messy.
I favor determining the access IP address and port, and the using ssh port forwarding.
In short:
$ oc get all
Look for the lines that specify the HTTP process. Example:
mlbparks-http 172.30.215.188 <none>
8080/TCP deploymentConfig=mlbparks 21h
Initiate a vagrant ssh connection with port and host forwarding to this address:
_From the Mac/Linux/Windows host_
$ vagrant ssh -- -L 8080:172.30.215.188:8080
At this point, on the host, http://localhost:8080/ should be the mlb parks application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment