SlideShare a Scribd company logo
Openshift for Beginners: Demo on building and deploying
application from scratch with in Openshift
Download the PPT and code from github as below
# git clone https://github.com/kiranpampana/kiran-app.git
Our application is a telephone directory which displays username/country and
phone number .
Application has 2 parts
• 1) Web app built using Python and Flask framework
• 2)MYSQL database holds user data that is being used by web app
WEBAPP
MYSQL
DATABASE
Pages displayed by the app
• First page is a Welcome page
with information
• Second page is displaying details
accessed from a mysql database
We need to know about containers/pods. But why ?
Pods are the basic building blocks of Openshift.
Pod is a group of one or more containers.
What are containers ?
Lets find out why we need containers and understand them by comparing
with Virtual machines , as VM’s are well understood
PHYSICAL MACHINE
HARDWARE (CPU/RAM/DISK)
OPERATING SYSTEM
USER SPACE
KERNEL SPACE
DB1
APP3
APP2
APP1
TRADITIONAL
What are the problems with
traditional system ?
1) Security, as files of one app can
be viewed by another app
owner
2) Resource exploitation by any
app
3) If an app needs reboot , it
impacts other apps as well
4) ……………….
5) ………..
6) ...
PHYSICAL MACHINE
HARDWARE (CPU/RAM/DISK)
OPERATING SYSTEM
USER SPACE
KERNEL SPACE
A
P
P
1
A
P
P
2
A
P
P
3
In-order to address problems with
traditional system we need Physical or
Logical separation between applications
Virtualization and
containerization provide logical
separation for Applications
PHYSICAL MACHINE
HARDWARE (CPU/RAM/DISK)
HYPERVISOR KERNEL
VIRTUAL
HW1
VM1 OS
USER
SPACE1
VM1
KERNEL
A
PP
1
VIRTUAL
HW2
VM2 OS
VM2
KERNEL
USER
SPACE2
A
PP
2
PHYSICAL MACHINE
HARDWARE (CPU/RAM/DISK)
OPERATING SYSTEM
KERNEL
CONTAINER 1 CONTAINER 2
USER
SPACE1
USER
SPACE2
A
PP
1
A
PP
2
VIRTUALIZATION CONTAINERIZATION
Containerization Virtualization
Are about virtualizing the operating system
subsystems(Network,Filesystems,Process…)
Based on emulating Hardware or are about
virtualizing hardware
Single kernel Multiple kernels
Initially embraced by service providers Initially embraced by enterprises
Under resource crunch containers are stable then
VMs as only one kernel tries to solve problem
Under resource crunch VM's running on
hypervisors are unstable as one+ kernels start to
solve the same problem
Lightness makes them far more dense and elastic Less elasticity and density
We need to know about docker . But why ?
Docker is a tool for managing
containers .Rkt is similar tool like docker .
Openshift uses docker
PHYSICAL MACHINE
HARDWARE (CPU/RAM/DISK)
OPERATING SYSTEM
KERNEL
CONTAINER 2
USER SPACE 2
APP2
CONTAINER 1
USER SPACE 1
APP1
DOCKER
Demo is consisting of 3 parts
Part 1: Deploy application on a Machine
Part 2 :Deploy application with in Containers
Part 3: Deploy application with in Openshift
Part 1: Deploy application on a Machine
Application can be depicted as below
CENTOS 7 VM/ IP_ADDR = 192.168.121.9
WEB-APP MYSQL DB
Setup Details
Centos 7 VM ,running on Oracle virtualbox
Software’s to be installed are python,flask, flask_mysqldb,mysql,mysql-server,git
Installation commands for reference (should have internet access) :
yum install -y epel-release python python-devel mysql-devel redhat-rpm-config gcc git wget
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install -y mysql-server python-pip
pip install flask
pip install flask_mysqldb
systemctl start mysqld
systemctl disable firewalld
systemctl stop firewalld
cat /var/log/mysqld.log |grep "temporary password" |awk '{print $11}' > /var/tmp/mysql-passwd
mysql -u root -p`cat /var/tmp/mysql-passwd`
ALTER USER 'root'@'localhost' IDENTIFIED BY 'HardPassword*1';
uninstall plugin validate_password;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';
exit;
Upload data to the database :
Mysql server should already be running , connect to the mysql as below , then create
database/table and upload data
mysql -u root –p
CREATE DATABASE tel_dir;
use tel_dir;
CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
country VARCHAR(40) NOT NULL,
phone INT NOT NULL,
PRIMARY KEY(id));
use tel_dir;
INSERT INTO details
(id,name,country,phone)
VALUES
(1,"kiran","india",12345);
INSERT INTO details
(name,country,phone)
VALUES
("bart","belgium",34567);
Download application code from github as below
git clone https://github.com/kiranpampana/kiran-app.git
Running above would download code to directory kiran-app, go to directory kiran-app/app
and check the code in app.py
cd kiran-app/app
cat app.py
Now run the application as below
python app.py localhost
Connect to web browser and check both the links below, ensure no firewalls are blocking
(ip address of my centos7 vm is 192.168.121.9 , you have to use the ip of your VM)
http://192.168.121.9:5000
http://192.168.121.9:5000/tel_dir
Part 2 :Deploy application with in Containers
Application can be depicted as below
CENTOS 7 VM /(IP_ADDR = 192.168.121.9)
APP
CONTAINER
DB
CONTAINER
DOCKER
Setup Details
Centos 7 VM ,running on Oracle virtualbox (same as the earlier one)
Install docker and start it
yum install –y docker
systemctl enable docker
systemctl start docker
Create and Start database container as below
docker run -itd --name db -e MYSQL_ROOT_PASSWORD=password
mysql
Connect to container
docker exec –it db bash
connect to the mysql as below , then create database/table and
upload data
mysql -u root –p
CREATE DATABASE tel_dir;
use tel_dir;
CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
country VARCHAR(40) NOT NULL,
phone INT NOT NULL,
PRIMARY KEY(id));
use tel_dir;
INSERT INTO details
(id,name,country,phone)
VALUES
(1,"kiran","india",12345);
INSERT INTO details
(name,country,phone)
VALUES
("bart","belgium",34567);
• Go to directory having earlier downloaded kiran-app git repository ,it should have Dockerfile ,verify that file
# cd ~/kiran-app
# cat Dockerfile
Build the docker image as below using Dockerfile
# docker build -t kiranpampana/kiran-app .
Upload the docker image having the app to the dockerhub for later use
# docker login
# docker push kiranpampana/kiran-app
Start the app container using IP of db container as below
#docker inspect db |grep "IPAddress"
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
# docker run -itd -p 63317:5000 --name app -e MYSQL_HOST=172.17.0.2 kiranpampana/kiran-app
Connect to web browser and check both the links below, ensure no firewalls are blocking
(ip address of my centos7 vm is 192.168.121.9 , you have to use the ip of your VM)
http://192.168.121.9:63317
http://192.168.121.9:63317/tel_dir
Part 3 : Deploy application in openshift
Setup Details
Openshift Origin 1.5.1 installed on centos 7 machines (google cloud)
Openshift cluster has 1 master and 2 minion nodes.
Openshift cluster
o-master o-node2
o-node1
Application in openshift can be depicted as below
Pod  Pod is a group of ONE or more containers
Internet route
(HA PROXY/LOAD BALANCER)
service
(Internal proxy/load
balancer)
Pod1 Pod2
• Login into o-master and download git as below
git clone https://github.com/kiranpampana/kiran-app.git
Running above would download code to directory kiran-app, go to directory kiran-app/ and check , you should various
yaml files
We shall deploy the app now
Check kiran-app.yaml file and try to understand its contents
Lets deploy application as below
oc create -f kiran-app.yaml
Check using below commands, pod with kiran-app should have been created
oc get pods
We shall create the service now for the app
Check kiran-svc.yaml file and try to understand its contents
Let create the services as below
oc create -f kiran-svc.yaml
Check using below commands , new service with name kiran-app should have been created
oc get svc
We shall create a route for the kiran-app service as below
oc expose svc kiran-app
Check the new route created as below
oc get route
Use the route obtained above to access the app , for my case its
http://kiran-app-my-test.apps.kiran-pampana.tk
Try to access http://kiran-app-my-test.apps.kiran-pampana.tk/tel_dir ,it
should through error because db is not yet created
Pod kiran-app****
(oc create –f kiran-app.yaml)
Service kiran-app
(oc create –f kiran-svc.yaml)
Route kiran-app-my-test.apps.kiran-pampana.tk
(oc expose svc kiran-app)
Mysql
db
We shall deploy the db now
Check mysql-db.yaml file and try to understand its contents
Lets deploy application as below
oc create -f mysql-db.yaml
Check using below commands, pod with mysql-** should have been created
oc get pods
We shall create the service now for the app
Check mysql-svc.yaml file and try to understand its contents
Let create the services as below
oc create -f mysql-svc.yaml
Check using below commands , new service with name mysql should have been created
oc get svc
Connect to the mysql pod as below after by identifying it
oc get pods
oc rsh mysql-***
Connect to database and upload data as below
mysql -u root –p
CREATE DATABASE tel_dir;
use tel_dir;
CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
country VARCHAR(40) NOT NULL,
phone INT NOT NULL,
PRIMARY KEY(id));
use tel_dir;
INSERT INTO details
(id,name,country,phone)
VALUES
(1,"kiran","india",12345);
INSERT INTO details
(name,country,phone)
VALUES
("bart","belgium",34567);
Pod kiran-app****
(oc create –f kiran-app.yaml)
Service kiran-app
(oc create –f kiran-svc.yaml)
Route kiran-app-my-test.apps.kiran-pampana.tk
(oc expose svc kiran-app)
Try to access http://kiran-app-my-test.apps.kiran-pampana.tk/tel_dir ,it should work
Service mysql
(oc create –f mysql-svc.yaml)
Pod mysql-****
(oc create –f mysql-db.yaml)
Thank you

