Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

erro ao rodar "kubectl create -f statefulset.yaml"

ao rodar = kubectl create -f statefulset.yaml retorna erro: The StatefulSet "statefulset-mysql" is invalid:

  • spec.selector: Required value
  • spec.template.metadata.labels: Invalid value: map[string]string{"name":"mysql"}: selector does not match template labels
1 resposta
solução!

erro de Indentação corrigido usando programa yamllint:

apiVersion: apps/v1 kind: StatefulSet metadata: name: statefulset-mysql spec: selector: matchLabels: name: mysql serviceName: db template: metadata: labels: name: 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: Service metadata: name: db spec: type: ClusterIP ports:

- port: 3306

selector: name: mysql

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: configuracao-mysql spec: accessModes:

- ReadWriteOnce

resources: requests: storage: 3Gi