After starting an OpenShift Origin instance, you can try it out by creating an end-to-end application demonstrating the full OpenShift Origin concept chain.
Reference > https://docs.openshift.org/latest/getting_started/administrators.html#try-it-out
Remark: When running OpenShift Origin in a VM, you will want to ensure your host system can access ports 8080 and 8443 inside the container for the examples below.
2. Install client tools
On the client machine (an Ubuntu Desktop 17.04 64-bit in this specific case), download the client tools > https://github.com/openshift/origin/releases
openshift-origin-client-tools-v1.5.0-031cbe4-linux-64bit.tar.gz
Once uncompressed, you'll have 3 files:
LICENSE
oc
README.md
Note: In this context, localhost is the client machine but port 8443 is accessing the openshift server in the VirtualBox machine (port forwarding has been set up in VirtualBox NAT)
./oc login https://localhost:8443 Username: test Password: test./oc new-project prova./oc new-app openshift/deployment-example./oc statusIn project prova on server https://localhost:8443svc/deployment-example - 172.30.46.123:8080 dc/deployment-example deploys istag/deployment-example:latest deployment #1 deployed 10 minutes ago - 1 podThe container image for your application will be pulled to the local system and started. Once it has started it can be accessed on the host. If this is your laptop or desktop, open a web browser to the service IP and port that was displayed for the application:
If you are on a separate system and do not have direct network access to the host, SSH to the system and perform a curl command:
v1 text displayed on the page.Now that your application is deployed, you can trigger a new version of that image to be rolled out to your host by tagging the v2 image. The new-app command created an image stream which tracks which images you wish to use. Use the tag command to mark a new image as being desired for deployment:
# Remark: getting started documentation command does not work. This one does:./oc tag --source=docker openshift/deployment-example:v2 deployment-example:latestYour application’s deployment config is watching deployment-example:latest and will trigger a new rolling deployment when the latest tag is updated to the value from v2.
#oc status shows the deployment$ ./oc statusIn project prova on server https://localhost:8443svc/deployment-example - 172.30.46.123:8080 dc/deployment-example deploys istag/deployment-example:latest deployment #2 deployed 9 minutes ago - 1 pod deployment #1 deployed 14 hours ago#Return to the browser or use curl (from the server if you do not have direct netwok access) again and you should see the v2 text displayed on the page.$ curl http://172.30.46.123:8080OpenShift Origin provides tools for running builds as well as building source code from within predefined builder images via the Source-to-Image toolchain.
Switch to the administrative user and change to the default project:
# Execute on server, ensuring the 'export' commands are set (it will autologin without asking for password)$ oc login -u system:admin
$ oc project default
Already on project "default" on server "https://10.0.2.15:8443".# NOTE: if you get "error: open /opt/openshift/openshift.local.config/master/admin.kubeconfig: permission denied"
# then execute at the openshift directory "sudo chmod a+rwX "$(pwd)"/openshift.local.config/master/admin.kubeconfig"
Set up an integrated Docker registry for the OpenShift Origin cluster:
$ oadm registry--> Creating registry registry ... serviceaccount "registry" created clusterrolebinding "registry-registry-role" created deploymentconfig "docker-registry" created service "docker-registry" created--> Success Note: It will take a few minutes for the registry image to download and start - use oc status to know when the registry is started.
In project default on server https://10.0.2.15:8443
svc/docker-registry - 172.30.155.30:5000
dc/docker-registry deploys docker.io/openshift/origin-docker-registry:v1.5.0
deployment #1 deployed 2 minutes ago - 1 pod
svc/kubernetes - 172.30.0.1 ports 443, 53->8053, 53->8053
Change back to the test user and test project:
# Note: user 'test' has password 'test'$ oc login -u test $ oc project provaAlready on project "prova" on server "https://10.0.2.15:8443".Create a new application that combines a builder image for Node.js with example source code to create a new deployable Node.js image:
$ oc new-app openshift/nodejs-010-centos7~https://github.com/openshift/nodejs-ex.git--> Found Docker image b3b1ce7 (5 months old) from Docker Hub for "openshift/nodejs-010-centos7" Node.js 0.10 ------------ Platform for building and running Node.js 0.10 applications Tags: builder, nodejs, nodejs010 * An image stream will be created as "nodejs-010-centos7:latest" that will track the source image * A source build using source code from https://github.com/openshift/nodejs-ex.git will be created * The resulting image will be pushed to image stream "nodejs-ex:latest" * Every time "nodejs-010-centos7:latest" changes a new build will be triggered * This image will be deployed in deployment config "nodejs-ex" * Port 8080/tcp will be load balanced by service "nodejs-ex" * Other containers can access this service through the hostname "nodejs-ex"--> Creating resources ... imagestream "nodejs-010-centos7" created imagestream "nodejs-ex" created buildconfig "nodejs-ex" created deploymentconfig "nodejs-ex" created service "nodejs-ex" created--> Success Build scheduled, use 'oc logs -f bc/nodejs-ex' to track its progress. Run 'oc status' to view your app.A build will be triggered automatically using the provided image and the latest commit to the master branch of the provided Git repository. To get the status of a build, run:
$ oc statuswhich will summarize the build. When the build completes, the resulting container image will be pushed to the Docker registry.
Note: Failed with error in the logs:
"error: build error: Failed to push image: Get https://172.30.155.30:5000/v1/_ping: http: server gave HTTP response to HTTPS client"
$ docker --version
Docker version 17.04.0-ce, build 4845c56
Note: ONLY if you need to clean-up and restart the oc command for the new-app#List all namesoc get all#Delete all names related to 'nodejs-ex'oc delete ...Once it succeeds, result is:
$ oc statusIn project prova on server https://10.0.2.15:8443svc/deployment-example - 172.30.67.80:8080 dc/deployment-example deploys istag/deployment-example:latest deployment #2 deployed 8 days ago - 1 pod deployment #1 deployed 8 days agosvc/nodejs-ex - 172.30.186.82:8080 dc/nodejs-ex deploys istag/nodejs-ex:latest <- bc/nodejs-ex source builds https://github.com/openshift/nodejs-ex.git on istag/nodejs-010-centos7:latest deployment #1 deployed 26 minutes ago - 1 podView details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.View the service IP using your browser or curl:
$ curl 172.30.186.82:8080OpenShift Origin includes a web console which helps you visualize your applications and perform common creation and management actions. You can use the test user we created above to log in to the console via https://<server>:8443/console.
ONLY if using NAT in the VM network:
a) Edit host /etc/hosts127.0.0.1 localhost openshift.local # VM openshift originb) Start openshift with the 'public' hostnamesudo ./openshift start --public-master=https://openshift.local:8443c) From host, access the web console (Virtual Box has port forwarding configured from 8443 to 8443)https://openshift.local:8443/consoleDevelopers: Web Console Walkthrough > https://sites.google.com/site/pawneecity/openshift-origin/developers-web-console-walkthrough-openshift-origin