...
Code Block |
---|
[bandersen@li1397-60 ~]$ oc login 139.162.131.60:8443 --username=system --password=admin --insecure-skip-tls-verify Login successful. You don't have any projects. You can try to create a new project, by running oc new-project <projectname> Welcome! See 'oc help' to get started. [bandersen@li1397-60 ~]$ |
Note |
---|
An OpenShift 'project' is like a Kubernetes 'namespace', but with extra herbs and spices thrown in. |
Note | ||||
---|---|---|---|---|
Most tutorials will tell you to do it this way, but I have never gotten it to work:
Usually, you'll get an error like so:
|
The best way is actually to follow the advice here.
Running Magnolia on OpenShift
Two ways: as a standalone WAR file, or using Docker.
as a standalone WAR
...
Creating an App
There are many ways to create an OpenShift application, including:
- from source code
oc new-app /path/to/someUser/someProject
- oc
new-app
...
https://
...
github.
...
com/
...
someUser/someProject
- from docker images
- oc
new-app someImageOnDockerHub
- oc
new-app localhost:5000/someImage
- oc
- from templates
- oc
new-app someOpenShiftTemplate
- oc
new-app -f /path/to/someTemplate.json
- oc
- using the web console
Deploying an App
When we deploy an app, we deploy three things:
- configuration
- this describes the desired state of your application
- replication controller(s)
- this is basically a snapshot of some state of your application (the system will create this for you)
- pod(s)
- this is basically an instance of the app you created
If you create an app, as per above, you can inspect the configuration file for your app thusly:
Expand | ||
---|---|---|
|
Running Magnolia on OpenShift
Two ways: as a standalone WAR file, or using Docker.
as a standalone WAR
Code Block |
---|
wget https://files.magnolia-cms.com/5.6/magnolia-enterprise-pro-demo-webapp-5.6.war -O magnoliaauthor.war |
Note |
---|
The name is important here. The name we use in the next command has to follow these rules: Must be an a lower case alphanumeric (a-z, and 0-9) string with a maximum length of 58 characters, where the first character is a letter (a-z), and the '-' character is allowed anywhere except the first or last character. |
Code Block |
---|
oc new-app wildfly:latest~. --name magnoliaauthor |
You should get some output like:
Code Block |
---|
[bandersen@li1397-60 ~]$ oc new-app wildfly:latest~. --name magnoliaauthor
--> Found image fdd5894 (4 weeks old) in image stream "openshift/wildfly" under tag "latest" for "wildfly:latest"
WildFly 10.1.0.Final
--------------------
Platform for building and running JEE applications on WildFly 10.1.0.Final
Tags: builder, wildfly, wildfly10
* A source build using binary input will be created
* The resulting image will be pushed to image stream "magnoliaauthor:latest"
* A binary build was created, use 'start-build --from-dir' to trigger a new build
* This image will be deployed in deployment config "magnoliaauthor"
* Port 8080/tcp will be load balanced by service "magnoliaauthor"
* Other containers can access this service through the hostname "magnoliaauthor"
--> Creating resources ...
imagestream "magnoliaauthor" created
buildconfig "magnoliaauthor" created
deploymentconfig "magnoliaauthor" created
service "magnoliaauthor" created
--> Success
Build scheduled, use 'oc logs -f bc/magnoliaauthor' to track its progress.
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/magnoliaauthor'
Run 'oc status' to view your app.
[bandersen@li1397-60 ~]$ |
Now we build it and then we can go see it:
Code Block |
---|
[bandersen@li1397-60 ~]$ oc start-build magnoliaauthor --from-file=magnoliaauthor.war
Uploading file "magnoliaauthor.war" as binary input for the build ...
build "magnoliaauthor-2" started
[bandersen@li1397-60 ~]$ oc get routes
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
magnoliaauthor magnoliaauthor-default.139.162.131.60.nip.io magnoliaauthor 8080-tcp None |
So if we go to http://magnoliaauthor-default.139.162.131.60.nip.io/magnoliaauthor, we should see Magnolia 5.6 running on WildFly.
using Docker
You could use something from Docker Hub, or from a local Docker image, like so:
Expand | ||
---|---|---|
|
Troubleshooting
If for some reason your app is not running, you can check the logs, by pod name:
Expand | ||
---|---|---|
|
https://developers.redhat.com/blog/2017/08/16/troubleshooting-java-applications-on-openshift/
Expand | ||||
---|---|---|---|---|
or
|
Note |
---|
The name is important here. The name we use in the next command has to follow these rules: Must be an a lower case alphanumeric (a-z, and 0-9) string with a maximum length of 58 characters, where the first character is a letter (a-z), and the '-' character is allowed anywhere except the first or last character. |
Code Block |
---|
oc new-app wildfly:latest~. --name magnoliaauthor |
You should get some output like:
Code Block |
---|
[bandersen@li1397-60 ~]$ oc new-app wildfly:latest~. --name magnoliaauthor
--> Found image fdd5894 (4 weeks old) in image stream "openshift/wildfly" under tag "latest" for "wildfly:latest"
WildFly 10.1.0.Final
--------------------
Platform for building and running JEE applications on WildFly 10.1.0.Final
Tags: builder, wildfly, wildfly10
* A source build using binary input will be created
* The resulting image will be pushed to image stream "magnoliaauthor:latest"
* A binary build was created, use 'start-build --from-dir' to trigger a new build
* This image will be deployed in deployment config "magnoliaauthor"
* Port 8080/tcp will be load balanced by service "magnoliaauthor"
* Other containers can access this service through the hostname "magnoliaauthor"
--> Creating resources ...
imagestream "magnoliaauthor" created
buildconfig "magnoliaauthor" created
deploymentconfig "magnoliaauthor" created
service "magnoliaauthor" created
--> Success
Build scheduled, use 'oc logs -f bc/magnoliaauthor' to track its progress.
Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
'oc expose svc/magnoliaauthor'
Run 'oc status' to view your app.
[bandersen@li1397-60 ~]$ |
Now we build it and then we can go see it:
Code Block |
---|
[bandersen@li1397-60 ~]$ oc start-build magnoliaauthor --from-file=magnoliaauthor.war
Uploading file "magnoliaauthor.war" as binary input for the build ...
build "magnoliaauthor-2" started
[bandersen@li1397-60 ~]$ oc get routes
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
magnoliaauthor magnoliaauthor-default.139.162.131.60.nip.io magnoliaauthor 8080-tcp None |
So if we go to http://magnoliaauthor-default.139.162.131.60.nip.io/magnoliaauthor, we should see Magnolia 5.6 running on WildFly.
using Docker
...
Page Turner | ||
---|---|---|
|