Home > other >  Statefulset pod is using more storage than defined in the volumeClaimTemplates
Statefulset pod is using more storage than defined in the volumeClaimTemplates

Time:06-01

I created below statfulset on microk8s:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgresql13
spec:
  selector:
    matchLabels:
      app: postgresql13
  serviceName: postgresql13
  replicas: 1
  template:
    metadata:
      labels:
        app: postgresql13
    spec:
      containers:
        - name: postgresql13
          image: postgres:13
          imagePullPolicy: Always
          ports:
            - containerPort: 5432
              name: sql-tcp
          volumeMounts:
            - name: postgresql13
              mountPath: /data
          env:
            - name: POSTGRES_PASSWORD
              value: testpassword
            - name: PGDATA
              value: /data/pgdata
  volumeClaimTemplates:
    - metadata:
        name: postgresql13
      spec:
        storageClassName: "microk8s-hostpath"
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Ki

in the volumeClaimTemplates i gave it only 1Ki (this is one KB right ?) But the DB started normally and when i run kubectl exec postgresql13-0 -- df -h on the pod i get this

Filesystem                         Size  Used Avail Use% Mounted on
overlay                             73G   11G   59G  15% /
tmpfs                               64M     0   64M   0% /dev
/dev/mapper/ubuntu--vg-ubuntu--lv   73G   11G   59G  15% /data
shm                                 64M   16K   64M   1% /dev/shm
tmpfs                              7.7G   12K  7.7G   1% /run/secrets/kubernetes.io/serviceaccount
tmpfs                              3.9G     0  3.9G   0% /proc/acpi
tmpfs                              3.9G     0  3.9G   0% /proc/scsi
tmpfs                              3.9G     0  3.9G   0% /sys/firmware

Isn't is supposed to not use more than what the PVC have ? I intentially sat the storage class AllowVolumeExpansion: False

what am i missing here ?

CodePudding user response:

allowVolumeExpansion and storage size does not apply to hostPath. The actual size will be the host volume size where the host path resides.

CodePudding user response:

Isn't is supposed to not use more than what the PVC have?

This is a misunderstanding. What you specify in a resource request is the resources your application needs at least. You might get more. You typically use resource limits to set hard limits.

  • Related