Reputation: 457
I have a PersistentVolume with volumeMode
as Block
. It is defined as:
apiVersion: v1
kind: PersistentVolume
metadata:
name: block-vol
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
local:
path: /dev/sdb # this path on the host specified below is used as a device mount
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- <my-host>
persistentVolumeReclaimPolicy: Retain
storageClassName: block-storage
volumeMode: Block
When I mount this on a statefulset
with a VolumeClaimTemplate
, I specify it's storage
field as 1Gi
. However, when exec'd in to the deployed pod, I see that the block size more than 1Gi
(It is the actual size of that device on physical machine)
StatefulSet
YAML:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
serviceName: "nginx"
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web
volumeDevices:
- name: rawdev0
devicePath: /dev/kdb0
volumeClaimTemplates:
- metadata:
name: rawdev0
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: block-storage
volumeMode: Block
resources:
requests:
storage: 1Gi
I have used blockdev
to find the size of block in bytes:
root@nginx-0:/# ls -lhrt /dev/kdb0
brw-rw----. 1 root disk 8, 16 Jan 13 19:49 /dev/kdb0
root@nginx-0:/# blockdev --getsize64 /dev/kdb0
536870912000 #size of block in bytes
What does the storage
field signify in this case?
Upvotes: 0
Views: 444
Reputation: 128955
Kubernetes can't do much about the storage size for local volumes. The admin that created the PersistentVolume
must set a proper size, for granular sizing he/she should probably create its own partition instead of mapping the local volume to a directory.
The storage size in the PersistentVolumeClaim
is a request so that the app at least get a volume of that size.
Upvotes: 2