...

Source file src/k8s.io/kubernetes/pkg/apis/storage/types.go

Documentation: k8s.io/kubernetes/pkg/apis/storage

     1  /*
     2  Copyright 2016 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package storage
    18  
    19  import (
    20  	"k8s.io/apimachinery/pkg/api/resource"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  	api "k8s.io/kubernetes/pkg/apis/core"
    23  )
    24  
    25  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    26  
    27  // StorageClass describes a named "class" of storage offered in a cluster.
    28  // Different classes might map to quality-of-service levels, or to backup policies,
    29  // or to arbitrary policies determined by the cluster administrators.  Kubernetes
    30  // itself is unopinionated about what classes represent.  This concept is sometimes
    31  // called "profiles" in other storage systems.
    32  // The name of a StorageClass object is significant, and is how users can request a particular class.
    33  type StorageClass struct {
    34  	metav1.TypeMeta
    35  	// +optional
    36  	metav1.ObjectMeta
    37  
    38  	// provisioner is the driver expected to handle this StorageClass.
    39  	// This is an optionally-prefixed name, like a label key.
    40  	// For example: "kubernetes.io/gce-pd" or "kubernetes.io/aws-ebs".
    41  	// This value may not be empty.
    42  	Provisioner string
    43  
    44  	// parameters holds parameters for the provisioner.
    45  	// These values are opaque to the  system and are passed directly
    46  	// to the provisioner.  The only validation done on keys is that they are
    47  	// not empty.  The maximum number of parameters is
    48  	// 512, with a cumulative max size of 256K
    49  	// +optional
    50  	Parameters map[string]string
    51  
    52  	// reclaimPolicy is the reclaim policy that dynamically provisioned
    53  	// PersistentVolumes of this storage class are created with
    54  	// +optional
    55  	ReclaimPolicy *api.PersistentVolumeReclaimPolicy
    56  
    57  	// mountOptions are the mount options that dynamically provisioned
    58  	// PersistentVolumes of this storage class are created with
    59  	// +optional
    60  	MountOptions []string
    61  
    62  	// AllowVolumeExpansion shows whether the storage class allow volume expand
    63  	// If the field is nil or not set, it would amount to expansion disabled
    64  	// for all PVs created from this storageclass.
    65  	// +optional
    66  	AllowVolumeExpansion *bool
    67  
    68  	// VolumeBindingMode indicates how PersistentVolumeClaims should be
    69  	// provisioned and bound.  When unset, VolumeBindingImmediate is used.
    70  	// This field is only honored by servers that enable the VolumeScheduling feature.
    71  	// +optional
    72  	VolumeBindingMode *VolumeBindingMode
    73  
    74  	// Restrict the node topologies where volumes can be dynamically provisioned.
    75  	// Each volume plugin defines its own supported topology specifications.
    76  	// An empty TopologySelectorTerm list means there is no topology restriction.
    77  	// This field is only honored by servers that enable the VolumeScheduling feature.
    78  	// +optional
    79  	AllowedTopologies []api.TopologySelectorTerm
    80  }
    81  
    82  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    83  
    84  // StorageClassList is a collection of storage classes.
    85  type StorageClassList struct {
    86  	metav1.TypeMeta
    87  	// Standard list metadata
    88  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
    89  	// +optional
    90  	metav1.ListMeta
    91  
    92  	// Items is the list of StorageClasses
    93  	Items []StorageClass
    94  }
    95  
    96  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    97  
    98  // Captures the intent to attach or detach the specified volume to/from
    99  // the specified node.
   100  //
   101  // VolumeAttachment objects are non-namespaced.
   102  type VolumeAttachment struct {
   103  	metav1.TypeMeta
   104  
   105  	// Standard object metadata.
   106  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   107  	// +optional
   108  	metav1.ObjectMeta
   109  
   110  	// Specification of the desired attach/detach volume behavior.
   111  	// Populated by the Kubernetes system.
   112  	Spec VolumeAttachmentSpec
   113  
   114  	// Status of the VolumeAttachment request.
   115  	// Populated by the entity completing the attach or detach
   116  	// operation, i.e. the external-attacher.
   117  	// +optional
   118  	Status VolumeAttachmentStatus
   119  }
   120  
   121  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   122  
   123  // VolumeAttachmentList is a collection of VolumeAttachment objects.
   124  type VolumeAttachmentList struct {
   125  	metav1.TypeMeta
   126  	// Standard list metadata
   127  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   128  	// +optional
   129  	metav1.ListMeta
   130  
   131  	// Items is the list of VolumeAttachments
   132  	Items []VolumeAttachment
   133  }
   134  
   135  // The specification of a VolumeAttachment request.
   136  type VolumeAttachmentSpec struct {
   137  	// Attacher indicates the name of the volume driver that MUST handle this
   138  	// request. This is the name returned by GetPluginName().
   139  	Attacher string
   140  
   141  	// Source represents the volume that should be attached.
   142  	Source VolumeAttachmentSource
   143  
   144  	// The node that the volume should be attached to.
   145  	NodeName string
   146  }
   147  
   148  // VolumeAttachmentSource represents a volume that should be attached.
   149  // Right now persistent volumes as well as inline volumes (only in
   150  // CSI Migration scenarios) can be attached via external attacher.
   151  // Exactly one member can be set.
   152  type VolumeAttachmentSource struct {
   153  	// Name of the persistent volume to attach.
   154  	// +optional
   155  	PersistentVolumeName *string
   156  
   157  	// inlineVolumeSpec contains all the information necessary to attach
   158  	// a persistent volume defined by a pod's inline VolumeSource. This field
   159  	// is populated only for the CSIMigration feature. It contains
   160  	// translated fields from a pod's inline VolumeSource to a
   161  	// PersistentVolumeSpec. This field is beta-level and is only
   162  	// honored by servers that enabled the CSIMigration feature.
   163  	// +optional
   164  	InlineVolumeSpec *api.PersistentVolumeSpec
   165  }
   166  
   167  // The status of a VolumeAttachment request.
   168  type VolumeAttachmentStatus struct {
   169  	// Indicates the volume is successfully attached.
   170  	// This field must only be set by the entity completing the attach
   171  	// operation, i.e. the external-attacher.
   172  	Attached bool
   173  
   174  	// Upon successful attach, this field is populated with any
   175  	// information returned by the attach operation that must be passed
   176  	// into subsequent WaitForAttach or Mount calls.
   177  	// This field must only be set by the entity completing the attach
   178  	// operation, i.e. the external-attacher.
   179  	// +optional
   180  	AttachmentMetadata map[string]string
   181  
   182  	// The last error encountered during attach operation, if any.
   183  	// This field must only be set by the entity completing the attach
   184  	// operation, i.e. the external-attacher.
   185  	// +optional
   186  	AttachError *VolumeError
   187  
   188  	// The last error encountered during detach operation, if any.
   189  	// This field must only be set by the entity completing the detach
   190  	// operation, i.e. the external-attacher.
   191  	// +optional
   192  	DetachError *VolumeError
   193  }
   194  
   195  // Captures an error encountered during a volume operation.
   196  type VolumeError struct {
   197  	// Time the error was encountered.
   198  	// +optional
   199  	Time metav1.Time
   200  
   201  	// String detailing the error encountered during Attach or Detach operation.
   202  	// This string may be logged, so it should not contain sensitive
   203  	// information.
   204  	// +optional
   205  	Message string
   206  }
   207  
   208  // VolumeBindingMode indicates how PersistentVolumeClaims should be bound.
   209  type VolumeBindingMode string
   210  
   211  const (
   212  	// VolumeBindingImmediate indicates that PersistentVolumeClaims should be
   213  	// immediately provisioned and bound.
   214  	VolumeBindingImmediate VolumeBindingMode = "Immediate"
   215  
   216  	// VolumeBindingWaitForFirstConsumer indicates that PersistentVolumeClaims
   217  	// should not be provisioned and bound until the first Pod is created that
   218  	// references the PeristentVolumeClaim.  The volume provisioning and
   219  	// binding will occur during Pod scheduing.
   220  	VolumeBindingWaitForFirstConsumer VolumeBindingMode = "WaitForFirstConsumer"
   221  )
   222  
   223  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   224  
   225  // CSIDriver captures information about a Container Storage Interface (CSI)
   226  // volume driver deployed on the cluster.
   227  // CSI drivers do not need to create the CSIDriver object directly. Instead they may use the
   228  // cluster-driver-registrar sidecar container. When deployed with a CSI driver it automatically
   229  // creates a CSIDriver object representing the driver.
   230  // Kubernetes attach detach controller uses this object to determine whether attach is required.
   231  // Kubelet uses this object to determine whether pod information needs to be passed on mount.
   232  // CSIDriver objects are non-namespaced.
   233  type CSIDriver struct {
   234  	metav1.TypeMeta
   235  
   236  	// Standard object metadata.
   237  	// metadata.Name indicates the name of the CSI driver that this object
   238  	// refers to; it MUST be the same name returned by the CSI GetPluginName()
   239  	// call for that driver.
   240  	// The driver name must be 63 characters or less, beginning and ending with
   241  	// an alphanumeric character ([a-z0-9A-Z]) with dashes (-), dots (.), and
   242  	// alphanumerics between.
   243  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   244  	metav1.ObjectMeta
   245  
   246  	// Specification of the CSI Driver.
   247  	Spec CSIDriverSpec
   248  }
   249  
   250  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   251  
   252  // CSIDriverList is a collection of CSIDriver objects.
   253  type CSIDriverList struct {
   254  	metav1.TypeMeta
   255  
   256  	// Standard list metadata
   257  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   258  	// +optional
   259  	metav1.ListMeta
   260  
   261  	// items is the list of CSIDriver
   262  	Items []CSIDriver
   263  }
   264  
   265  // CSIDriverSpec is the specification of a CSIDriver.
   266  type CSIDriverSpec struct {
   267  	// attachRequired indicates this CSI volume driver requires an attach
   268  	// operation (because it implements the CSI ControllerPublishVolume()
   269  	// method), and that the Kubernetes attach detach controller should call
   270  	// the attach volume interface which checks the volumeattachment status
   271  	// and waits until the volume is attached before proceeding to mounting.
   272  	// The CSI external-attacher coordinates with CSI volume driver and updates
   273  	// the volumeattachment status when the attach operation is complete.
   274  	// If the CSIDriverRegistry feature gate is enabled and the value is
   275  	// specified to false, the attach operation will be skipped.
   276  	// Otherwise the attach operation will be called.
   277  	//
   278  	// This field is immutable.
   279  	//
   280  	// +optional
   281  	AttachRequired *bool
   282  
   283  	// Defines if the underlying volume supports changing ownership and
   284  	// permission of the volume before being mounted.
   285  	// Refer to the specific FSGroupPolicy values for additional details.
   286  	//
   287  	// This field was immutable in Kubernetes < 1.29 and now is mutable.
   288  	//
   289  	// Defaults to ReadWriteOnceWithFSType, which will examine each volume
   290  	// to determine if Kubernetes should modify ownership and permissions of the volume.
   291  	// With the default policy the defined fsGroup will only be applied
   292  	// if a fstype is defined and the volume's access mode contains ReadWriteOnce.
   293  	// +optional
   294  	FSGroupPolicy *FSGroupPolicy
   295  
   296  	// If set to true, podInfoOnMount indicates this CSI volume driver
   297  	// requires additional pod information (like podName, podUID, etc.) during
   298  	// mount operations.
   299  	// If set to false, pod information will not be passed on mount.
   300  	// Default is false.
   301  	// The CSI driver specifies podInfoOnMount as part of driver deployment.
   302  	// If true, Kubelet will pass pod information as VolumeContext in the CSI
   303  	// NodePublishVolume() calls.
   304  	// The CSI driver is responsible for parsing and validating the information
   305  	// passed in as VolumeContext.
   306  	// The following VolumeContext will be passed if podInfoOnMount is set to true.
   307  	// This list might grow, but the prefix will be used.
   308  	// "csi.storage.k8s.io/pod.name": pod.Name
   309  	// "csi.storage.k8s.io/pod.namespace": pod.Namespace
   310  	// "csi.storage.k8s.io/pod.uid": string(pod.UID)
   311  	// "csi.storage.k8s.io/ephemeral": "true" if the volume is an ephemeral inline volume
   312  	//                                 defined by a CSIVolumeSource, otherwise "false"
   313  	//
   314  	// "csi.storage.k8s.io/ephemeral" is a new feature in Kubernetes 1.16. It is only
   315  	// required for drivers which support both the "Persistent" and "Ephemeral" VolumeLifecycleMode.
   316  	// Other drivers can leave pod info disabled and/or ignore this field.
   317  	// As Kubernetes 1.15 doesn't support this field, drivers can only support one mode when
   318  	// deployed on such a cluster and the deployment determines which mode that is, for example
   319  	// via a command line parameter of the driver.
   320  	//
   321  	// This field was immutable in Kubernetes < 1.29 and now is mutable.
   322  	//
   323  	// +optional
   324  	PodInfoOnMount *bool
   325  
   326  	// VolumeLifecycleModes defines what kind of volumes this CSI volume driver supports.
   327  	// The default if the list is empty is "Persistent", which is the usage
   328  	// defined by the CSI specification and implemented in Kubernetes via the usual
   329  	// PV/PVC mechanism.
   330  	// The other mode is "Ephemeral". In this mode, volumes are defined inline
   331  	// inside the pod spec with CSIVolumeSource and their lifecycle is tied to
   332  	// the lifecycle of that pod. A driver has to be aware of this
   333  	// because it is only going to get a NodePublishVolume call for such a volume.
   334  	// For more information about implementing this mode, see
   335  	// https://kubernetes-csi.github.io/docs/ephemeral-local-volumes.html
   336  	// A driver can support one or more of these mode and
   337  	// more modes may be added in the future.
   338  	//
   339  	// This field is immutable.
   340  	//
   341  	// +optional
   342  	VolumeLifecycleModes []VolumeLifecycleMode
   343  
   344  	// If set to true, storageCapacity indicates that the CSI
   345  	// volume driver wants pod scheduling to consider the storage
   346  	// capacity that the driver deployment will report by creating
   347  	// CSIStorageCapacity objects with capacity information.
   348  	//
   349  	// The check can be enabled immediately when deploying a driver.
   350  	// In that case, provisioning new volumes with late binding
   351  	// will pause until the driver deployment has published
   352  	// some suitable CSIStorageCapacity object.
   353  	//
   354  	// Alternatively, the driver can be deployed with the field
   355  	// unset or false and it can be flipped later when storage
   356  	// capacity information has been published.
   357  	//
   358  	// This field was immutable in Kubernetes <= 1.22 and now is mutable.
   359  	//
   360  	// +optional
   361  	StorageCapacity *bool
   362  
   363  	// TokenRequests indicates the CSI driver needs pods' service account
   364  	// tokens it is mounting volume for to do necessary authentication. Kubelet
   365  	// will pass the tokens in VolumeContext in the CSI NodePublishVolume calls.
   366  	// The CSI driver should parse and validate the following VolumeContext:
   367  	// "csi.storage.k8s.io/serviceAccount.tokens": {
   368  	//   "<audience>": {
   369  	//     "token": <token>,
   370  	//     "expirationTimestamp": <expiration timestamp in RFC3339>,
   371  	//   },
   372  	//   ...
   373  	// }
   374  	//
   375  	// Note: Audience in each TokenRequest should be different and at
   376  	// most one token is empty string. To receive a new token after expiry,
   377  	// RequiresRepublish can be used to trigger NodePublishVolume periodically.
   378  	//
   379  	// +optional
   380  	// +listType=atomic
   381  	TokenRequests []TokenRequest
   382  
   383  	// RequiresRepublish indicates the CSI driver wants `NodePublishVolume`
   384  	// being periodically called to reflect any possible change in the mounted
   385  	// volume. This field defaults to false.
   386  	//
   387  	// Note: After a successful initial NodePublishVolume call, subsequent calls
   388  	// to NodePublishVolume should only update the contents of the volume. New
   389  	// mount points will not be seen by a running container.
   390  	//
   391  	// +optional
   392  	RequiresRepublish *bool
   393  
   394  	// SELinuxMount specifies if the CSI driver supports "-o context"
   395  	// mount option.
   396  	//
   397  	// When "true", the CSI driver must ensure that all volumes provided by this CSI
   398  	// driver can be mounted separately with different `-o context` options. This is
   399  	// typical for storage backends that provide volumes as filesystems on block
   400  	// devices or as independent shared volumes.
   401  	// Kubernetes will call NodeStage / NodePublish with "-o context=xyz" mount
   402  	// option when mounting a ReadWriteOncePod volume used in Pod that has
   403  	// explicitly set SELinux context. In the future, it may be expanded to other
   404  	// volume AccessModes. In any case, Kubernetes will ensure that the volume is
   405  	// mounted only with a single SELinux context.
   406  	//
   407  	// When "false", Kubernetes won't pass any special SELinux mount options to the driver.
   408  	// This is typical for volumes that represent subdirectories of a bigger shared filesystem.
   409  	//
   410  	// Default is "false".
   411  	//
   412  	// +featureGate=SELinuxMountReadWriteOncePod
   413  	// +optional
   414  	SELinuxMount *bool
   415  }
   416  
   417  // FSGroupPolicy specifies if a CSI Driver supports modifying
   418  // volume ownership and permissions of the volume to be mounted.
   419  // More modes may be added in the future.
   420  type FSGroupPolicy string
   421  
   422  const (
   423  	// ReadWriteOnceWithFSTypeFSGroupPolicy indicates that each volume will be examined
   424  	// to determine if the volume ownership and permissions
   425  	// should be modified. If a fstype is defined and the volume's access mode
   426  	// contains ReadWriteOnce, then the defined fsGroup will be applied.
   427  	// This mode should be defined if it's expected that the
   428  	// fsGroup may need to be modified depending on the pod's SecurityPolicy.
   429  	// This is the default behavior if no other FSGroupPolicy is defined.
   430  	ReadWriteOnceWithFSTypeFSGroupPolicy FSGroupPolicy = "ReadWriteOnceWithFSType"
   431  
   432  	// FileFSGroupPolicy indicates that CSI driver supports volume ownership
   433  	// and permission change via fsGroup, and Kubernetes will change the permissions
   434  	// and ownership of every file in the volume to match the user requested fsGroup in
   435  	// the pod's SecurityPolicy regardless of fstype or access mode.
   436  	// Use this mode if Kubernetes should modify the permissions and ownership
   437  	// of the volume.
   438  	FileFSGroupPolicy FSGroupPolicy = "File"
   439  
   440  	// NoneFSGroupPolicy indicates that volumes will be mounted without performing
   441  	// any ownership or permission modifications, as the CSIDriver does not support
   442  	// these operations.
   443  	// This mode should be selected if the CSIDriver does not support fsGroup modifications,
   444  	// for example when Kubernetes cannot change ownership and permissions on a volume due
   445  	// to root-squash settings on a NFS volume.
   446  	NoneFSGroupPolicy FSGroupPolicy = "None"
   447  )
   448  
   449  // VolumeLifecycleMode specifies how a CSI volume is used in Kubernetes.
   450  // More modes may be added in the future.
   451  type VolumeLifecycleMode string
   452  
   453  // TokenRequest contains parameters of a service account token.
   454  type TokenRequest struct {
   455  	// Audience is the intended audience of the token in "TokenRequestSpec".
   456  	// It will default to the audiences of kube apiserver.
   457  	//
   458  	Audience string
   459  
   460  	// ExpirationSeconds is the duration of validity of the token in "TokenRequestSpec".
   461  	// It has the same default value of "ExpirationSeconds" in "TokenRequestSpec."
   462  	//
   463  	// +optional
   464  	ExpirationSeconds *int64
   465  }
   466  
   467  const (
   468  	// VolumeLifecyclePersistent explicitly confirms that the driver implements
   469  	// the full CSI spec. It is the default when CSIDriverSpec.VolumeLifecycleModes is not
   470  	// set. Such volumes are managed in Kubernetes via the persistent volume
   471  	// claim mechanism and have a lifecycle that is independent of the pods which
   472  	// use them.
   473  	VolumeLifecyclePersistent VolumeLifecycleMode = "Persistent"
   474  	// VolumeLifecycleEphemeral indicates that the driver can be used for
   475  	// ephemeral inline volumes. Such volumes are specified inside the pod
   476  	// spec with a CSIVolumeSource and, as far as Kubernetes is concerned, have
   477  	// a lifecycle that is tied to the lifecycle of the pod. For example, such
   478  	// a volume might contain data that gets created specifically for that pod,
   479  	// like secrets.
   480  	// But how the volume actually gets created and managed is entirely up to
   481  	// the driver. It might also use reference counting to share the same volume
   482  	// instance among different pods if the CSIVolumeSource of those pods is
   483  	// identical.
   484  	VolumeLifecycleEphemeral VolumeLifecycleMode = "Ephemeral"
   485  )
   486  
   487  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   488  
   489  // CSINode holds information about all CSI drivers installed on a node.
   490  // CSI drivers do not need to create the CSINode object directly. As long as
   491  // they use the node-driver-registrar sidecar container, the kubelet will
   492  // automatically populate the CSINode object for the CSI driver as part of
   493  // kubelet plugin registration.
   494  // CSINode has the same name as a node. If the object is missing, it means either
   495  // there are no CSI Drivers available on the node, or the Kubelet version is low
   496  // enough that it doesn't create this object.
   497  // CSINode has an OwnerReference that points to the corresponding node object.
   498  type CSINode struct {
   499  	metav1.TypeMeta
   500  
   501  	// metadata.name must be the Kubernetes node name.
   502  	metav1.ObjectMeta
   503  
   504  	// spec is the specification of CSINode
   505  	Spec CSINodeSpec
   506  }
   507  
   508  // CSINodeSpec holds information about the specification of all CSI drivers installed on a node
   509  type CSINodeSpec struct {
   510  	// drivers is a list of information of all CSI Drivers existing on a node.
   511  	// If all drivers in the list are uninstalled, this can become empty.
   512  	// +patchMergeKey=name
   513  	// +patchStrategy=merge
   514  	Drivers []CSINodeDriver
   515  }
   516  
   517  // CSINodeDriver holds information about the specification of one CSI driver installed on a node
   518  type CSINodeDriver struct {
   519  	// This is the name of the CSI driver that this object refers to.
   520  	// This MUST be the same name returned by the CSI GetPluginName() call for
   521  	// that driver.
   522  	Name string
   523  
   524  	// nodeID of the node from the driver point of view.
   525  	// This field enables Kubernetes to communicate with storage systems that do
   526  	// not share the same nomenclature for nodes. For example, Kubernetes may
   527  	// refer to a given node as "node1", but the storage system may refer to
   528  	// the same node as "nodeA". When Kubernetes issues a command to the storage
   529  	// system to attach a volume to a specific node, it can use this field to
   530  	// refer to the node name using the ID that the storage system will
   531  	// understand, e.g. "nodeA" instead of "node1". This field is required.
   532  	NodeID string
   533  
   534  	// topologyKeys is the list of keys supported by the driver.
   535  	// When a driver is initialized on a cluster, it provides a set of topology
   536  	// keys that it understands (e.g. "company.com/zone", "company.com/region").
   537  	// When a driver is initialized on a node, it provides the same topology keys
   538  	// along with values. Kubelet will expose these topology keys as labels
   539  	// on its own node object.
   540  	// When Kubernetes does topology aware provisioning, it can use this list to
   541  	// determine which labels it should retrieve from the node object and pass
   542  	// back to the driver.
   543  	// It is possible for different nodes to use different topology keys.
   544  	// This can be empty if driver does not support topology.
   545  	// +optional
   546  	TopologyKeys []string
   547  
   548  	// allocatable represents the volume resources of a node that are available for scheduling.
   549  	// +optional
   550  	Allocatable *VolumeNodeResources
   551  }
   552  
   553  // VolumeNodeResources is a set of resource limits for scheduling of volumes.
   554  type VolumeNodeResources struct {
   555  	// Maximum number of unique volumes managed by the CSI driver that can be used on a node.
   556  	// A volume that is both attached and mounted on a node is considered to be used once, not twice.
   557  	// The same rule applies for a unique volume that is shared among multiple pods on the same node.
   558  	// If this field is not specified, then the supported number of volumes on this node is unbounded.
   559  	// +optional
   560  	Count *int32
   561  }
   562  
   563  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   564  
   565  // CSINodeList is a collection of CSINode objects.
   566  type CSINodeList struct {
   567  	metav1.TypeMeta
   568  
   569  	// Standard list metadata
   570  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   571  	// +optional
   572  	metav1.ListMeta
   573  
   574  	// items is the list of CSINode
   575  	Items []CSINode
   576  }
   577  
   578  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   579  
   580  // CSIStorageCapacity stores the result of one CSI GetCapacity call.
   581  // For a given StorageClass, this describes the available capacity in a
   582  // particular topology segment.  This can be used when considering where to
   583  // instantiate new PersistentVolumes.
   584  //
   585  // For example this can express things like:
   586  // - StorageClass "standard" has "1234 GiB" available in "topology.kubernetes.io/zone=us-east1"
   587  // - StorageClass "localssd" has "10 GiB" available in "kubernetes.io/hostname=knode-abc123"
   588  //
   589  // The following three cases all imply that no capacity is available for
   590  // a certain combination:
   591  // - no object exists with suitable topology and storage class name
   592  // - such an object exists, but the capacity is unset
   593  // - such an object exists, but the capacity is zero
   594  //
   595  // The producer of these objects can decide which approach is more suitable.
   596  //
   597  // They are consumed by the kube-scheduler when a CSI driver opts into
   598  // capacity-aware scheduling with CSIDriverSpec.StorageCapacity. The scheduler
   599  // compares the MaximumVolumeSize against the requested size of pending volumes
   600  // to filter out unsuitable nodes. If MaximumVolumeSize is unset, it falls back
   601  // to a comparison against the less precise Capacity. If that is also unset,
   602  // the scheduler assumes that capacity is insufficient and tries some other
   603  // node.
   604  type CSIStorageCapacity struct {
   605  	metav1.TypeMeta
   606  	// Standard object's metadata. The name has no particular meaning. It must be
   607  	// be a DNS subdomain (dots allowed, 253 characters). To ensure that
   608  	// there are no conflicts with other CSI drivers on the cluster, the recommendation
   609  	// is to use csisc-<uuid>, a generated name, or a reverse-domain name which ends
   610  	// with the unique CSI driver name.
   611  	//
   612  	// Objects are namespaced.
   613  	//
   614  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   615  	// +optional
   616  	metav1.ObjectMeta
   617  
   618  	// NodeTopology defines which nodes have access to the storage
   619  	// for which capacity was reported. If not set, the storage is
   620  	// not accessible from any node in the cluster. If empty, the
   621  	// storage is accessible from all nodes. This field is
   622  	// immutable.
   623  	//
   624  	// +optional
   625  	NodeTopology *metav1.LabelSelector
   626  
   627  	// The name of the StorageClass that the reported capacity applies to.
   628  	// It must meet the same requirements as the name of a StorageClass
   629  	// object (non-empty, DNS subdomain). If that object no longer exists,
   630  	// the CSIStorageCapacity object is obsolete and should be removed by its
   631  	// creator.
   632  	// This field is immutable.
   633  	StorageClassName string
   634  
   635  	// Capacity is the value reported by the CSI driver in its GetCapacityResponse
   636  	// for a GetCapacityRequest with topology and parameters that match the
   637  	// previous fields.
   638  	//
   639  	// The semantic is currently (CSI spec 1.2) defined as:
   640  	// The available capacity, in bytes, of the storage that can be used
   641  	// to provision volumes. If not set, that information is currently
   642  	// unavailable.
   643  	//
   644  	// +optional
   645  	Capacity *resource.Quantity
   646  
   647  	// MaximumVolumeSize is the value reported by the CSI driver in its GetCapacityResponse
   648  	// for a GetCapacityRequest with topology and parameters that match the
   649  	// previous fields.
   650  	//
   651  	// This is defined since CSI spec 1.4.0 as the largest size
   652  	// that may be used in a
   653  	// CreateVolumeRequest.capacity_range.required_bytes field to
   654  	// create a volume with the same parameters as those in
   655  	// GetCapacityRequest. The corresponding value in the Kubernetes
   656  	// API is ResourceRequirements.Requests in a volume claim.
   657  	//
   658  	// +optional
   659  	MaximumVolumeSize *resource.Quantity
   660  }
   661  
   662  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   663  
   664  // CSIStorageCapacityList is a collection of CSIStorageCapacity objects.
   665  type CSIStorageCapacityList struct {
   666  	metav1.TypeMeta
   667  	// Standard list metadata
   668  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   669  	// +optional
   670  	metav1.ListMeta
   671  
   672  	// Items is the list of CSIStorageCapacity objects.
   673  	Items []CSIStorageCapacity
   674  }
   675  
   676  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   677  
   678  // VolumeAttributesClass represents a specification of mutable volume attributes
   679  // defined by the CSI driver. The class can be specified during dynamic provisioning
   680  // of PersistentVolumeClaims, and changed in the PersistentVolumeClaim spec after provisioning.
   681  type VolumeAttributesClass struct {
   682  	metav1.TypeMeta
   683  
   684  	// Standard object's metadata.
   685  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   686  	// +optional
   687  	metav1.ObjectMeta
   688  
   689  	// Name of the CSI driver
   690  	// This field is immutable.
   691  	DriverName string
   692  
   693  	// parameters hold volume attributes defined by the CSI driver. These values
   694  	// are opaque to the Kubernetes and are passed directly to the CSI driver.
   695  	// The underlying storage provider supports changing these attributes on an
   696  	// existing volume, however the parameters field itself is immutable. To
   697  	// invoke a volume update, a new VolumeAttributesClass should be created with
   698  	// new parameters, and the PersistentVolumeClaim should be updated to reference
   699  	// the new VolumeAttributesClass.
   700  	//
   701  	// This field is required and must contain at least one key/value pair.
   702  	// The keys cannot be empty, and the maximum number of parameters is 512, with
   703  	// a cumulative max size of 256K. If the CSI driver rejects invalid parameters,
   704  	// the target PersistentVolumeClaim will be set to an "Infeasible" state in the
   705  	// modifyVolumeStatus field.
   706  	Parameters map[string]string
   707  }
   708  
   709  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
   710  
   711  // VolumeAttributesClassList is a collection of VolumeAttributesClass objects.
   712  type VolumeAttributesClassList struct {
   713  	metav1.TypeMeta
   714  
   715  	// Standard list metadata
   716  	// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
   717  	// +optional
   718  	metav1.ListMeta
   719  
   720  	// items is the list of VolumeAttributesClass objects.
   721  	// +listType=map
   722  	// +listMapKey=name
   723  	Items []VolumeAttributesClass
   724  }
   725  

View as plain text