df_pv

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertQuantityValueToHumanReadableDecimalString added in v0.2.3

func ConvertQuantityValueToHumanReadableDecimalString(quantity *resource.Quantity) string

ConvertQuantityValueToHumanReadableDecimalString converts value to human readable decimal format

func ConvertQuantityValueToHumanReadableIECString

func ConvertQuantityValueToHumanReadableIECString(quantity *resource.Quantity) string

ConvertQuantityValueToHumanReadableIECString converts value to human readable IEC format https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

func GetColorFromPercentageUsed added in v0.2.1

func GetColorFromPercentageUsed(percentageUsed float64) text.Color

GetColorFromPercentageUsed gives a color based on percentage

func GetKubeConfigFromGenericCliConfigFlags added in v0.2.5

func GetKubeConfigFromGenericCliConfigFlags(genericCliConfigFlags *genericclioptions.ConfigFlags) (*rest.Config, error)

GetKubeConfigFromGenericCliConfigFlags gets the kubeconfig from all the flags

func GetOutputRowPVCFromNode added in v0.2.6

func GetOutputRowPVCFromNode(ctx context.Context, clientset *kubernetes.Clientset, desiredNamespace string, nodeName string, outputRowPVCChan chan<- *OutputRowPVC) error

GetOutputRowPVCFromNode gets the output row given a nodeName

func GetPVNameFromPVCName added in v0.2.3

func GetPVNameFromPVCName(ctx context.Context, clientset *kubernetes.Clientset, namespace string, pvcName string) (string, error)

GetPVNameFromPVCName returns the name of persistent volume given a namespace and persistent volume claim name

func GetWhichNodesToQueryBasedOnNamespace added in v0.2.6

func GetWhichNodesToQueryBasedOnNamespace(ctx context.Context, clientset *kubernetes.Clientset, desiredNamespace string) (map[string][]string, error)

GetWhichNodesToQueryBasedOnNamespace gets a list of nodes to query for all the pods in a namespace

func InitAndExecute

func InitAndExecute()

InitAndExecute sets up and executes the cobra root command

func KubeConfigPath

func KubeConfigPath() (string, error)

KubeConfigPath returns the path to kubeconfig file

func ListNodes

func ListNodes(ctx context.Context, clientset *kubernetes.Clientset) (*corev1.NodeList, error)

ListNodes returns a list of nodes

func ListPVCs added in v0.2.6

func ListPVCs(ctx context.Context, clientset *kubernetes.Clientset, namespace string) (*corev1.PersistentVolumeClaimList, error)

ListPVCs returns a list of PVCs for a given namespace

func ListPVs added in v0.2.6

func ListPVs(ctx context.Context, clientset *kubernetes.Clientset, namespace string)

ListPVs returns a list of PVs, scoped to corresponding mapped PVCs based on the namespace

func ListPods added in v0.2.6

func ListPods(ctx context.Context, clientset *kubernetes.Clientset, namespace string) (*corev1.PodList, error)

ListPods returns a list of pods

func ListPodsWithPersistentVolumeClaims added in v0.2.6

func ListPodsWithPersistentVolumeClaims(ctx context.Context, clientset *kubernetes.Clientset, namespace string) ([]corev1.Pod, error)

ListPodsWithPersistentVolumeClaims returns a list of pods with PVCs kubectl get pods --all-namespaces -o=json | jq -c \ '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName:.spec.volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'

func PrintUsingGoPretty added in v0.2.1

func PrintUsingGoPretty(sliceOfOutputRowPVC []*OutputRowPVC, disableColor bool)

PrintUsingGoPretty prints a slice of output rows

func ProduceOutputRowsConcurrently added in v0.2.6

func ProduceOutputRowsConcurrently(ctx context.Context, clientset *kubernetes.Clientset, desiredNamespace string, nodeNames []string, outputRowPVCChan chan<- *OutputRowPVC) error

ProduceOutputRowsConcurrently produces output rows concurrently

Types

type OutputRowPVC

