Estou recebendo este retorno ao executar os comando no GCP mas utilizando o Minikube localmente a aplicação sobe sem problemas.
kubectl get pods:
statefulset-postgres-0 0/1 CrashLoopBackOff 6 7m
kubectl logs statefulset-postgres-0
initdb: directory "/var/lib/postgresql/data" exists but is not empty
It contains a lost+found directory, perhaps due to it being a mount point.
Using a mount point directly as the data directory is not recommended.
Create a subdirectory under the mount point.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
kubectl describe pods statefulset-postgres-0
.
.
.
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 13m default-scheduler Successfully assigned statefulset-postgres-0 to gke-cluster-make4me-default-pool-6c521a68-7bjx
Normal SuccessfulMountVolume 13m kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx MountVolume.SetUp succeeded for volume "default-token-clff8"
Normal SuccessfulMountVolume 12m kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx MountVolume.SetUp succeeded for volume "pvc-4f2e138b-22f9-11e8-841f-42010a800fdb"
Normal Pulled 12m (x4 over 12m) kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx Container image "postgres:9.6.7" already present on machine
Normal Created 12m (x4 over 12m) kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx Created container
Normal Started 12m (x4 over 12m) kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx Started container
Warning BackOff 12m (x5 over 12m) kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx Back-off restarting failed container
Warning FailedSync 2m (x45 over 12m) kubelet, gke-cluster-make4me-default-pool-6c521a68-7bjx Error syncing pod
Arquivos de configurações
statefulset.yaml
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: statefulset-postgres
spec:
serviceName: database
template:
metadata:
labels:
name: postgress
spec:
containers:
- name: container-postgres
image: postgres:9.6.7
ports:
- containerPort: 5432
env:
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PASSWORD
value: XXXXXXXXXXXx
volumeMounts:
- name: volume-postgres
mountPath: /var/lib/postgresql/data
volumes:
- name: volume-postgres
persistentVolumeClaim:
claimName: config-postgres
database-service.yaml
apiVersion: v1
kind: Service
metadata:
name: database-service
spec:
type: ClusterIP
ports:
- port: 5432
selector:
name: postgress