Deploying the Application via Command Line Interface
We can deploy our application via the OpenShift Command Line Interface (CLI).
Installing the Client
We should begin by downloading the OpenShift 3.11 origin and extract the archived file to $HOME/bin directory. Then, we should add the directory to the $PATH variable. In Linux, we can append the following line to our .bashrc file.
export PATH="$HOME/bin/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/:$PATH"Now, we can test that your installation works by calling the help command.
oc --helpThe OKD 3.11 documentation explains how to use OpenShift with different commands.
Login
Let's login to OpenShift using the token obtained from the Web User Interface. We recommend to keep the web user interface open if you want to see visually how your deployment is progressing.
oc login "https://rahti.csc.fi:8443" --token=<hidden>Check OpenShift and Kubernetes versions.
oc versionoc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO
Server https://rahti.csc.fi:8443
openshift v3.11.0+7876dd5-361
kubernetes v1.11.0+d4cacc0Creating a Project
We denote the user defined parameters using variables.
PROJECT="app"
APP="genie"
REPO="https://github.com/csc-training/GenieWebApp.jl"We can create a new project.
oc new-project $PROJECTIf a project already exists, we can change to existing project instead.
oc project $PROJECTWe can list existing projects
oc projectsYou have one project on this server: "app".
Using project "app" on server "https://rahti.csc.fi:8443".We can show an overview of our current project.
oc statusIn project app on server https://rahti.csc.fi:8443
You have no services, deployment configs, or build configs.
Run 'oc new-app' to create an application.Deploying the Application
Create new application, build the Docker container for the repository and deploy it to OpenShift
oc new-app $REPO --name=$APPCreating a Secure Route
We can expose the application to the internet by creating a Route.
oc create route edge \
--insecure-policy="Redirect" \
--service=$APP \
--hostname="$APP.rahtiapp.fi"Application should now be available in https://$APP.rahtiapp.fi.
Adding Persistent Storage
We can create a persistent storage and mount it to the application with a Persistent Volume Claim (PVC).
oc set volume dc/$APP \
--add \
--name="volume-1" \
--type="PersistentVolumeClaim" \
--claim-name="genie-volume" \
--claim-mode="ReadWriteMany" \
--claim-size="1G" \
--mount-path="/home/genie/app/data"Rebuilding Application
If we update our application and want to propagate the changes to the server, can start a new build.
oc start-build $APP