k8s

package
v0.0.0-...-c3d4854 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllNamespaces = metav1.NamespaceAll
)

Variables

View Source
var (
	// GVRs used
	GVRs = map[string]schema.GroupVersionResource{
		"nodes":                  {Group: "", Version: "v1", Resource: "nodes"},
		"namespaces":             {Group: "", Version: "v1", Resource: "namespaces"},
		"pods":                   {Group: "", Version: "v1", Resource: "pods"},
		"persistentvolumes":      {Group: "", Version: "v1", Resource: "persistentvolumes"},
		"persistentvolumeclaims": {Group: "", Version: "v1", Resource: "persistentvolumeclaims"},
		"deployments":            {Group: appsV1.GroupName, Version: "v1", Resource: "deployments"},
		"daemonsets":             {Group: appsV1.GroupName, Version: "v1", Resource: "daemonsets"},
		"replicasets":            {Group: appsV1.GroupName, Version: "v1", Resource: "replicasets"},
		"statefulsets":           {Group: appsV1.GroupName, Version: "v1", Resource: "statefulsets"},
		"jobs":                   {Group: batchV1.GroupName, Version: "v1", Resource: "jobs"},
		"cronjobs":               {Group: batchV1.GroupName, Version: "v1", Resource: "cronjobs"},
	}
)

Functions

func GetNodeIp

func GetNodeIp(node *coreV1.Node, addrType coreV1.NodeAddressType) string

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(flags *genericclioptions.ConfigFlags) (*Client, error)

func (*Client) AssertCoreAuthz

func (k8s *Client) AssertCoreAuthz(ctx context.Context) error

AssertCoreAuthz asserts that user/context can access node and pods

func (*Client) AssertMetricsAvailable

func (k8s *Client) AssertMetricsAvailable() error

AssertMetricsAvailable checks for available metrics server every 10th invocation. Otherwise, it returns the last known registration state of metrics server.

func (*Client) ClusterContext

func (k8s *Client) ClusterContext() string

func (*Client) Controller

func (k8s *Client) Controller() *Controller

func (*Client) GetServerVersion

func (k8s *Client) GetServerVersion() string

func (*Client) IsAuthz

func (k8s *Client) IsAuthz(ctx context.Context, resource string, verbs []string) (bool, error)

IsAuthz checks access authorization using SelfSubjectAccessReview

func (*Client) Namespace

func (k8s *Client) Namespace() string

func (*Client) NewNamespace

func (k8s *Client) NewNamespace(name string) string

func (*Client) RESTConfig

func (k8s *Client) RESTConfig() *restclient.Config

func (*Client) Username

func (k8s *Client) Username() string

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func (*Controller) GetAllPodMetrics

func (c *Controller) GetAllPodMetrics(ctx context.Context) ([]*metricsV1beta1.PodMetrics, error)

GetAllPodMetrics retrieve all available pod emtrics

func (*Controller) GetCronJobList

func (c *Controller) GetCronJobList(ctx context.Context) ([]*batchV1.CronJob, error)

func (*Controller) GetDaemonSetList

func (c *Controller) GetDaemonSetList(ctx context.Context) ([]*appsV1.DaemonSet, error)

func (*Controller) GetDeploymentList

func (c *Controller) GetDeploymentList(ctx context.Context) ([]*appsV1.Deployment, error)

func (*Controller) GetJobList

func (c *Controller) GetJobList(ctx context.Context) ([]*batchV1.Job, error)

func (*Controller) GetNamespaceList

func (c *Controller) GetNamespaceList(ctx context.Context) ([]*coreV1.Namespace, error)

func (*Controller) GetNode

func (c *Controller) GetNode(ctx context.Context, nodeName string) (*coreV1.Node, error)

func (*Controller) GetNodeList

func (c *Controller) GetNodeList(ctx context.Context) ([]*coreV1.Node, error)

func (*Controller) GetNodeMetrics

