name: SPRING_DATASOURCE_USERNAME # Name of the environment variable Memory: "1Gi" # This Spring Boot App needs around 700 MB MemoryĮnv: # Environment variables supplied to the Pod Image: ajtechdeveloper/springbootmysql-app:latestĬontainerPort: 4000 # The port that the container exposes Spec: # Specification for the containers that will be run in the Pods Labels: # Labels that will be applied to each Pod in this deployment Template: # Template for creating the pods in this deployment MatchLabels: # The deployment applies to any pods mayching the specified labels of replicas (or) pods to run in this deployment Labels: # Labels that will be applied to this resource Name: springbootmysql-app-server # Name of the Kubernetes resource Kind: Deployment # Type of Kubernetes resource
SPRING BOOT CRUD EXAMPLE WITH MYSQL PASSWORD
Installation location bin folder and login to the database using theĬommand below, use the password r00t when prompted:ĭ:\Programs\mysql-5.7.19-win圆4\bin>mysql -u root -p -h 127.0.0.1
SPRING BOOT CRUD EXAMPLE WITH MYSQL WINDOWS
The open a new windows command prompt window, navigate to the MySQL $ kubectl port-forward springbootmysql-app-mysql-7fbc9f88cc-7kxgk 3306:3306 Then you can use an installed existing MySQLĬlient in your computer to log into the database. Port forward the pod's port 3306 to your computer localhost Springbootmysql-app-mysql-7fbc9f88cc-7kxgk 1/1 Running 3 7d17h To log into the MySQL database pod, get its pod name using the command $ kubectl apply -f /d/projects/gitprojects/SpringBootMySQL/deployments/mysql-deployment.yaml To deploy this in Minikube, we use the kubectl command below: Volumes: # A PersistentVolume is mounted as a volume to the Pod name: mysql-persistent-storage # This name should match the name specified in `volumes.name` containerPort: 3306 # The port that the container exposes ValueFrom: # Read environment variables from kubernetes secrets Spec: # The spec for the containers that will be run inside the Pods in this deploymentĮnv: # Environment variables passed to the container Labels: # Labels to be applied to the Pods in this deployment Template: # Template for Pods in this deployment MatchLabels: # This deployment applies to the Pods matching the specified labels Labels: # Labels applied to this deployment Name: springbootmysql-app-mysql # Name of the deployment Kind: Deployment # Type of kubernetes resource Selector: # Selects any Pod with labels `app=springbootmysql-app,tier=mysql` Labels: # Labels that will be applied to the resource Name: springbootmysql-app-mysql # Name of the resource Kind: Service # Type of kubernetes resource ReadWriteOnce # ReadWriteOnce means that the volume can be mounted as read-write by a single Node StorageClassName: standard # Request certain storage class Spec: # Access mode and the resource limits Kind: PersistentVolumeClaim # Create PersistentVolumeClaim to request a PersistentVolume storage But it is not yet available for another claim because the previous claimant’s data remains on the volume. PersistentVolumeReclaimPolicy: Retain # Retain the PersistentVolume even after PersistentVolumeClaim is deleted. It uses a file (or)directory on the Node to emulate the network-attached storage HostPath: # hostPath PersistentVolume is used for both development and testing. A PersistentVolume Claim requesting the same storageClass can be bound to this volume. StorageClassName: standard # Storage class. Kind: PersistentVolume # Create PersistentVolume which is required for MySQL Database You can understand the yaml file by reading the If you observe in this yaml, I am using the image: We will useīoth Kubernetes Secrets and Kubernetes Persistent Volume in this yaml file.
NoteServiceJPATest.java package MySQL Database deployment, a yaml files needs to be created. Import = class Note implements Serializable Demo project for Spring Boot with FreeMarker template