Skip to content

Instantly share code, notes, and snippets.

@chainhead
Last active October 7, 2019 16:18
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 chainhead/c5e522398246667096e588efb46f2649 to your computer and use it in GitHub Desktop.
Save chainhead/c5e522398246667096e588efb46f2649 to your computer and use it in GitHub Desktop.
OpenShift notes

Introduction

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.

Installation - minishift

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.

Pre-requisites

  • 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.

Installation instructions

minishift - Instructions

Configuration - minishift

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

Installation - oc

Instructions

oc - Instructions

Configuration - oc

None.

Application development

OpenShift instructions

  • Note the minishift IP address with minishift 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment