Experiment Name: 在 OpenShift 平台上部署应用 of OpenShift on z/VM
Experiment Content:
Experiment Resources:
在 OpenShift 平台上部署应用 of OpenShift on z/VM
The following content is displayed on the same screen for your experiment so that you can make any necessary reference in experiment. Start your experiment now!
-
Product overview and registry
OpenShift is a containerization software solution developed by Red Hat and it is a Platform as a Service (PaaS) based on enterprise level Kubernetes management. The latest version is OpenShift 4. In addition to traditional X86 servers, it also supports some mainstream cloud platforms like Azure and AWS, and at the same time, supports the IBM LinuxONE platform. OpenShift supports application deployment through various methods, such as the use of S2I through Operators or Git, and direct use of the mirror of Image Registry.
Enter
cscdemo(XX)
in Username anddemo123
in Password, and click Log in to enter the graphic interface of OpenShift -
Check the project and deploy the Git server
On the navigation bar on the left, select
Projects
, then you can see one project (PR) cscdemoXX on the list on the right. ClickcscdemoXX
project, then you can view the Overview of the project. ClickWorkloads
, then you can check the applications deployed in the project. Currently, it is empty.
Click theAdministrator
pull-down menu at the top of the navigation on the left and switch to theDeveloper
view (Note: In case of any Restricted Access error, please change “Project: default” pull-down menu above into “Project: cscdemoXX”);
ChooseFrom Catalog
from the deployment modes on the right;
SelectGit Server (Ephemeral)
from the deployable projects;
Click Instantiate Template to prepare for the deployment;
Fill inApplication Hostname
withgit-XX.apps.zvm-ocp.example.com
, and confirm the correctness before clickingCreate
to start the deployment;
By clickingEvents
in the navigation bar on the left, you can view important events during the deployment process.
ClickDeveloper
pull-down menu at the top of the navigation bar on the left and Switch to theAdministrator
view;
After clicking Projects, clickcscdemoXX
on the right;
ClickWorkloads
to open the tab;
Click the DC projects listed undergit-server-example
, then you can see the details of the Git server application just deployed;
ClickResources
tab to confirm the state of P resource in the Pods group. The Running state indicates a deployment success.
At the bottom of Resources, you can see the group information of Routes, where Location is Application Hostname input when we just deployed;
click the link to open the page, if you see a page indicating403 Forbidden
, it means it operates properly. -
Deploy NodeJS MongoDB applications
Background story: The developers have finished one of the NodeJS applications in the project and submitted it to our git server. Now they need to deploy it to an OpenShift environment for testing. The location of the application on the git server is /git/nodejs.git.
Click theAdministrator
pull-down menu at the top of the navigation bar on the left to switch to theDeveloper
view;
Click+Add
menu item and selectFrom Catalog
from the deployment modes on the right;
SelectTemplate
filter conditions under TYPE and just display the template projects;
SelectNode.js + MongoDB (Ephemeral)
from the deployable projects;
ClickInstantiate Template
to prepare for deployment;
Fill inGit Repository URL
withhttp://git-(Project Name).apps.zvm-ocp.example.com/git/nodejs.git
After it is confirmed correct, clickCreate
to start deployment.
Click theDeveloper
pull-down menu at the top of the navigation bar on the left and switch to theAdministrator
view;
ClickProjects
, then clickcscdemoXX
on the right for a view;
ClickWorkloads
to open the tab;
Click (DC)nodejs-mongodb-example
project to see the information of the Node.JS application just deployed;
ClickResources
tab, then you can see the running state of Build tasks under the Builds group,
Click theView Logs
behind the Build group tasks, you can see the running log of Build tasks.
A few minutes later,Push successful
will appear on the bottom line, indicating success;
Return to theResources
tab page to confirm that the P resources are inRunning
state;
Then at the bottom of the resources, you can see information of the Routes group. Click the link given in Location. When “Welcome to your Node.js....
” appears at the top of the confirmation page, it means the deployment is a success -
Deploy Java MySQL applications
Background story: The developers have finished one of the Java applications in the project and submitted it to our git server. Now they need to deploy it to an OpenShift environment for testing. The location of the application on the git server is /git/java.git.
Click theAdministrator
pull-down menu at the top of the navigation bar on the left to switch to theDeveloper
view;
Click+Add
menu item and selectFrom Catalog
from the deployment modes on the right;
SelectTemplate
filter conditions under TYPE and just display the template projects,
SelectOpenJDK + MySQL (Ephemeral)
from the deployable projects,
ClickInstantiate Template
to prepare for deployment,
Fill inGit Repository URL
withhttp://git-(Project Name).apps.zvm-ocp.example.com/git/java.git
empty the content inContext Directory
,
and after it is confirmed correct, clickCreate
to start deployment.
Click theDeveloper
pull-down menu at the top of the navigation bar on the left to switch to theDeveloper
view;
ClickProjects
and then clickcscdemoXX
on the right for a view;
ClickWorkloads
to open the tab;
Click (DC)openjdk-app-mysql
project, then you can see the information of the Java application just deployed.
By clickingResources
tab, you can see the running state of Build tasks under the Build group,
ClickView Logs
behind the Build tasks, you can check the running log of Build tasks.
A few minutes later,Push successful
will appear on the bottom line, indicating a success;
Return to theResources
tab page to confirm that the P resources in the Pods group is inRunning
state.
At the bottom of the resources, you can see the information of the Routes group. Click the link given in Location. IfWelcome to your Node.js....
” appears on the top of the page, it means the deployment is a success -
Automatic deployment after the code change
Background story: Due to the rapid iteration of codes, in order to accelerate the development, it is hoped that after their submission, the new codes can be automatically deployed without manual intervention. In OpenShift, only Webhook method is needed to trigger this function. The following experiment demonstrates how to obtain the URL of Webhook and the automatic deployment.
First clickApplcations
->Terminal Emulator
on the top right of the desktop to start the terminal window, and then run the following command to clone the java code base and confirm the cloning success.ls
git clone http://git-(Project Name).apps.zvm-ocp.example.com/git/java.git
ls
cd java
Go back to theAdministrator
interface of OpenShift and selectBuild Configs
item underBuilds
on the navigation bar on the left,
Clickopenjdk-app-mysql
item on the page on the right,
Then at the bottom of the page, you can seeWebhooks
group.
ClickCopy URL with Secret
under Generic, and copy the URL of Webhook;
Return to the terminal window, create webhook files with vi, and paste the copied URL to a file before saving and exiting.vi webhook
Then use vi to modify the original java file src/main/java/org/openshift/quickstarts/undertow/servlet/PhoneBookServlet.java filevi src/main/java/org/openshift/quickstarts/undertow/servlet/PhoneBookServlet.java
changename = "NONE";
in the 87th line intoname = "NULL";
upon the modification, run the following command to submit the changegit add .
git commit -m "Test auto build"
git push
If there are prompts for username and password, entergit
as the username anddemo
as the password
Go back to theAdministrator
interface of OpenShift,
selectcscdemoXX
under Projects,
openWorkloads
tab,
after selecting (DC)openjdk-app-mysql
,
openResources
tab to view task items under the Builds group and you will see a new Build task is in operation. After the operation, the projects in the Running State in the Pods group will be stopped and new projects will be regenerated. When the new projects enter the Running state, click the Location link in the Routes Group at the bottom, the page output has changed from Number for user 'NONE' is not found into
Number for user 'NULL' is not found