Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/postgresql] Using minikube, mkdir: cannot create directory ‘/bitnami/postgresql/data’ #14390

Closed
docktermj opened this issue Jun 1, 2019 · 4 comments · Fixed by #14401

Comments

@docktermj
Copy link

docktermj commented Jun 1, 2019

Which chart:

stable/postgresql

Description

When using minikube, Persistent Volumes (PV) using hostPath fail when used in stable/postgresql chart.

$ kubectl logs --namespace my-namespace my-postgresql-postgresql-0
 04:12:56.57 
 04:12:56.57 Welcome to the Bitnami postgresql container
 04:12:56.57 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
 04:12:56.57 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
 04:12:56.57 Send us your feedback at [email protected]
 04:12:56.58 
 04:12:56.60 INFO  ==> ** Starting PostgreSQL setup **
 04:12:56.67 INFO  ==> Validating settings in POSTGRESQL_* env vars..
 04:12:56.68 INFO  ==> Initializing PostgreSQL database...
 04:12:56.69 INFO  ==> postgresql.conf file not detected. Generating it...
 04:12:56.72 INFO  ==> pg_hba.conf file not detected. Generating it...
mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied
 04:12:56.73 INFO  ==> Stopping PostgreSQL...

Steps to reproduce the issue:

  1. Start MiniKube
minikube start --cpus 4 --memory 8192 --vm-driver kvm2
  1. Install Tiller
kubectl create serviceaccount -n kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule \
  --clusterrole=cluster-admin \
  --serviceaccount=kube-system:tiller
helm init --service-account tiller
  1. Create namespace.yaml file:
cat <<EOT > namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: my-namespace
  labels:
    name: my-namespace
EOT
  1. Create namespace:
kubectl create -f namespace.yaml
  1. Create persistent-volume-postgresql.yaml file:
cat <<EOT > persistent-volume-postgresql.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: postgresql-volume
  labels:
    type: local
  namespace: my-namespace
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/var/postgresql"
EOT
  1. Create persistent volume:
kubectl create -f persistent-volume-postgresql.yaml
  1. Create persistent-volume-claim-postgresql.yaml file:
cat <<EOT > persistent-volume-claim-postgresql.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    cattle.io/creator: norman
  name: postgresql-claim
  namespace: my-namespace
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: "manual"
  volumeName: postgresql-volume
EOT
  1. Create persistent volume claim:
kubectl create -f persistent-volume-claim-postgresql.yaml
  1. Create postgresql.yaml file:
cat <<EOT > postgresql.yaml
persistence:
  existingClaim: postgresql-claim

postgresqlDatabase: G2
postgresqlPassword: postgres
EOT
  1. Install stable/postgresql helm chart.
helm install \
  --name my-postgresql \
  --namespace my-namespace \
  --values postgresql.yaml \
  stable/postgresql
  1. Watch for error.
kubectl get pods \
  --namespace my-namespace \
  --watch

Describe the results you received:

  1. View error.
$ kubectl logs --namespace my-namespace my-postgresql-postgresql-0
 04:12:56.57 
 04:12:56.57 Welcome to the Bitnami postgresql container
 04:12:56.57 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-postgresql
 04:12:56.57 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-postgresql/issues
 04:12:56.57 Send us your feedback at [email protected]
 04:12:56.58 
 04:12:56.60 INFO  ==> ** Starting PostgreSQL setup **
 04:12:56.67 INFO  ==> Validating settings in POSTGRESQL_* env vars..
 04:12:56.68 INFO  ==> Initializing PostgreSQL database...
 04:12:56.69 INFO  ==> postgresql.conf file not detected. Generating it...
 04:12:56.72 INFO  ==> pg_hba.conf file not detected. Generating it...
mkdir: cannot create directory ‘/bitnami/postgresql/data’: Permission denied
 04:12:56.73 INFO  ==> Stopping PostgreSQL...

Describe the results you expected:

A chart that comes up. :-)

Additional information you deem important (e.g. issue happens only occasionally):

Version of Helm and Kubernetes:

  • Output of helm version:
$ helm version
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
  • Output of kubectl version:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:45:25Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"linux/amd64"}
  • Output of minikube:
$ minikube version
minikube version: v1.0.0

Cleanup

helm delete --purge my-postgresql
helm repo remove bitnami
kubectl delete -f persistent-volume-claim-postgresql.yaml
kubectl delete -f persistent-volume-postgresql.yaml
kubectl delete -f namespace.yaml
minikube stop
minikube delete
@docktermj docktermj changed the title stable/postgresql mkdir: cannot create directory ‘/bitnami/postgresql/data’ [stable/postgresql] mkdir: cannot create directory ‘/bitnami/postgresql/data’ Jun 1, 2019
@docktermj docktermj changed the title [stable/postgresql] mkdir: cannot create directory ‘/bitnami/postgresql/data’ [stable/postgresql] Using minikube, mkdir: cannot create directory ‘/bitnami/postgresql/data’ Jun 1, 2019
@MohammedFadin
Copy link

I'm also having the same issue here.

@roomreport
Copy link

Me, too.

@juan131
Copy link
Collaborator

juan131 commented Jun 3, 2019

HI @docktermj @MohamadGamal

Thanks for reporting the issue!!

On the one hand, please note that you can solve the permissions issue by creating a initContainer that prepare the volume with the right permissions. To do so, use a values.yaml like the one below:

persistence:
  enabled: true
  existingClaim: postgresql-claim

volumePermissions:
  enabled: true

postgresqlDatabase: G2
postgresqlPassword: postgres

On the other hand, there's a small bug in the logic used on the initContainer to adapt the permissions and I just created a PR to address it. Thanks for reporting it again.

@juan131
Copy link
Collaborator

juan131 commented Jun 3, 2019

Hi everyone

The changes were just merged and now you should be able to follow the steps @docktermj indicated and the values.yaml below to use an existing PVC:

persistence:
  enabled: true
  existingClaim: postgresql-claim

volumePermissions:
  enabled: true

postgresqlDatabase: G2
postgresqlPassword: postgres

Please ensure you're using the latest MongoDB chart version 5.2.2. You can update your Helm charts by running the command below:

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants