google cloud platform - Kubernetes not claiming persistent volume - "failed due to PersistentVolumeClaim is not bound: "task-pv-claim", which is unexpected." -


i'm not sure why persistent volume not being claimed, or steps take further diagnose this?

should claim size match volume size? should volume size match gcp volume size?

this difficult test , figure out...

my goal here able create wordpress instance single replica long support rolling deployments....

output of kubectl pods:

name                         ready     status    restarts   age wordpress-1546832918-mz4rt   0/3       pending   0          47m wordpress-1546832918-p0s1s   0/3       pending   0          47m 

output of kubectl describe pods:

...truncated... events:   firstseen lastseen    count              subobjectpath   type        reason          message   --------- --------    -----   ----            -------------   --------    ------          -------   47m       3s      168 default-scheduler       warning     failedscheduling    [schedulerpredicates failed due persistentvolumeclaim not bound: "task-pv-claim", unexpected., schedulerpredicates failed due persistentvolumeclaim not bound: "task-pv-claim", unexpected.] 

output of kubectl pvc:

name            status    volume    capacity   accessmodes   storageclass   age task-pv-claim   pending                                      manual         4h 

output of kubectl pv:

name      capacity   accessmodes   reclaimpolicy   status      claim     storageclass   reason    age pv0001    10gi       rwx           retain          available             manual                   4h 

production.yaml

apiversion: extensions/v1beta1 kind: deployment metadata:   name: wordpress   labels:     app: wordpress spec:   replicas: 2   selector:     matchlabels:       app: wordpress   template:     metadata:       labels:         app: wordpress     spec:       terminationgraceperiodseconds: 30       containers:         - image: eu.gcr.io/abcxyz/wordpress:deploy-1502807720           name: wordpress           imagepullpolicy: "always"           env:             - name: wordpress_host               value: localhost             - name: wordpress_db_username               valuefrom:                 secretkeyref:                   name: cloudsql-db-credentials                   key: username           volumemounts:             - name: wordpress-persistent-storage               mountpath: /var/www/html         - image: eu.gcr.io/abcxyz/nginx:deploy-1502807720           name: nginx           imagepullpolicy: "always"           ports:             - containerport: 80               name: nginx           volumemounts:             - name: wordpress-persistent-storage               mountpath: /var/www/html               readonly: true         - image: gcr.io/cloudsql-docker/gce-proxy:1.09           name: cloudsql-proxy           command: ["/cloud_sql_proxy", "--dir=/cloudsql",                     "-instances=abcxyz:europe-west1:wordpressdb2=tcp:3306",                     "-credential_file=/secrets/cloudsql/credentials.json"]           volumemounts:             - name: cloudsql-instance-credentials               mountpath: /secrets/cloudsql               readonly: true             - name: ssl-certs               mountpath: /etc/ssl/certs             - name: cloudsql               mountpath: /cloudsql       volumes:         - name: wordpress-persistent-storage           persistentvolumeclaim:             claimname: "task-pv-claim"         - name: cloudsql-instance-credentials           secret:             secretname: cloudsql-instance-credentials         - name: ssl-certs           hostpath:             path: /etc/ssl/certs         - name: cloudsql           emptydir: 

pvolume.yaml

apiversion: "v1" kind: "persistentvolume" metadata:   name: "pv0001"  spec:   storageclassname: manual   capacity:     storage: "10gi"    accessmodes:     - "readwritemany"   gcepersistentdisk:      fstype: "ext4"      pdname: "wordpress-disk"  

pvolumeclaim.yaml

kind: persistentvolumeclaim apiversion: v1 metadata:   name: task-pv-claim spec:   storageclassname: manual   accessmodes:     - readwriteonce   resources:     requests:       storage: 3gi 

the spec.accessmodes of persistent volume claim has match in persistent volume. try change both of them same value.

if didn't work, can add spec.selector definition persistent volume claim definition, updating match persistent volume metadata.labels this:

apiversion: "v1" kind: "persistentvolume" metadata:   name: "pv0001"    labels:     name: "pv0001" # can long matches selector in pvc spec:   ...  ---- kind: persistentvolumeclaim apiversion: v1 metadata:   name: task-pv-claim spec:   storageclassname: manual   accessmodes:     - readwriteonce   resources:     requests:       storage: 3gi   selector:     matchlabels:       name: "pv0001"  

the spec.selector serves filter ensure pv specified labels matched.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -