kubernetes

package
v0.0.0-...-414c732 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container struct {
	Name  string `json:"name"`
	Usage Usage  `json:"usage"`
}

type Hook

type Hook struct {
	Header     string
	Exec       []string
	Name       string
	Image      string
	MountPoint string
	PreHook    string
	PostHook   string
}

type Ingress

type Ingress interface {
}

type Kubernetes

type Kubernetes interface {
	GetClient() *kubeapi.Clientset
	GetDeployments(namespace string) (*appsv1.DeploymentList, error)
	GetEvents(namespace string) (*corev1.EventList, error)
	GetHelmPods(namespace string) (*corev1.PodList, error)
	GetPods(namespace string) (*corev1.PodList, error)
	GetHpaV1s(namespace string) (*scalev1.HorizontalPodAutoscalerList, error)
	GetHpaV2s(namespace string) (*scalev2.HorizontalPodAutoscalerList, error)

	GetNodes() (*corev1.NodeList, error)
	GetPVs() (*corev1.PersistentVolumeList, error)

	GetPodMetrics() (*PodMetricsList, error)
	GetNodeMetrics(nodes []string) ([]NodeMetricsList, error)

	SetReadable(flag bool) error
	SetWriteable(flag bool) error

	Ping() error
	Cron(
		name string,
		command string,
		schedule, namespace string,
		extendVolumes ...[]corev1.PersistentVolumeClaim,
	) error
	Do(
		name string,
		command string,
		namespace string,
		extendVolumes ...[]corev1.PersistentVolumeClaim,
	) error
}

func NewFromClient

func NewFromClient(client Kubernetes, hook ...Hook) Kubernetes

func NewFromKubeconfig

func NewFromKubeconfig(config []byte, hook ...Hook) (Kubernetes, error)

func NewFromRestConfig

func NewFromRestConfig(restConfig *rest.Config, hook ...Hook) (Kubernetes, error)

type NodeMetricsList

type NodeMetricsList struct {
	Pods []*PodRef `json:"pods"`
}

type PodMetricsList

type PodMetricsList struct {
	Kind       string `json:"kind"`
	APIVersion string `json:"apiVersion"`
	Metadata   struct {
		SelfLink string `json:"selfLink"`
	} `json:"metadata"`
	Items []struct {
		Metadata struct {
			Name              string    `json:"name"`
			Namespace         string    `json:"namespace"`
			SelfLink          string    `json:"selfLink"`
			CreationTimestamp time.Time `json:"creationTimestamp"`
		} `json:"metadata"`
		Timestamp  time.Time   `json:"timestamp"`
		Window     string      `json:"window"`
		Containers []Container `json:"containers"`
	} `json:"items"`
}

type PodRef

type PodRef struct {
	PodRef struct {
		Name      string `json:"name"`
		Namespace string `json:"namespace"`
	} `json:"podRef"`
	Volumes []*Volume `json:"volume"`
}

type Pool

type Pool interface {
}

type Tenant

type Tenant interface {
	GetName() string
	GetAliases() []string
	GetClient() (Kubernetes, error)
	GetMetadata() (interface{}, error)
	GetProvider() (string, error)
	GetKubeconfig() ([]byte, error)
	GetPool(name string) (Pool, error)
	GetExpiredTime() int64

	SetPool(name string, pool Pool) error

	IsReadable() bool
	IsWriteable() bool
}

func NewDefaultTenant

func NewDefaultTenant(
	name string,
	kubeconfig []byte,
	metadata ...interface{},
) (Tenant, error)

func NewDefaultTenantV1

func NewDefaultTenantV1(
	name string,
	kubeconfig []byte,
	metadata ...interface{},
) (Tenant, error)

func NewDefaultTenantV2

func NewDefaultTenantV2(
	name string,
	kubeconfig []byte,
	readable bool,
	writeable bool,
	metadata ...interface{},
) (Tenant, error)

type Usage

type Usage struct {
	CPU    string `json:"cpu"`
	Memory string `json:"memory"`
}

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"`
}

Jump to

Keyboard shortcuts

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