More Related Content

Similar to Openshift Presentation ppt compare with VM (20)

PPTX
Open shift enterprise 3.1 paas on kubernetes
Samuel Terburg
 
PPTX
Open shift enterprise 3.1 paas on kubernetes
Samuel Terburg
 
PDF
Open shift and docker - october,2014
Hojoong Kim
 
PDF
Open shift and docker - october,2014
Hojoong Kim
 
PDF
Can I Contain This?
Eficode
 
PDF
Can I Contain This?
Eficode
 
PDF
Openshift: The power of kubernetes for engineers - Riga Dev Days 18
Jorge Morales
 
PDF
Openshift: The power of kubernetes for engineers - Riga Dev Days 18
Jorge Morales
 
PDF
Butter bei die Fische - Ein Jahr Entwicklung und Produktion mit Docker
johannesunterstein
 
PDF
Butter bei die Fische - Ein Jahr Entwicklung und Produktion mit Docker
johannesunterstein
 
PPTX
The Future of Web Application Architectures
Lucas Carlson
 
PPTX
The Future of Web Application Architectures
Lucas Carlson
 
PDF
Containerizing legacy applications
Andrew Kirkpatrick
 
PDF
Containerizing legacy applications
Andrew Kirkpatrick
 
PDF
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Ambassador Labs
 
