PersistentVolume & PersistentVolumeClaim API types
This commit is contained in:
108
pkg/api/types.go
108
pkg/api/types.go
@@ -195,7 +195,88 @@ type VolumeSource struct {
|
||||
NFS *NFSVolumeSource `json:"nfs"`
|
||||
}
|
||||
|
||||
// used by VolumeSources to describe their mounting/access modes
|
||||
// Similar to VolumeSource but meant for the administrator who creates PVs.
|
||||
// Exactly one of its members must be set.
|
||||
type PersistentVolumeSource struct {
|
||||
// GCEPersistentDisk represents a GCE Disk resource that is attached to a
|
||||
// kubelet's host machine and then exposed to the pod.
|
||||
GCEPersistentDisk *GCEPersistentDiskVolumeSource `json:"gcePersistentDisk"`
|
||||
// HostPath represents a directory on the host.
|
||||
// This is useful for development and testing only.
|
||||
// on-host storage is not supported in any way
|
||||
HostPath *HostPathVolumeSource `json:"hostPath"`
|
||||
}
|
||||
|
||||
type PersistentVolume struct {
|
||||
TypeMeta `json:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
//Spec defines a persistent volume owned by the cluster
|
||||
Spec PersistentVolumeSpec `json:"spec,omitempty"`
|
||||
|
||||
// Status represents the current information about persistent volume.
|
||||
Status PersistentVolumeStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeSpec struct {
|
||||
// Resources represents the actual resources of the volume
|
||||
Capacity ResourceList `json:"capacity`
|
||||
// Source represents the location and type of a volume to mount.
|
||||
// AccessModeTypes are inferred from the Source.
|
||||
PersistentVolumeSource `json:",inline"`
|
||||
// holds the binding reference to a PersistentVolumeClaim
|
||||
ClaimRef *ObjectReference `json:"claimRef,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeStatus struct {
|
||||
// Phase indicates if a volume is available, bound to a claim, or released by a claim
|
||||
Phase PersistentVolumePhase `json:"phase,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeList struct {
|
||||
TypeMeta `json:",inline"`
|
||||
ListMeta `json:"metadata,omitempty"`
|
||||
Items []PersistentVolume `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// PersistentVolumeClaim is a user's request for and claim to a persistent volume
|
||||
type PersistentVolumeClaim struct {
|
||||
TypeMeta `json:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Spec defines the volume requested by a pod author
|
||||
Spec PersistentVolumeClaimSpec `json:"spec,omitempty"`
|
||||
|
||||
// Status represents the current information about a claim
|
||||
Status PersistentVolumeClaimStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeClaimList struct {
|
||||
TypeMeta `json:",inline"`
|
||||
ListMeta `json:"metadata,omitempty"`
|
||||
Items []PersistentVolumeClaim `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// PersistentVolumeClaimSpec describes the common attributes of storage devices
|
||||
// and allows a Source for provider-specific attributes
|
||||
type PersistentVolumeClaimSpec struct {
|
||||
// Contains the types of access modes required
|
||||
AccessModes []AccessModeType `json:"accessModes,omitempty"`
|
||||
// Resources represents the minimum resources required
|
||||
Resources ResourceRequirements `json:"resources,omitempty"`
|
||||
}
|
||||
|
||||
type PersistentVolumeClaimStatus struct {
|
||||
// Phase represents the current phase of PersistentVolumeClaim
|
||||
Phase PersistentVolumeClaimPhase `json:"phase,omitempty"`
|
||||
// AccessModes contains all ways the volume backing the PVC can be mounted
|
||||
AccessModes []AccessModeType `json:"accessModes,omitempty`
|
||||
// Represents the actual resources of the underlying volume
|
||||
Capacity ResourceList `json:"capacity,omitempty"`
|
||||
// VolumeRef is a reference to the PersistentVolume bound to the PersistentVolumeClaim
|
||||
VolumeRef *ObjectReference `json:"volumeRef,omitempty"`
|
||||
}
|
||||
|
||||
type AccessModeType string
|
||||
|
||||
const (
|
||||
@@ -207,6 +288,27 @@ const (
|
||||
ReadWriteMany AccessModeType = "ReadWriteMany"
|
||||
)
|
||||
|
||||
type PersistentVolumePhase string
|
||||
|
||||
const (
|
||||
// used for PersistentVolumes that are not yet bound
|
||||
VolumeAvailable PersistentVolumePhase = "Available"
|
||||
// used for PersistentVolumes that are bound
|
||||
VolumeBound PersistentVolumePhase = "Bound"
|
||||
// used for PersistentVolumes where the bound PersistentVolumeClaim was deleted
|
||||
// released volumes must be recycled before becoming available again
|
||||
VolumeReleased PersistentVolumePhase = "Released"
|
||||
)
|
||||
|
||||
type PersistentVolumeClaimPhase string
|
||||
|
||||
const (
|
||||
// used for PersistentVolumeClaims that are not yet bound
|
||||
ClaimPending PersistentVolumeClaimPhase = "Pending"
|
||||
// used for PersistentVolumeClaims that are bound
|
||||
ClaimBound PersistentVolumeClaimPhase = "Bound"
|
||||
)
|
||||
|
||||
// HostPathVolumeSource represents a host directory mapped into a pod.
|
||||
type HostPathVolumeSource struct {
|
||||
Path string `json:"path"`
|
||||
@@ -390,6 +492,8 @@ type Capabilities struct {
|
||||
type ResourceRequirements struct {
|
||||
// Limits describes the maximum amount of compute resources required.
|
||||
Limits ResourceList `json:"limits,omitempty"`
|
||||
// Requests describes the minimum amount of compute resources required.
|
||||
Requests ResourceList `json:"requests,omitempty"`
|
||||
}
|
||||
|
||||
// Container represents a single container that is expected to be run on the host.
|
||||
@@ -957,6 +1061,8 @@ const (
|
||||
ResourceCPU ResourceName = "cpu"
|
||||
// Memory, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
|
||||
ResourceMemory ResourceName = "memory"
|
||||
// Volume size, in bytes (e,g. 5Gi = 5GiB = 5 * 1024 * 1024 * 1024)
|
||||
ResourceStorage ResourceName = "storage"
|
||||
)
|
||||
|
||||
// ResourceList is a set of (resource name, quantity) pairs.
|
||||
|
||||
Reference in New Issue
Block a user