0
respostas

Aula 4 do Kubernetes

Não estou conseguindo acessar o banco de dados no cap 4 do curso. Sempre me retorna o erro :

Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/conecta.php on line 4

Warning: mysqli_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/html/conecta.php on line 4

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /var/www/html/banco-categoria.php on line 7

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/html/banco-categoria.php on line 8

Me parece que não acha o nome da maquina que esta o banco de dados, segue meu arquivos de configuração

apiVersion: v1
kind: Service
metadata:
 name: db
spec:
 type: ClusterIP
 ports:
  - protocol: TCP
    port: 3306
    targetPort: 3306
 selector:
  app: mysql
apiVersion: apps/v1 
kind: StatefulSet
metadata:
 name: statefulset-mysql
 labels:
   app: statefulset-mysql
spec:
 serviceName: db
 selector:
  matchLabels:
   app: mysql
 template:
  metadata:
   labels:
    app: mysql
  spec:   
   containers:
    - name: container-mysql
      image: mysql:5.7.19
      ports:
       - containerPort: 3306
      env:
       - name: MYSQL_DATABASE
         value: "loja"
       - name: MYSQL_USER
         value: "root"
       - name: MYSQL_ALLOW_EMPTY_PASSWORD
         value: "1"
      volumeMounts:
       - name: volume-mysql
         mountPath: /var/lib/mysql
   volumes:
    - name: volume-mysql
      persistentVolumeClaim:
       claimName: configuracao-mysql
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
 name: configuracao-mysql
spec:
 accessModes:
  - ReadWriteOnce
 resources:
  requests:
   storage: 3Gi