0

Steps

  1. I create cluster in zonal mode and only have 1 zonal GKE version v1.21.14-gke.2700

  2. I create a PD in GCP GUI make sure it is in the same zonal

  3. I am deploy a pod mount the PV, PVC using PD i created without nodeSelector/nodeAffinity and tolerations <=== to shows the PV,PVC and PD is correct define

  4. I then create pod with nodeSelector and tolerations without mount and pv and pvc <== Result is success run , to shows the pod in nodeSelector and tolerations is fine

  5. I clean up everything make sure there have no more pv and pvc in the cluster and make sure the PD show in GUI level i does not have node mount it

  6. however when i combine them using PV,PVC and nodeSelector/nodeAffinity and tolerations , the pod turn out in keep ContainerCreating status Error Msg : Unable to attach or mount volumes: unmounted volumes=[task-pv-storage], unattached volumes=[task-pv-storage kube-api-access-87dvb]: timed out waiting for the condition PV.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-pv
spec:
  capacity:
    storage: 10G
  accessModes:
    - ReadWriteOnce
  claimRef:
    namespace: default
    name: test-pvc
  gcePersistentDisk:
    pdName: test-pd-disk
    fsType: ext4

PVC.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: test-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10G

Pod.yaml

kind: Pod
apiVersion: v1
metadata:
  name: task-pv-pod
spec:
  volumes:
    - name: task-pv-storage
      persistentVolumeClaim:
       claimName: test-pvc
  containers:
    - name: task-pv-container
      image: nginx
      ports:
        - containerPort: 80
          name: "http-server"
      volumeMounts:
        - mountPath: "/usr/data"
          name: task-pv-storage
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: xxx
            operator: In
            values:
            - xxxxx
  tolerations:
  - key: "xxx"
    operator: "Equal"
    value: "xxxxx"

0 Answers0