func (c *Controller) GetNodeMetrics(ctx context.Context, nodeName string) (*metricsV1beta1.NodeMetrics, error)

GetNodeMetrics returns metrics for specified node

func (*Controller) GetNodeModels

func (c *Controller) GetNodeModels(ctx context.Context) (models []model.NodeModel, err error)

func (*Controller) GetPVCList

func (c *Controller) GetPVCList(ctx context.Context) ([]*coreV1.PersistentVolumeClaim, error)

func (*Controller) GetPVList

func (c *Controller) GetPVList(ctx context.Context) ([]*coreV1.PersistentVolume, error)

func (*Controller) GetPodList

func (c *Controller) GetPodList(ctx context.Context) ([]*coreV1.Pod, error)

func (*Controller) GetPodMetricsByName

func (c *Controller) GetPodMetricsByName(ctx context.Context, pod *v1.Pod) (*metricsV1beta1.PodMetrics, error)

GetPodMetricsByName returns pod metrics for specified pod

func (*Controller) GetPodModels

func (c *Controller) GetPodModels(ctx context.Context) (models []model.PodModel, err error)

func (*Controller) GetReplicaSetList

func (c *Controller) GetReplicaSetList(ctx context.Context) ([]*appsV1.ReplicaSet, error)

func (*Controller) GetStatefulSetList

func (c *Controller) GetStatefulSetList(ctx context.Context) ([]*appsV1.StatefulSet, error)

func (*Controller) SetClusterSummaryRefreshFunc

func (c *Controller) SetClusterSummaryRefreshFunc(fn RefreshSummaryFunc) *Controller

func (*Controller) SetNodeRefreshFunc

func (c *Controller) SetNodeRefreshFunc(fn RefreshNodesFunc) *Controller

func (*Controller) SetPodRefreshFunc

func (c *Controller) SetPodRefreshFunc(fn RefreshPodsFunc) *Controller

func (*Controller) Start

func (c *Controller) Start(ctx context.Context, resync time.Duration) error

type NodeMetricsInformer

type NodeMetricsInformer struct {
	// contains filtered or unexported fields
}

func NewNodeMetricsInformer

func NewNodeMetricsInformer(client metricsclient.Interface, resyncPeriod time.Duration) *NodeMetricsInformer

func (*NodeMetricsInformer) Informer

func (*NodeMetricsInformer) Lister

type NodeMetricsLister

type NodeMetricsLister struct {
	// contains filtered or unexported fields
}

func NewNodeMetricsLister

func NewNodeMetricsLister(indexer cache.Indexer) *NodeMetricsLister

func (*NodeMetricsLister) Get

func (*NodeMetricsLister) List

func (s *NodeMetricsLister) List(selector labels.Selector) (ret []*metricsV1beta1.NodeMetrics, err error)

type PodMetricsInformer

type PodMetricsInformer struct {
	// contains filtered or unexported fields
}

func NewPodMetricsInformer

func NewPodMetricsInformer(client metricsclient.Interface, resyncPeriod time.Duration, namespace string) *PodMetricsInformer

func (*PodMetricsInformer) Informer

func (*PodMetricsInformer) Lister

func (i *PodMetricsInformer) Lister() *PodMetricsLister

type PodMetricsLister

type PodMetricsLister struct {
	// contains filtered or unexported fields
}

func NewPodMetricsLister

func NewPodMetricsLister(indexer cache.Indexer) *PodMetricsLister

func (*PodMetricsLister) Get

func (*PodMetricsLister) List

func (s *PodMetricsLister) List(selector labels.Selector) (ret []*metricsV1beta1.PodMetrics, err error)

type RefreshNodesFunc

type RefreshNodesFunc func(ctx context.Context, items []model.NodeModel) error

type RefreshPodsFunc

type RefreshPodsFunc func(ctx context.Context, items []model.PodModel) error

type RefreshSummaryFunc

type RefreshSummaryFunc func(ctx context.Context, items model.ClusterSummary) error

Jump to

Keyboard shortcuts

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