This project demonstrates how you use Kubernetes to orchestrate a simple web-app.
This project utlize TypeScript/Vue/Quasar for the frontend, Java Spring Boot with JDBC for the backend and MySQL for database - all running in separated containers/pods.
- Create monolit git repo
- Create frontend and backend projects:
- Frontend: Quasar CLI:
npm init quasar
cd frontend
andnpm install
(for dev dependencies)- Backend: Create Spring Boot install file with Maven - https://start.spring.io/
- Add the following in /backend/pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
- Rename the respective folders from the default names to frontend/backend
- Install with homebrew:
brew install mysql
- Run:
brew services start mysql
- Secure/Set password:
mysql_secure_installation
- Verify:
mysql --version
docker exec -it db-mysql mysql -u root -p
and enter root pw.- Create New User:
CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'myuser'@'%';
- Test User:
mysql -h 127.0.0.1 -P 3307 -u myuser -p
- Start up all instances with
docker-compose up
- In the
src/main/resources/application.properties
file in backend we exponse port 5000 to the docker network by addingserver.port=5000
. - Open a docker interactive shell on frontend instance
docker exec -it frontend /bin/sh
- Use curl to test the API:
curl "http://backend:5000/customers/who-bought?productName=Blue%20Jeans&color=Blue&size=L&brand=DenimCo"
Below instructions only apply for macOS.
- Install Kubernetes kompose:
brew install kompose
- Install Minicube:
brew install minikube
- Run command:
kompose convert
- Start Docker Application
- Start Minicube:
minikube start
- Run
apply-k8.sh
to add files to minicube. - Open minikube dashboard:
minikube dashboard
- Delete all pods:
kubectl delete all --all
- Apply manifest:
kubectl apply -f k8s-manifest.yaml