openshift katacoda

ansible ingo

Posted by datahawklab on May 28, 2021

Katacoda

go to: https://katacoda.com/courses/openshift/playground

generate sample project

1
2
3
4
5
mkdir apptest
cd apptest
git clone https://github.com/servidc/minishift_jdg_springboot_kafka_example
cd minishift_jdg_springboot_kafka_example
mvn clean install

generate mysql docker build

1
2
3
cd src/main/docker-files  ;
docker build -t springboot_mysql -f ./dockerfile_springboot_mysql .
docker pull openshift/mysql-56-centos7

creaet openshfit mysql pod

1
oc new-app -e MYSQL_USER=root -e MYSQL_PASSWORD=root -e MYSQL_DATABASE=test openshift/mysql-56-centos7

this shows local openshift access but interactive access like this is not idiomatic

1
2
3
4
5
6
oc rsh mysql-56-centos7-1-nvth9
mysql -u root
CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

create springboot mysql app in openshift

1
2
3
4
5
oc get pods
oc new-app -e spring_datasource_url=jdbc:mysql://172.30.188.236:3306/test mysql-56-centos7 --name=swapapp
oc get svc
oc expose svc springbootmysql
oc get route

alidate rest endpoints of app via curl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
curl -v http://swapapp-myproject.192.168.1.204.nip.io/demo/all
output:
[
{"name":"UBUNTU 17.10 LTS","lastaudit":1502409600000,"id":1},
{"name":"RHEL 7","lastaudit":1500595200000,"id":2},
{"name":"Solaris 11","lastaudit":1502582400000,"id":3}
]

curl http://swapapp-myproject.192.168.1.204.nip.io/demo/add?name=SpringBootMysqlTest
3Saved

curl http://swapapp-myproject.192.168.1.204.nip.io/demo/all
[
{"name":"UBUNTU 17.10 LTS","lastaudit":1502409600000,"id":1},
{"name":"RHEL 7","lastaudit":1500595200000,"id":2}
{"name":"Solaris 11","lastaudit":1502582400000,"id":3},
{"name":"SpringBootMysqlTest","lastaudit":1548892800000,"id":4}
]