This my first project with k8s and I m trying to deploy my app with 2 images from docker hub database and web(laravel) , i Used Kompose which is a tool to translate my docker-compose to k8s components, that generated:
db-deployment.yaml,db-claim0-persistentvolumeclaim.yaml,db-service.yaml,web-deployment.yaml, web-service.yaml and network-networkpolicy.yaml .
Ps: For now i m not using configmap,secret or ingress.
well almost works fine just when i check my localhost i get this error :
Illuminate\Database\QueryException SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution (SQL: select * from users
where id
= 2 and users
. deleted_at
is null limit 1)
With Docker-compose everything works fine locally. I Already, link where the problem should be fixed with changing DB-Host but i have no clue.
----------------------------
----------------------------
docker-compose file:
services:
attendize_web:
image: dolking/ica-attendize
depends_on:
- attendize_db
working_dir: /usr/src/app
environment:
NGINX_ROOT: /usr/src/app/public
DB_CONNECTION: mysql
DB_DRIVER: mysql
DB_HOST: attendize_db
DB_PORT: 3306
ports:
- "8001:80"
networks:
- app_network
attendize_db:
image: mysql:5
restart: always
environment:
MYSQL_DATABASE: "preprodica"
MYSQL_ROOT_PASSWORD: "Str0ngDBP@ssw0rd"
MYSQL_USER: "dhia"
MYSQL_PASSWORD: "dhiaammar"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "3306:3306"
volumes:
- "./storage/db-data:/var/lib/mysql"
networks:
- app_network
networks:
app_network:
driver: bridge
----------------------------
----------------------------
attendize-db-deployment.yaml file :
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: attendize-db
name: attendize-db
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: attendize-db
strategy:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.network/app_network: "true"
io.kompose.service: attendize-db
spec:
containers:
- env:
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "yes"
- name: MYSQL_DATABASE
value: "preprodica"
- name: MYSQL_PASSWORD
value: "dhiaammar"
- name: MYSQL_ROOT_PASSWORD
value: "Str0ngDBP@ssw0rd"
- name: MYSQL_USER
value: "dhia"
image: mysql:5
name: attendize-db
ports:
- containerPort: 3306
resources: {}
volumeMounts:
- mountPath: /var/lib/mysql
name: attendize-db-claim0
restartPolicy: Always
volumes:
- name: attendize-db-claim0
persistentVolumeClaim:
claimName: attendize-db-claim0
status: {}
----------------------------
----------------------------
attendize-web-deployment.yaml file :
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.service: attendize-web
name: attendize-web
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: attendize-web
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert
kompose.version: 1.22.0 (955b78124)
creationTimestamp: null
labels:
io.kompose.network/app_network: "true"
io.kompose.service: attendize-web
spec:
containers:
- env:
- name: DB_CONNECTION
value: mysql
- name: DB_DRIVER
value: mysql
- name: DB_HOST
value: attendize_db
- name: DB_PORT
value: "3306"
- name: NGINX_ROOT
value: /usr/src/app/public
image: dolking/attendize-diginov
name: attendize-web
ports:
- containerPort: 80
resources: {}
workingDir: /usr/src/app
restartPolicy: Always
status: {}