k3s: Cannot write data to local PVC

Environmental Info: K3s Version:

k3s version v1.21.3+k3s1 (1d1f220f)
go version go1.16.6

Node(s) CPU architecture, OS, and Version:

Linux debian-8gb-nbg1-1 4.19.0-17-amd64 #1 SMP Debian 4.19.194-2 (2021-06-21) x86_64 GNU/Linux

Cluster Configuration: Single node

Describe the bug: Postgres does not come up due to mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied

    Container ID:   containerd://fb0246e6a5aa94fe5f14c5c387a2609616d0c198d8a5c5606a41a4792b2c90aa
    Image:          postgres:12
...
    Mounts:
      /var/lib/postgresql/data from postgres (rw,path="data")
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-7jkg4 (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  postgres:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  postgres-awx-postgres-0
    ReadOnly:   false
  kube-api-access-7jkg4:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true

Steps To Reproduce:

Expected behavior: postgres comes up

Actual behavior: postgres crashes

Additional context / logs: mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 6
  • Comments: 30 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I am a bit surprised about that, too. I think this bug is bad enough to justify an early v1.21.3+k3s2 bugfix release.

Yeah, I’ll take a look.

K3s v1.21.4 is now out with the fix for this issue. https://github.com/k3s-io/k3s/releases/tag/v1.21.4%2Bk3s1

Upstream is putting out new patches (v1.21.4) this Wednesday, so we’re going to wait for that instead of doing a whole extra release cycle just for this one issue.

@dereknola can you take a look at this? It appears that with the permissions change, LocalStorage no longer supports containers that don’t run as root.

@ChristianCiach how do I do that in the best way possible ?😃

Btw. thanks for the fast reply 😄

PS: I figured it out. Thanks for the hint nevertheless 😃