Instructions for deploy:
Warning: All steps must be executed as ordered and full path to json data must be provided.
- Create dir "/Users/jstojanovic/doodle/testpg/mnt/data" (chmod 755) and it must be empty
- Provide full path to data.json file: kubectl create configmap initial-data --from-file=data.json
- kubectl apply -f postgres-storage.yaml
- kubectl apply -f postgres-configmap.yaml
- kubectl apply -f sql-init-scripts.yaml //this step will import data into db
- kubectl apply -f postgres-deployment.yaml
- kubectl apply -f postgres-service.yaml
- kubectl apply -f doodle.yaml
How to use:
get ip:port -> url = minikube service doodle --url
curl -v
curl -X GET -v $(minikube service doodle --url)/doodle/users/polls -d from="2017-01-25 00:00:00" -d to="2017-01-26 00:00:00"
For improvement:
- It was possible to solve postgres-*.yamls then doodle.yaml dependency with Readiness Probes, but there was not enough time.
- I decided to put data in pg because it has good support for json and i was more comfortable with, but improvement is definitely nosql db.
- This approach can be slow for a lot of data, indexes can be created.
- User with space in path - bad solution. Also i prefer to have some business key, say userId, but I didn't have enough time to implement it
- Spring boot, because you are using it and i wanted to try it for first time.
- I couldn't find a way to search text with jsonb, so i used java streams. There is also one point to improve contains is case sensitive.
- Also this time filter can be done on more sophisticated way
- Tests...
- Yaml files should not be in project
- Jsonb is converted in string but will be better if it was Object
Clean: kubectl delete service postgres kubectl delete service doodle kubectl delete deployment postgres kubectl delete deployment doodle kubectl delete configmap initial-data kubectl delete configmap postgres-config kubectl delete persistentvolumeclaim postgres-pv-claim kubectl delete persistentvolume postgres-pv-volume