After starting an OKD instance, you can try it out by creating an
end-to-end application demonstrating the full OKD concept chain.
|
When running OKD in a VM, you will want to ensure your host
system can access ports 8080 and 8443 inside the container for the examples
below.
|
-
Log in to the server as a regular user:
$ oc login
Username: test
Password: test
-
Create a new project to hold your application:
-
Create a new application based on a Node.js image on the Docker Hub:
$ oc new-app openshift/deployment-example
Note that a service was created and given an IP - this is an address that
can be used within the cluster to access the application.
-
Display a summary of the resources you created:
-
The 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:
http://172.30.192.169:8080 (example)
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:
$ curl http://172.30.192.169:8080 # (example)
You should see the 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:
$ oc tag --source=docker openshift/deployment-example:v2 deployment-example:latest
Your 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
.
|
You can also use an alternate version of the command:
$ oc tag docker.io/openshift/deployment-example:v2 deployment-example:latest
|
Return to the browser or use curl
again and you should see the v2
text
displayed on the page.
|
For this next step we’ll need to ensure that Docker is able to pull images
from the host system. Ensure you have completed the instructions about setting the
--insecure-registry flag from Host Preparation.
|
As a developer, building new container images is as important as deploying them.
OKD provides tools for running builds as well as building
source code from within predefined builder images via the Source-to-Image
toolchain.
For this procedure, ensure that Docker is able to pull images
from the host system. Also, make sure you have completed the instructions about setting the
--insecure-registry
flag from Host Preparation.
-
Switch to the administrative user and change to the default
project:
$ oc login -u system:admin
$ oc project default
-
Set up an integrated Docker registry for the OKD cluster:
It will take a few minutes for the registry image to download and start - use
oc status
to know when the registry is started.
-
Change back to the test
user and test
project:
$ oc login -u test
$ oc project test
-
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/sclorg/nodejs-ex.git
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:
which will summarize the build. When the build completes, the resulting container image will be pushed to the Docker registry.
-
Wait for the deployed image to start, then view the service IP using your
browser or curl
.
You can see more about the commands available in
the CLI (the oc
command)
with:
Or connect to another system with:
$ oc -h <server_hostname_or_IP> [...]