Using Springboot 2.2.4 and a local distribution of Openshift (Minishift, Kubernetes Master 1.11, Openshift Web Console 3.11).
The app itself is just a spring-boot-starter-data-rest CRUD for a simple Employee entity configured in a pod within Openshift. The data source is a MySQL service in another container.
On deployment some data is loaded in the employee table. Just 4 employees for testing purposes.
DROP TABLE IF EXISTS employee;
CREATE TABLE employee (
id int(11) NOT NULL AUTO_INCREMENT,
first_name varchar(45) DEFAULT NULL,
last_name varchar(45) DEFAULT NULL,
email varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
);
--
-- Data for table `employee`
--
INSERT INTO employee VALUES
(1,'Leslie','Andrews','leslie@luv2code.com'),
(2,'Emma','Baumgarten','emma@luv2code.com'),
(3,'Avani','Gupta','avani@luv2code.com'),
(4,'Yuri','Petrov','yuri@luv2code.com');
Everything works perfect. All of the endpoints are well published and all works perfectly.
But just out for curiosity, I am trying to connect some mysql viewer to check the data that it is loaded on startup and changed later on API usage. But I can't find the table anywhere. I am trying two ways:
configmap.yml
apiVersion: v1
kind: ConfigMap
metadata:
name: spring-boot-bootstrap
data:
application.properties: |-
spring.datasource.url=jdbc:mysql://mydatabase:3306/mydatabase
fabric8\deployment.yml
spec:
template:
spec:
containers:
- env:
- name: SPRING_PROFILES_ACTIVE
value: mysql
- name: SPRING_DATASOURCE_USER
valueFrom:
secretKeyRef:
name: mydatabase
key: database-user
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
name: mydatabase
key: database-password
livenessProbe:
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 180
readinessProbe:
httpGet:
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 30
Any idea?
Postgres have the same behaver.
Entering the Postgres container and going through command line (Postgres command). I connect to the database, but it is empty (no tables).
I use minishift.
jdbc:postgresql://localhost:25432/pstgrs1 work in client. I used spring app, it works, but table is empty.
Example DROP TABLE IF EXISTS cities; CREATE TABLE cities(id serial PRIMARY KEY, name VARCHAR(255), population integer);