PDF
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Ambassador Labs
 
PDF
Openshift cheat rhce_r3v1 rhce
Darnette A
 
PDF
Openshift cheat rhce_r3v1 rhce
Darnette A
 
ODP
Openshift: Build, deploy & manage open, standard containers
Jonh Wendell
 
ODP
Openshift: Build, deploy & manage open, standard containers
Jonh Wendell
 
Open shift enterprise 3.1 paas on kubernetes
Samuel Terburg
 
Open shift enterprise 3.1 paas on kubernetes
Samuel Terburg
 
Open shift and docker - october,2014
Hojoong Kim
 
Open shift and docker - october,2014
Hojoong Kim
 
Can I Contain This?
Eficode
 
Can I Contain This?
Eficode
 
Openshift: The power of kubernetes for engineers - Riga Dev Days 18
Jorge Morales
 
Openshift: The power of kubernetes for engineers - Riga Dev Days 18
Jorge Morales
 
Butter bei die Fische - Ein Jahr Entwicklung und Produktion mit Docker
johannesunterstein
 
Butter bei die Fische - Ein Jahr Entwicklung und Produktion mit Docker
johannesunterstein
 
The Future of Web Application Architectures
Lucas Carlson
 
The Future of Web Application Architectures
Lucas Carlson
 
