This file documents the steps I followed to create and deploy an application to an OpenShift cluster. These instructions have been gathered after much trials and tribulations on maxcOS Mojave - YMMV.
Since this is an educational exercise, I used minishift
- an OpenShift cluster that is just enough to get started. To work with minishift
, a CLI tool oc
is also installed.
- VirtualBox - 5.0.x. For some reason, the latest version does not work well with
minishift
. Also, VirtualBox installation on macOS needs to be 'allowed' under Security and Privacy settings. - RedHat account -
https://access.redhat.com/tags/login
Note, xhyve
is the default VM driver. However, I haven't had success with it.
minishift
- Instructions
minishift setup-cdk --default-vm-driver=virtualbox
minishift config set skip-check-openshift-release true
minishift start
While starting up, the script will prompt for a RedHat account name and credentials. This is a one-time set-up. If the installation has gone through successfully, then you should see the URL for web console as shown below.
OpenShift server started.
The server is accessible via web console at:
https://192.168.99.100:8443/console
oc
- Instructions
None.
- Note the
minishift
IP address withminishift ip
. - Login -
oc login https://minishift_ip:8443 -u developer
. For password, enter any characters. - New project -
oc new-project demo
The rest of the gist assumes that the source code is in a local git
repository. Further this source code is a NodeJs application with a valid package.json
file at its root. This file helps OpenShift in identifying the language of the application.
- New application -
oc new-app .
For other options of creating an application, refer here.
Once an application is created, the following happens:
- A build configuration is created.
- The build configuration creates an application image.
- A deployment configuration is created.
- A service to load-balance the deployment.
To list the build and deployment configurations use the following respectively:
oc get bc
oc get dc
- To start a build, use the build configuration from the list above as
oc start-build bc/<build_name>
.
Note, the build strategy chosen by OpenShift depends of certain files at the root of source directory.
File | Strategy |
---|---|
Dockerfile |
Docker build |
Jenkinsfile |
Pipeline build |
None | Source build |
See here for more information on build strategies.