type OutputRowPVC struct {
	PVName          string             `json:"pvName"`
	PVCName         string             `json:"pvcName"`
	Namespace       string             `json:"namespace"`
	NodeName        string             `json:"nodeName"`
	PodName         string             `json:"podName"`
	VolumeMountName string             `json:"volumeMountName"`
	AvailableBytes  *resource.Quantity `json:"availableBytes"` // TODO: use uint64 here as well? but resource.Quantity takes int64
	CapacityBytes   *resource.Quantity `json:"capacityBytes"`
	UsedBytes       *resource.Quantity `json:"usedBytes"`
	InodesFree      uint64             `json:"inodesFree"`
	Inodes          uint64             `json:"inodes"`
	InodesUsed      uint64             `json:"inodesUsed"`
	PercentageUsed  float64            `json:"percentageUsed"`
	PercentageIUsed float64            `json:"percentageIUsed"`
}

OutputRowPVC represents the output row

func ConsumeOutputRowsConcurrently added in v0.2.6

func ConsumeOutputRowsConcurrently(outputRowPVCChan <-chan *OutputRowPVC) []*OutputRowPVC

ConsumeOutputRowsConcurrently consumes processed output rows concurrently

func GetOutputRowPVCFromPodAndVolume

func GetOutputRowPVCFromPodAndVolume(ctx context.Context, clientset *kubernetes.Clientset, pod *Pod, vol *Volume, desiredNamespace string) *OutputRowPVC

GetOutputRowPVCFromPodAndVolume gets an output row for a given pod, volume and optionally namespace

func GetSliceOfOutputRowPVC

func GetSliceOfOutputRowPVC(flags *flagpole) ([]*OutputRowPVC, error)

GetSliceOfOutputRowPVC gets the output row

type Pod

type Pod struct {
	/*
		EXAMPLE:
		"podRef": {
		     "name": "configs-service-59c9c7586b-5jchj",
		     "namespace": "onprem",
		     "uid": "5fbb63da-d0a3-4493-8d27-6576b63119f5"
		    }
	*/
	PodRef struct {
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	} `json:"podRef"`
	/*
		EXAMPLE:
		"volume": [
		     {...},
		     {...}
		    ]
	*/
	ListOfVolumes []*Volume `json:"volume"`
}

Pod represents pod spec in the server response

type ServerResponseStruct

type ServerResponseStruct struct {
	Pods []*Pod `json:"pods"`
}

ServerResponseStruct represents the response at the node endpoint

type Volume

type Volume struct {
	// The time at which these stats were updated.
	Time metav1.Time `json:"time"`

	// Used represents the total bytes used by the Volume.
	// Note: For block devices this maybe more than the total size of the files.
	UsedBytes int64 `json:"usedBytes"` // TODO: use uint64 here as well?

	// Capacity represents the total capacity (bytes) of the volume's
	// underlying storage. For Volumes that share a filesystem with the host
	// (e.g. emptydir, hostpath) this is the size of the underlying storage,
	// and will not equal Used + Available as the fs is shared.
	CapacityBytes int64 `json:"capacityBytes"`

	// Available represents the storage space available (bytes) for the
	// Volume. For Volumes that share a filesystem with the host (e.g.
	// emptydir, hostpath), this is the available space on the underlying
	// storage, and is shared with host processes and other Volumes.
	AvailableBytes int64 `json:"availableBytes"`

	// InodesUsed represents the total inodes used by the Volume.
	InodesUsed uint64 `json:"inodesUsed"`

	// Inodes represents the total number of inodes available in the volume.
	// For volumes that share a filesystem with the host (e.g. emptydir, hostpath),
	// this is the inodes available in the underlying storage,
	// and will not equal InodesUsed + InodesFree as the fs is shared.
	Inodes uint64 `json:"inodes"`

	// InodesFree represent the inodes available for the volume.  For Volumes that share
	// a filesystem with the host (e.g. emptydir, hostpath), this is the free inodes
	// on the underlying storage, and is shared with host processes and other volumes
	InodesFree uint64 `json:"inodesFree"`

	Name   string `json:"name"`
	PvcRef struct {
		PvcName      string `json:"name"`
		PvcNamespace string `json:"namespace"`
	} `json:"pvcRef"`
}

Volume represents the volume struct

EXAMPLE: { "time": "2019-11-25T20:33:19Z", "availableBytes": 25674719232, "capacityBytes": 25674731520, "usedBytes": 12288, "inodesFree": 6268236, "inodes": 6268245, "inodesUsed": 9, "name": "vault-client" }

https://github.com/kubernetes/kubernetes/blob/v1.18.5/pkg/volume/volume.go https://github.com/kubernetes/kubernetes/blob/v1.18.5/pkg/volume/csi/csi_client.go#L553

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL