1
resposta

Conexão com a base de dados

APP:

deployment.yml

apiVersion: apps/v1
kind: Deployment
metadata:
    name: aplicacao-deployment
spec:
    selector:
        matchLabels:
            name: aplicacao-pod
    template:
        metadata:
            labels:
                name: aplicacao-pod
        spec:
            containers:
                - name: container-app-loja
                  image: rafanercessian/aplicacao-loja:v1
                  ports:
                      - containerPort: 80

service.yml

apiVersion: v1
kind: Service
metadata:
  name: servico-aplicacao
spec:
  type: LoadBalancer
  ports:
    - port: 80
  selector:
    name: aplicacao-pod

DB

permission.yml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: app-db-permission
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi

service.yml

apiVersion: v1
kind: Service
metadata:
  name: db
spec:
  type: ClusterIP
  ports:
    - port: 3306
  selector:
    name: app-db

statefulset.yml

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: statefulset-app-db
spec:
  selector:
    matchLabels:
      name: app-db
  serviceName: db
  template:
    metadata:
      labels:
        name: app-db
    spec:
      containers:
        - name: app-db-container
          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: app-db-volume
              mountPath: /var/lib/mysql
      volumes:
        - name: app-db-volume
          persistentVolumeClaim:
            claimName: app-db-permission

Mensagem de 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
1 resposta

Olá César, tudo bem? Você poderia fornecer pra gente o conteúdo do arquivo conecta.php, porque como o erro foi originado nele precisamos verificar esse arquivo!