This application demonstrates the capabilities of Spring Security in authenticating users based on their roles
- Java 21
- Spring Boot 3.1.4
- Spring Security
- Docker 24.0.6
- Kubernetes (minikube)
- Maven 3.9.5
- MySQL 8.0.34
To run this project locally
-
Clone this repository
-
Navigate to the project root directory and install it by running the following command on the terminal:
./mvnw clean install -DskipTests
-
Setup Docker by logging into docker from the terminal.
-
Setup Kubernetes:
minikube start eval $(minikube docker-env)
-
Setup project database in Kubernetes by navigating to the
k8s
directory and issue the following commands:cd /k8s kubectl apply -f db-configmap.yaml kubectl apply -f db-root-credentials.yaml kubectl apply -f db-credentials.yaml kubectl apply -f db-deployment.yaml
OPTIONAL: You can run the following commands to interact with MySQL:
kubectl run -it --rm --image=mysql:latest --restart=Never mysql-client -- mysql -h mysql -uroot -ptoor
The above command will create a
mysql-client
and present a mysql prompt in the terminal like: -
Navigate back to the root directory where the
Dockerfile
is domiciled and build the application image using docker by running:cd .. docker build -t <your-dockerhub-username>/springboot-k8s-mysql:v1 .
-
Setup the main application by navigating again to the
k8s
folder and issue the following command in the terminal within k8s folderkubectl apply -f app-deployment.yaml
-
You can check the state of your pods, deployments and services by running the following commands in the terminal
kubectl get pods
kubectl get deployments
kubectl get services
-
OPTIONAL: clean kubernetes workspace by running the following commands in that order:
kubectl delete deployments --all kubectl delete services --all kubectl delete pvc --all kubectl delete pv --all kubectl delete secrets --all kubectl delete configmaps --all