Containerizing legacy applications
Andrew Kirkpatrick
 
Containerizing legacy applications
Andrew Kirkpatrick
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Ambassador Labs
 
Velocity NYC 2017: Building Resilient Microservices with Kubernetes, Docker, ...
Ambassador Labs
 
Openshift cheat rhce_r3v1 rhce
Darnette A
 
Openshift cheat rhce_r3v1 rhce
Darnette A
 
Openshift: Build, deploy & manage open, standard containers
Jonh Wendell
 
Openshift: Build, deploy & manage open, standard containers
Jonh Wendell
 

Recently uploaded (20)

PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
DOCX
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PDF
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
PPTX
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
DOC
MRRS Strength and Durability of Concrete
CivilMythili
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Hashing Introduction , hash functions and techniques
sailajam21
 
8th International Conference on Electrical Engineering (ELEN 2025)
elelijjournal653
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
VITEEE 2026 Exam Details , Important Dates
SonaliSingh127098
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
Day2 B2 Best.pptx
helenjenefa1
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
GTU Civil Engineering All Semester Syllabus.pdf
Vimal Bhojani
 
PORTFOLIO Golam Kibria Khan — architect with a passion for thoughtful design...
MasumKhan59
 
GitOps_Without_K8s_Training simple one without k8s
DanialHabibi2
 
MRRS Strength and Durability of Concrete
CivilMythili
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
Ad

