How to use volumes in Kubernetes deployments? -


i want use volumes deployments more 1 replica. how define persistentvolumeclaim generated each replica? @ moment (see example below) able generate volume , assign pods. problem is, 1 volume gets generated causes error messages:

  38m   1m  18  {kubelet worker-1.loc}      warning failedmount unable mount volumes pod "solr-1254544937-zblou_default(610b157c-549e-11e6-a624-0238b97cfe8f)": timeout expired waiting volumes attach/mount pod "solr-1254544937-zblou"/"default". list of unattached/unmounted volumes=[datadir]   38m   1m  18  {kubelet worker-1.loc}      warning failedsync  error syncing pod, skipping: timeout expired waiting volumes attach/mount pod "solr-1254544937-zblou"/"default". list of unattached/unmounted volumes=[datadir] 

how can tell kubernetes generate volume each replica?

i using kubernetes 1.3.


example:

--- kind: persistentvolumeclaim apiversion: v1 metadata:   name: solr-datadir   annotations:     volume.alpha.kubernetes.io/storage-class: spec:   accessmodes:     - readwriteonce   resources:     requests:       storage: 50gi --- apiversion: extensions/v1beta1 kind: deployment  metadata:   name: solr   labels:     team: platform     tier: search     app: solr  spec:   revisionhistorylimit: 3   replicas: 3    template:     metadata:       name: solr       labels:         team: platform         tier: search         app: solr      spec:       containers:       - name: solr         image: solr:6-alpine         imagepullpolicy: ifnotpresent         ports:         - name: http           containerport: 80         resources:           requests:             cpu: 512m             memory: 512mi         command:          - /bin/bash         args:         - -c         - /opt/solr/bin/solr start -f -z zookeeper:2181         volumemounts:         - mountpath: "/opt/solr/server/solr/mycores"           name: datadir       volumes:       - name: datadir         persistentvolumeclaim:           claimname: solr-datadir 

generated pods:

$ kubectl pods -lapp=solr  name                    ready     status              restarts   age solr-1254544937-chenr   1/1       running             0          55m solr-1254544937-gjud0   0/1       containercreating   0          55m solr-1254544937-zblou   0/1       containercreating   0          55m 

generated volumes:

$ kubectl pv name                                       capacity   accessmodes   status    claim                         reason    age pvc-3955e8f1-549e-11e6-94be-060ea3314be5   50gi       rwo           bound     default/solr-datadir                    57m 

generated claims:

$ kubectl pvc name                  status    volume                                     capacity   accessmodes   age solr-datadir          bound     pvc-3955e8f1-549e-11e6-94be-060ea3314be5   0                        57m 

replicasets treat volumes stateless. if replicaset pod template specifies volume can attached read-write once, same volume used pods in replicaset. if volume can attached read-write 1 node @ time (like gce pds), after first pod scheduled , started, subsequent instances of pod fail start if scheduled different node, because volume not able attach second node.

what looking pet sets enable generate volume each replica. see http://kubernetes.io/docs/user-guide/petset/ feature in alpha should address usecase.

update: in kubernetes 1.5+ petsets renamed statefulsets. see documentation here.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -