Kubernetes StatefulSet Manifest: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 39: Line 39:
   [[#volumeClaimTemplates|volumeClaimTemplates]]:
   [[#volumeClaimTemplates|volumeClaimTemplates]]:
     - metadata:
     - metadata:
         name: data
         <span id='name_template'></span>[[#Volume_Claim_Name|name]]: data
       spec:
       spec:
         volumeMode: Filesystem
         volumeMode: Filesystem
Line 54: Line 54:
"volumeClaimTemplates" is a list of [[Kubernetes_Persistent_Volume_Claim_Manifest|persistent volume claim specifications]], defining persistent volume claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod.  
"volumeClaimTemplates" is a list of [[Kubernetes_Persistent_Volume_Claim_Manifest|persistent volume claim specifications]], defining persistent volume claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod.  


Every claim in this list must have at least one name-matching volumeMount in one [[#template_containers|container]] in the [[#template_metadata|template]]. The name of the claim is specified as [[#name_template|.metadata.name]].
<span id='Volume_Claim_Name'></span>Every claim in this list must have at least one name-matching volumeMount in one [[#template_containers|container]] in the [[#template_metadata|template]]. The name of the claim is specified as [[#name_template|.metadata.name]].


A claim in this list takes precedence over any volumes in the template, with the same name.
A claim in this list takes precedence over any volumes in the template, with the same name.

Revision as of 17:33, 11 December 2019

External

Internal

Example

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: postgresql
  labels:
    color: blue
spec:
  replicas: 1
  serviceName: postgresql-headless
  selector:
    matchLabels:
      app: postgresql
      role: master   
  podManagementPolicy: OrderedReady
  updateStrategy: 
    type: RollingUpdate
  template:
    metadata:
      name: postgresql
      labels:
        app: postgresql
        role: master
    spec:
      containers:
        - ...
      initContainers:
        - ...
      dnsPolicy:  ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: ...
      terminationGracePeriodSeconds: ...
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        volumeMode: Filesystem
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 8Gi

.spec Elements

template

volumeClaimTemplates

"volumeClaimTemplates" is a list of persistent volume claim specifications, defining persistent volume claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod.

Every claim in this list must have at least one name-matching volumeMount in one container in the template. The name of the claim is specified as .metadata.name.

A claim in this list takes precedence over any volumes in the template, with the same name.