Openshift Presentation ppt compare with VM

  • 1. Openshift for Beginners: Demo on building and deploying application from scratch with in Openshift
  • 2. Download the PPT and code from github as below # git clone https://github.com/kiranpampana/kiran-app.git Our application is a telephone directory which displays username/country and phone number . Application has 2 parts • 1) Web app built using Python and Flask framework • 2)MYSQL database holds user data that is being used by web app WEBAPP MYSQL DATABASE
  • 3. Pages displayed by the app • First page is a Welcome page with information • Second page is displaying details accessed from a mysql database
  • 4. We need to know about containers/pods. But why ? Pods are the basic building blocks of Openshift. Pod is a group of one or more containers. What are containers ? Lets find out why we need containers and understand them by comparing with Virtual machines , as VM’s are well understood
  • 5. PHYSICAL MACHINE HARDWARE (CPU/RAM/DISK) OPERATING SYSTEM USER SPACE KERNEL SPACE DB1 APP3 APP2 APP1 TRADITIONAL
  • 6. What are the problems with traditional system ?
  • 7. 1) Security, as files of one app can be viewed by another app owner 2) Resource exploitation by any app 3) If an app needs reboot , it impacts other apps as well 4) ………………. 5) ……….. 6) ... PHYSICAL MACHINE HARDWARE (CPU/RAM/DISK) OPERATING SYSTEM USER SPACE KERNEL SPACE A P P 1 A P P 2 A P P 3
  • 8. In-order to address problems with traditional system we need Physical or Logical separation between applications
  • 9. Virtualization and containerization provide logical separation for Applications
  • 10. PHYSICAL MACHINE HARDWARE (CPU/RAM/DISK) HYPERVISOR KERNEL VIRTUAL HW1 VM1 OS USER SPACE1 VM1 KERNEL A PP 1 VIRTUAL HW2 VM2 OS VM2 KERNEL USER SPACE2 A PP 2 PHYSICAL MACHINE HARDWARE (CPU/RAM/DISK) OPERATING SYSTEM KERNEL CONTAINER 1 CONTAINER 2 USER SPACE1 USER SPACE2 A PP 1 A PP 2 VIRTUALIZATION CONTAINERIZATION
  • 11. Containerization Virtualization Are about virtualizing the operating system subsystems(Network,Filesystems,Process…) Based on emulating Hardware or are about virtualizing hardware Single kernel Multiple kernels Initially embraced by service providers Initially embraced by enterprises Under resource crunch containers are stable then VMs as only one kernel tries to solve problem Under resource crunch VM's running on hypervisors are unstable as one+ kernels start to solve the same problem Lightness makes them far more dense and elastic Less elasticity and density
  • 12. We need to know about docker . But why ? Docker is a tool for managing containers .Rkt is similar tool like docker . Openshift uses docker
  • 13. PHYSICAL MACHINE HARDWARE (CPU/RAM/DISK) OPERATING SYSTEM KERNEL CONTAINER 2 USER SPACE 2 APP2 CONTAINER 1 USER SPACE 1 APP1 DOCKER
  • 14. Demo is consisting of 3 parts Part 1: Deploy application on a Machine Part 2 :Deploy application with in Containers Part 3: Deploy application with in Openshift
  • 15. Part 1: Deploy application on a Machine Application can be depicted as below CENTOS 7 VM/ IP_ADDR = 192.168.121.9 WEB-APP MYSQL DB
  • 16. Setup Details Centos 7 VM ,running on Oracle virtualbox Software’s to be installed are python,flask, flask_mysqldb,mysql,mysql-server,git Installation commands for reference (should have internet access) : yum install -y epel-release python python-devel mysql-devel redhat-rpm-config gcc git wget wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm rpm -ivh mysql57-community-release-el7-9.noarch.rpm yum install -y mysql-server python-pip pip install flask pip install flask_mysqldb systemctl start mysqld systemctl disable firewalld systemctl stop firewalld cat /var/log/mysqld.log |grep "temporary password" |awk '{print $11}' > /var/tmp/mysql-passwd mysql -u root -p`cat /var/tmp/mysql-passwd` ALTER USER 'root'@'localhost' IDENTIFIED BY 'HardPassword*1'; uninstall plugin validate_password; ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; exit;
  • 17. Upload data to the database : Mysql server should already be running , connect to the mysql as below , then create database/table and upload data mysql -u root –p CREATE DATABASE tel_dir; use tel_dir; CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, country VARCHAR(40) NOT NULL, phone INT NOT NULL, PRIMARY KEY(id)); use tel_dir; INSERT INTO details (id,name,country,phone) VALUES (1,"kiran","india",12345); INSERT INTO details (name,country,phone) VALUES ("bart","belgium",34567);
  • 18. Download application code from github as below git clone https://github.com/kiranpampana/kiran-app.git Running above would download code to directory kiran-app, go to directory kiran-app/app and check the code in app.py cd kiran-app/app cat app.py Now run the application as below python app.py localhost Connect to web browser and check both the links below, ensure no firewalls are blocking (ip address of my centos7 vm is 192.168.121.9 , you have to use the ip of your VM) http://192.168.121.9:5000 http://192.168.121.9:5000/tel_dir
  • 19. Part 2 :Deploy application with in Containers Application can be depicted as below CENTOS 7 VM /(IP_ADDR = 192.168.121.9) APP CONTAINER DB CONTAINER DOCKER
  • 20. Setup Details Centos 7 VM ,running on Oracle virtualbox (same as the earlier one) Install docker and start it yum install –y docker systemctl enable docker systemctl start docker
  • 21. Create and Start database container as below docker run -itd --name db -e MYSQL_ROOT_PASSWORD=password mysql Connect to container docker exec –it db bash
  • 22. connect to the mysql as below , then create database/table and upload data mysql -u root –p CREATE DATABASE tel_dir; use tel_dir; CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, country VARCHAR(40) NOT NULL, phone INT NOT NULL, PRIMARY KEY(id)); use tel_dir; INSERT INTO details (id,name,country,phone) VALUES (1,"kiran","india",12345); INSERT INTO details (name,country,phone) VALUES ("bart","belgium",34567);
  • 23. • Go to directory having earlier downloaded kiran-app git repository ,it should have Dockerfile ,verify that file # cd ~/kiran-app # cat Dockerfile Build the docker image as below using Dockerfile # docker build -t kiranpampana/kiran-app . Upload the docker image having the app to the dockerhub for later use # docker login # docker push kiranpampana/kiran-app Start the app container using IP of db container as below #docker inspect db |grep "IPAddress" "SecondaryIPAddresses": null, "IPAddress": "172.17.0.2", # docker run -itd -p 63317:5000 --name app -e MYSQL_HOST=172.17.0.2 kiranpampana/kiran-app Connect to web browser and check both the links below, ensure no firewalls are blocking (ip address of my centos7 vm is 192.168.121.9 , you have to use the ip of your VM) http://192.168.121.9:63317 http://192.168.121.9:63317/tel_dir
  • 24. Part 3 : Deploy application in openshift Setup Details Openshift Origin 1.5.1 installed on centos 7 machines (google cloud) Openshift cluster has 1 master and 2 minion nodes. Openshift cluster o-master o-node2 o-node1
  • 25. Application in openshift can be depicted as below Pod  Pod is a group of ONE or more containers Internet route (HA PROXY/LOAD BALANCER) service (Internal proxy/load balancer) Pod1 Pod2
  • 26. • Login into o-master and download git as below git clone https://github.com/kiranpampana/kiran-app.git Running above would download code to directory kiran-app, go to directory kiran-app/ and check , you should various yaml files We shall deploy the app now Check kiran-app.yaml file and try to understand its contents Lets deploy application as below oc create -f kiran-app.yaml Check using below commands, pod with kiran-app should have been created oc get pods We shall create the service now for the app Check kiran-svc.yaml file and try to understand its contents Let create the services as below oc create -f kiran-svc.yaml Check using below commands , new service with name kiran-app should have been created oc get svc
  • 27. We shall create a route for the kiran-app service as below oc expose svc kiran-app Check the new route created as below oc get route Use the route obtained above to access the app , for my case its http://kiran-app-my-test.apps.kiran-pampana.tk Try to access http://kiran-app-my-test.apps.kiran-pampana.tk/tel_dir ,it should through error because db is not yet created
  • 28. Pod kiran-app**** (oc create –f kiran-app.yaml) Service kiran-app (oc create –f kiran-svc.yaml) Route kiran-app-my-test.apps.kiran-pampana.tk (oc expose svc kiran-app) Mysql db
  • 29. We shall deploy the db now Check mysql-db.yaml file and try to understand its contents Lets deploy application as below oc create -f mysql-db.yaml Check using below commands, pod with mysql-** should have been created oc get pods We shall create the service now for the app Check mysql-svc.yaml file and try to understand its contents Let create the services as below oc create -f mysql-svc.yaml Check using below commands , new service with name mysql should have been created oc get svc
  • 30. Connect to the mysql pod as below after by identifying it oc get pods oc rsh mysql-*** Connect to database and upload data as below mysql -u root –p CREATE DATABASE tel_dir; use tel_dir; CREATE TABLE details( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100) NOT NULL, country VARCHAR(40) NOT NULL, phone INT NOT NULL, PRIMARY KEY(id)); use tel_dir; INSERT INTO details (id,name,country,phone) VALUES (1,"kiran","india",12345); INSERT INTO details (name,country,phone) VALUES ("bart","belgium",34567);
  • 31. Pod kiran-app**** (oc create –f kiran-app.yaml) Service kiran-app (oc create –f kiran-svc.yaml) Route kiran-app-my-test.apps.kiran-pampana.tk (oc expose svc kiran-app) Try to access http://kiran-app-my-test.apps.kiran-pampana.tk/tel_dir ,it should work Service mysql (oc create –f mysql-svc.yaml) Pod mysql-**** (oc create –f mysql-db.yaml)