How to setup open-shift container on a single EC2 instance and how to deploy TIBCO BWCE Application on open shift container
PART 1 Setup Openshift on single Ec2-instance
Step 1 : Launch AWS RHEL EC2 instance (instance type t2.xlarge)
Select Red Hat Enterprise version
Step 2 : Login to ec2 instance using ssh ssh -i <<certificate file>> ec2-user@<<public ip addres of ec2 >>
Step 3: Before we install open shift we need to install docker. Again docker-ce is only supported on RHEL server so please install docker-ce, Below are the steps to install docker-ce version :
- Install docker using below command.
$ sudo yum install docker
- Optional : if Container .i.o error occurs use the below command to install container for docker.
$ sudo yum install -y https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm and then install the docker
- Add Docker repository.
$ sudo yum-config-manager — add-repo https://download.docker.com/linux/centos/docker-ce.repo
- List out the available docker-ce version available.
$ sudo yum — showduplicates list docker-ce
Note: we going to install specific version of docker-ce that has whole number as I have learned with my previous experience that open shift failed to parse version number if it has 0 ,for example 18.09.01 so we going to install docker-ce-17.12.1.ce-1.el7.centos
- Install the specific version of docker.
$ sudo yum install docker-ce-17.12.1.ce-1.el7.centos
- Verify the docker version.
$ docker -v
- Add ec2-user to docker.
$ sudo usermod -aG docker ec2-user
- Start the docker service.
$ sudo service docker start
- Verify the docker service started using
$ sudo docker ps
Step 4: Get Openshift from Github https://github.com/openshift/origin/releases
$ sudo yum install wget
- Change the mode of file
$ chmod 755 openshift-origin-client-tools-v3.6.0-alpha.0–0343989-linux-64bit.tar.gz
- Untar the file
$ tar -xvzf openshift-origin-client-tools-v3.6.0-alpha.0–0343989-linux-64bit.tar.gz
$ cd openshift-origin-client-tools-v3.6.0-alpha.0–0343989-linux-64bit
- Copy Open shift command into your bin folder
$ sudo cp oc /usr/local/bin/
- Start Open shift cluster
$ sudo su -
[root@ip-172–31–19–218 ~]#
$ oc cluster up — routing-suffix=<your public AWS EC2 IP address>.nip.io — public-hostname=<your AWS EC2 public DNS>.compute-1.amazonaws.com
Note: If you get error did not detect an -insecure-registry argument on the docker then you have to add insecure registry to docker configuration
$ sudo vi /etc/sysconfig/docker
- After file is open Copy the below line on “docker” file and save it .
Add option — insecure-registry 172.30.0.0/16
- after saving the file re-run the
$ oc cluster up — routing-suffix=<your public AWS EC2 IP address>.nip.io — public-hostname=<your AWS EC2 public DNS>.compute-1.amazonaws.com
Note : If you get above error related to ip table permission you can run below command to resolve this
$ modprobe ip_tables
And run the OC script again
$ oc cluster up — routing-suffix=<your public AWS EC2 IP address>.nip.io — public-hostname=<your AWS EC2 public DNS>.compute-1.amazonaws.com
Part 2- Deploy BWCE instance in Open-shift Container
Prerequisite
1. BWCE (Tibco BusinessWorks Container Edition) must be installed and must be familiar with its working.
2. Corresponding Docker client must be installed on your local machine.
3. You must have a Docker Hub account.
Methodology
Before we actually begin, let us understand the actual steps that we are going to perform.
Step 1: Creating a BWCE application.
Step 2: Creating an EAR of the application.
Step 3: Creating a base docker image of Tibco BWCE.
Step 4: Creating a Docker file for your application which will include the Tibco BWCE base image.
Step 5: Creating the Docker image for your application.
Step 6: Pushing the docker image of your application to your Docker Hub.
Step 7: login to OpenShift container .
Step 8: Finally Deploying your application from Docker Hub to OpenShift.
Step 1: Creating a BWCE application.
Please make sure you have a working BWCE application. You can test it through studio before moving further.
Step 2: Creating an EAR of the application.
- Right click anywhere in the project explorer tab.
- Choose the Export option.
- Scroll down in the Others section.
- Choose Export as an EAR option. The EAR Export window will appear as shown below.
- Choose the location in which you want to store your EAR file.
- You can also name the file as per your choice or leave it to default. Click Finish.
- You can check the EAR file at the selected location.
Step 3: Creating a base docker image of Tibco BWCE
Prerequisites
Download the TIBCO BusinessWorks™ Container Edition runtime zip file, bwce-runtime-2.5.2.zip, from http://edelivery.tibco.com.
To download this file,
1. Select Container from the Operating Systems drop down list.
2. Read and Accept the TIBCO End User License Agreement.
3. Select the radio button for Individual file Download.
4. Click the + sign to view the individual components and select bwce-runtime-2.5.2.zip.
Note: If there is plug-in used within your application like Active-space or Data conversion plugin then please download the necessary plugin from http://edelivery.tibco.com and for downloading the file repeat step 1-4.
Procedure
- Navigate to the directory. TIBCO_HOME/bwce/<<version>>/docker.
2. Copy the bwce-runtime-2.5.2.zip file to the TIBCO_HOME/bwce/<<version>>/docker/resources/bwce-runtime/ folder.
3. Optionally add the following
- plugin container file to. TIBCO_HOME/bwce/<<version>>/docker/resources/addon/plugins/
- lib container file to TIBCO_HOME/bwce/<<version>>/docker/resources/addon/lib/
- jars container file to TIBCO_HOME/bwce/<<version>>/docker/resources/addon/jars/
Note: if there are multiple jar files or library files are available then zip these files without making copying into any folder, just select all the jar file and zip it and copy it to lib or jar folder depends upon the type of files.
4. Open a command terminal and execute the following command from the TIBCO_HOME/bwce/<<version>>/docker folder:
- command : docker build -t NAME:TAG-NAME .
- Eg: docker build -t tibco/bwce:latest .
Note: there is full stop after latest please add it for successful run
Result The TIBCO BusinessWorks™ Container Edition base Docker image is now created. This base Docker image can now be used to create Docker application images.
Step 4: Creating a Docker file for your application which will include the Tibco BWCE base image.
- Go to the directory where you saved your EAR file.
- Open your terminal in that directory.
- With the help of your favourite text editor create a file and name it as “Dockerfile”.
- Type the following
- Save the file.
Step 5: Creating the Docker image for your application.
We need to build the image of our application in this step.
- Go to the directory where you saved you EAR file.
- Open your terminal in that directory.
- Execute the following command:
- command : docker build -t image_name:tag .
- Eg: docker build -t sahaj4u/helloworld:latest .
Note: sahaj4u is my docker image id here
execute the docker image command
Step 6: Pushing the docker image of your application to your Docker
Since, you made your own Docker image and would like to share it with the world you can sign up for an account on https://hub.docker.com/. After verifying your email you are ready to go and upload your first docker image.
- Log in on https://hub.docker.com/
- Click on Create Repository.
- Choose a name (e.g. sahaj4u/helloworld) and a description for your repository and click Create.
- Log into the Docker Hub from the command line
docker login — username=yourhubusername — email=youremail@company.com OR docker login
Just with your own user name and email that you used for the account. Enter your password when prompted. If everything worked you will get a message similar to
WARNING: login credentials saved in /home/username/.docker/config.json Login Succeeded
Now we need to tag our local image which is present on our machine locally…..to our repository name that we created on DockerHub. This is done to ensure that the image is pushed to your repository only.
docker tag 972467605d21 sahaj4u/helloworld:latest
The number must match the image ID and :latest is the tag.
Now it is time to push your image to DockerHub. Use the following command to do so.
docker push repository-name/image-name:tag Eg: docker push sahaj4u/helloworld:latest
Refresh your DockerHub account page. You will see your repository and the corresponding docker image in it.
Step 7: login to OpenShift container .Open your browser and use https://localhost:8443/console to start the OpenShift console window.
username :admin/password:admin
The login screen appears as below.
- Create new Projects and pull images from docker hub
select Docker image tab
Provide image name from docker hub
Click create button
Project created successfully , Check the Pod status