PHP K8s
Github Repo
3.x
3.x
  • ๐ŸšขIntroduction
  • ๐ŸŽ‰Support
  • โซUpgrading to 3.x
  • Getting Started
    • ๐Ÿš€Installation
    • ๐Ÿ™ŒShowcase
    • ๐Ÿ”’Authentication
    • โ™ป๏ธActive Development
      • ๐Ÿ“—Default Versions
      • ๐Ÿง™Supported Kubernetes versions
      • ๐Ÿ—ณ๏ธPackage versioning
  • Cluster Interaction
    • ๐ŸงญGetting Started
    • ๐ŸŽญCRUD Operations
    • ๐Ÿ“ฆImport from YAML
    • ๐Ÿ‘€Watching Resources
  • Resources
    • ๐Ÿ‘“Base Resource
      • Attributes Methods
      • Metadata Methods
      • Custom Callers
    • ๐Ÿง‘Namespace
    • ๐Ÿ–ฅ๏ธNode
    • ๐Ÿ“กEvent
    • ๐Ÿ“ฆWorkloads
      • Pod
      • Deployment
      • StatefulSet
      • DaemonSet
      • Job
      • CronJob
    • ๐ŸงตConfigurations
      • ConfigMap
      • Secret
    • ๐Ÿ“€Storage
      • StorageClass
      • PersistentVolume
      • PersistentVolumeClaim
    • ๐Ÿ“ถNetworking
      • Service
      • Ingress
    • โ†”๏ธScaling & Availability
      • HorizontalPodAutoscaler
      • PodDisruptionBudget
    • ๐Ÿ”‘RBAC
      • ClusterRole
      • ClusterRoleBinding
      • Role
      • RoleBinding
      • ServiceAccount
  • Instances
    • Affinity
    • Container
    • Container Probes
    • Expressions
    • Resource Metrics
    • RBAC Rules
    • Volumes
  • Advanced
    • ๐ŸฐMacros
    • โœจCreate classes for CRDs
      • ๐ŸŽ‡Getting started
      • ๐ŸฐMacros
      • ๐Ÿ‘€Watchable Resources
      • โ†”๏ธScalable Resources
      • ๐Ÿ’ŠPodable Resources
      • ๐Ÿ“„Loggable Resources
      • ๐Ÿš’Helper Traits
  • Frameworks
    • Laravel
    • PHP Helm
Powered by GitBook
On this page
  • Example
  • Persistent Volume Status

Was this helpful?

  1. Resources
  2. Storage

PersistentVolume

PreviousStorageClassNextPersistentVolumeClaim

Last updated 3 years ago

Was this helpful?

Default version: v1โ€Œ

Example

$pv = $this->cluster
    ->persistentVolume()
    ->setName('disk-1')
    ->setSelectors(['matchLabels' => ['app' => 'bigdata'])
    ->setSource('awsElasticBlockStore', [
        'fsType' => 'ext4',
        'volumeID' => 'vol-xxxxx',
    ])
    ->setCapacity(10, 'Gi')
    ->setAccessModes(['ReadWriteOnce'])
    ->setMountOptions(['nfsvers=4.1'])
    ->setStorageClass('gp2')
    ->create();

You can pass the storage class as a RenokiCo\PhpK8s\Kinds\K8sStorageClass instance:

$sc = $this->cluster
    ->storageClass()
    ->setName('sc1')
    ->setProvisioner('csi.aws.amazon.com')
    ->setParameters(['type' => 'sc1'])
    ->setMountOptions(['debug'])
    ->create();

// Creating the $pv
$pv->setStorageClass($sc)->create();

Persistent Volume Status

The Status API is available to be accessed for fresh instances:

$pv->refresh();

if ($pv->isAvailable()) {
    //
}

You can also check if the PV is bound:

if ($pv->isBound()) {
    //
}
๐Ÿ“€
Official Documentation