Hello guys.
I'm trying to have 3 deployments :
- Mysql database
- Backend
- Frontend
On docker desktop.
The Issue is that the backend fails to connect to the database. Here are my files:
application.properties
spring.application.name=commune-connect
spring.flyway.locations=classpath:db/migration
spring.datasource.url=jdbc:mysql://localhost:3306/communeconnect?autoReconnect=true
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=example
spring.flyway.enabled=false
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
skaffold.yml
apiVersion: skaffold/v2beta29
kind: Config
metadata:
name: commune-connect
build:
artifacts:
- image: mysql
context: .
docker:
dockerfile: Dockerfile-mysql
- image: commune-connect-backend
context: ./backend
docker:
dockerfile: Dockerfile
- image: commune-connect-frontend
context: ./frontend
docker:
dockerfile: Dockerfile
deploy:
kubectl:
manifests:
- k8s/mysql-deployment.yaml
- k8s/backend-deployment.yaml
- k8s/frontend-deployment.yaml
portForward:
- resourceType: deployment
resourceName: backend-deployment
port: 8080
localPort: 8080
- resourceType: deployment
resourceName: frontend-deployment
port: 80
localPort: 4200
- resourceType: deployment
resourceName: mysql-deployment
port: 3306
localPort: 3306
And the deployment files (not including frontend as it is irrelevant here)
backend-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-deployment
spec:
replicas: 2
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: commune-connect-backend:latest
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
selector:
app: backend
ports:
- protocol: TCP
port: 8080
targetPort: 8080
type: ClusterIP
mysql-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:latest
env:
- name: MYSQL_ROOT_PASSWORD
value: "example"
- name: MYSQL_DATABASE
value: "communeconnect"
ports:
- containerPort: 3306
---
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
selector:
app: mysql
ports:
- protocol: TCP
port: 3306
targetPort: 3306
Here are the related logs:
Mysql deployment pod: https://pastebin.com/DniPLuU2
Backend deployment pod: https://pastebin.com/YDyLpGgB
Im super confused
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.