Storage¶
This module primarily deals with storage classes. These functions call Kubectl at the command line. create_storage_class() and delete_storage_class() will output information to the screen as well as return the output as a string. If you want to turn off the output to console off, call set_storage_output(False).
- k9.storage.list_storage_classes()[source]¶
List all storage class
- Returns
Returns a list of storage classes.
Example Output:
{ "apiVersion": "v1", "items": [ { "allowVolumeExpansion": true, "apiVersion": "storage.k8s.io/v1", "kind": "StorageClass", "metadata": { "creationTimestamp": "2019-12-20T14:18:10Z", "name": "aws-storage-class", "resourceVersion": "3708823", "selfLink": "/apis/storage.k8s.io/v1/storageclasses/aws-storage-class", "uid": "8d3a7012-2333-11ea-b829-025000000001" }, "parameters": { "fsType": "ext4", "type": "gp2" }, "provisioner": "kubernetes.io/aws-ebs", "reclaimPolicy": "Retain", "volumeBindingMode": "Immediate" }, { "apiVersion": "storage.k8s.io/v1", "kind": "StorageClass", "metadata": { "annotations": { "storageclass.kubernetes.io/is-default-class": "true" }, "creationTimestamp": "2019-10-01T23:34:49Z", "name": "hostpath", "resourceVersion": "527", "selfLink": "/apis/storage.k8s.io/v1/storageclasses/hostpath", "uid": "0f5bccbc-e4a4-11e9-90c3-025000000001" }, "provisioner": "docker.io/hostpath", "reclaimPolicy": "Delete", "volumeBindingMode": "Immediate" } ], "kind": "List", "metadata": { "resourceVersion": "", "selfLink": "" } }
- k9.storage.storage_class_exists(name: str)[source]¶
- Parameters
name – Storage class name
- Returns
True if specified storage class exists.
- k9.storage.create_storage_class(fn: str)[source]¶
- Parameters
fn – Filename of storage class description
- Returns
Example:
from k9.storage import create_storage_class result = create_storage_class('storage.yaml')
Sample YAML file:
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: aws-storage-clas provisioner: kubernetes.io/aws-ebs parameters: type: gp2 fsType: ext4 volumeBindingMode: Immediate reclaimPolicy: Retain allowVolumeExpansion: true