Pv vs pvc

# Defines the rules for how the storage is handled
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: blue-stc-cka
# Tells K8s not to look for a cloud provider (AWS/GCP) to create a disk
provisioner: kubernetes.io/no-provisioner
# Prevents the PV/PVC from binding until a Pod is actually created
volumeBindingMode: WaitForFirstConsumer
# Defines the actual physical directory on the disk
apiVersion: v1
kind: PersistentVolume
metadata:
  name: blue-pv-cka
spec:
  capacity:
    storage: 100Mi
  accessModes:
    - ReadWriteOnce
  # Ensures the data is kept on the disk even if the PVC is deleted
  persistentVolumeReclaimPolicy: Retain
  # Matches the rulebook (StorageClass) created above
  storageClassName: blue-stc-cka
  # Specifies the literal Linux path on the host machine
  local:
    path: /opt/blue-data-cka
  # Mandatory for 'local' types; pins this volume to a specific piece of hardware
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          # The specific node where the directory /opt/blue-data-cka exists
          - controlplane
# The request to use the storage
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  # The name you need for the lab (fixed from your previous version)
  name: blue-pvc-cka
  namespace: default
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      # Asks for 50Mi (valid because the PV has 100Mi)
      storage: 50Mi
  # Filters for PVs that belong to this specific StorageClass
  storageClassName: blue-stc-cka 
  # Explicitly points to 'blue-pv-cka' to force a direct connection
  volumeName: blue-pv-cka