k8s poc
A very prilimiary project for proof of concept on following items,
Support multiplie user login
(re-implement session managment logic without spring-session and spring-security)Concurrent update control
Prerequisites
JDK 11+
Gradle 6.8
NodeJS v14
H2 DB v1.4.199
Redis 3.2
MariaDB Server 10.6 (Optional)
MySQL Workbench 8.0 CE
Docker Desktop (Optional)
To setup the environment and run the demo
Add below entry at C:\Windows\System32\drivers\etc\hosts
1 | 127.0.0.1 xxx.local.hk |
MariaDB (Optional)
- Download and install MariaDB
- Run the scripts in file config\MariaDB\create-db.txt to create database and data initialization.
H2 DB
- Go to config\h2 folder and run the script
h2_server.bat
in command prompt - Run below scripts to create database file in baseDir defined in
h2_server.bat
java -cp h2-1.4.199.jar org.h2.tools.Shell
1 | Welcome to H2 Shell 1.4.199 (2019-03-13) |
- Run the scripts in file config\MariaDB\create-db.txt to create tables and data initialization.
Redis
- Download and install Redis
- Backup the redis.windows-service.conf file in Redis Installation folder and replace it with config\redis\redis.windows-service.conf
- Run following commands with Adminstrator permission
net stop redis && net start redis
Go to session-service directory and run below script in command prompt
gradle build && java -Dcommon.properties=..\config\common.properties -jar build\libs\session-service-1.0.war
Go to login-service directory and run below script in command prompt
gradle build && java -Dcommon.properties=..\config\common.properties -jar build\libs\login-service-1.0.war
Go to profile-service directory and run below script in command prompt
gradle build && java -Dcommon.properties=..\config\common.properties -jar build\libs\profile-service-1.0.war
Go to frontend directory and run below script in command prompt
1 | npm install |
The project is also able to build and run with docker
- Build the services session-service, login-service and profile-service respectively by using Gradle
- Go to directory container and run following commands
- Build all images by command
build-all.bat
- Startup the application by command
startup-all.bat
- Create tables USER and SESSION, and corresponding records in MariaDB via MySQL Workbench
- Refer to above H2 DB section, create database, table and records
Test the application
- Open a new browser tab or window with the URL http://xxx-poc:3000/login in your address bar.
- To view the database structure open MySQL Workbench and input connection information from file config\mariadb\create-db.sql.
Next…
Deploy the code to OKD, minikube, CodeReady Containers and KinD later
Fix problem of PullImageErr even successfully validate new docker image from external registry for deployment
Add imagePullSecret under below YAML
1 | Administrator -> User Management -> Service Accounts -> default -> YAML |
Or run following script
openshift-deploy-an-application-from-private-registry
service_accounts in openshift
image-pull-secrets
1 | oc create secret docker-registry repo-secrect \ |
oc login
oc status
oc logs
oc describe pod
oc describe svc
oc get is
oc get pods
oc get svc
oc get routes
oc get deployment
oc del is
oc del pod
oc exec
oc rsh
oc debug dc
Redeploy images from repo.lab.company.com
oc delete deployment frontend
oc delete svc frontend
oc delete is frontend
oc delete route frontend
Check service account
oc describe sa
Create deployment
oc new-app repo.lab.company.com/myname/xxx-poc/login-service:latest –name=my-application
oc delete deployment application
1 |
|
odo login -umyname
odo project create quickstart
odo catalog list services
1 |
|