Documentation ¶
Index ¶
- Constants
- Variables
- func Can(verbs []string, v string) bool
- func CleanseNamespace(ns string) string
- func FQN(ns, n string) string
- func IsAllNamespace(ns string) bool
- func IsAllNamespaces(ns string) bool
- func IsClusterScoped(ns string) bool
- func IsClusterWide(ns string) bool
- func IsNamespaced(ns string) bool
- func MetaFQN(m metav1.ObjectMeta) string
- func Namespaced(p string) (string, string)
- type APIClient
- func (a *APIClient) CachedDiscoveryOrDie() *disk.CachedDiscoveryClient
- func (a *APIClient) CanI(ns, gvr string, verbs []string) (auth bool, err error)
- func (a *APIClient) Config() *Config
- func (a *APIClient) CurrentNamespaceName() (string, error)
- func (a *APIClient) DialOrDie() kubernetes.Interface
- func (a *APIClient) DynDialOrDie() dynamic.Interface
- func (a *APIClient) HasMetrics() bool
- func (a *APIClient) IsNamespaced(res string) bool
- func (a *APIClient) MXDial() (*versioned.Clientset, error)
- func (a *APIClient) RestConfigOrDie() *restclient.Config
- func (a *APIClient) ServerVersion() (*version.Info, error)
- func (a *APIClient) SupportsRes(group string, versions []string) (string, bool, error)
- func (a *APIClient) SupportsResource(group string) bool
- func (a *APIClient) SwitchContextOrDie(ctx string)
- func (a *APIClient) ValidNamespaces() ([]v1.Namespace, error)
- type Authorizer
- type ClusterMetrics
- type Config
- func (c *Config) CheckConnectivity() bool
- func (c *Config) ClusterNameFromContext(ctx string) (string, error)
- func (c *Config) ClusterNames() ([]string, error)
- func (c *Config) ConfigAccess() (clientcmd.ConfigAccess, error)
- func (c *Config) ContextNames() ([]string, error)
- func (c *Config) Contexts() (map[string]*clientcmdapi.Context, error)
- func (c *Config) CurrentClusterName() (string, error)
- func (c *Config) CurrentContextName() (string, error)
- func (c *Config) CurrentGroupNames() ([]string, error)
- func (c *Config) CurrentNamespaceName() (string, error)
- func (c *Config) CurrentUserName() (string, error)
- func (c *Config) DelContext(n string) error
- func (c *Config) Flags() *genericclioptions.ConfigFlags
- func (c *Config) GetContext(n string) (*clientcmdapi.Context, error)
- func (c *Config) NamespaceNames(nns []v1.Namespace) []string
- func (c *Config) RESTConfig() (*restclient.Config, error)
- func (c *Config) RawConfig() (clientcmdapi.Config, error)
- func (c *Config) SwitchContext(name string) error
- type Connection
- type GVR
- func (g GVR) AsResourceName() string
- func (g GVR) G() string
- func (g GVR) GR() *schema.GroupResource
- func (g GVR) GV() schema.GroupVersion
- func (g GVR) GVR() schema.GroupVersionResource
- func (g GVR) R() string
- func (g GVR) RG() (string, string)
- func (g GVR) String() string
- func (g GVR) SubResource() string
- func (g GVR) V() string
- type GVRs
- type MetricsServer
- func (m *MetricsServer) ClusterLoad(nos *v1.NodeList, nmx *mv1beta1.NodeMetricsList, mx *ClusterMetrics) error
- func (m *MetricsServer) FetchNodesMetrics() (*mv1beta1.NodeMetricsList, error)
- func (m *MetricsServer) FetchPodMetrics(ns, sel string) (*mv1beta1.PodMetrics, error)
- func (m *MetricsServer) FetchPodsMetrics(ns string) (*mv1beta1.PodMetricsList, error)
- func (m *MetricsServer) NodesMetrics(nodes *v1.NodeList, metrics *mv1beta1.NodeMetricsList, mmx NodesMetrics)
- func (m *MetricsServer) PodsMetrics(pods *mv1beta1.PodMetricsList, mmx PodsMetrics)
- type NodeMetrics
- type NodesMetrics
- type PodMetrics
- type PodsMetrics
Constants ¶
const ( // NA Not available NA = "n/a" // NamespaceAll designates the fictional all namespace. NamespaceAll = "all" // AllNamespaces designates all namespaces. AllNamespaces = "" // ClusterScope designates a resource is not namespaced. ClusterScope = "-" )
const ( // CreateVerb represents create access on a resource. CreateVerb = "create" // UpdateVerb represents an update access on a resource. UpdateVerb = "update" // PatchVerb represents a patch access on a resource. PatchVerb = "patch" // DeleteVerb represents a delete access on a resource. DeleteVerb = "delete" // GetVerb represents a get access on a resource. GetVerb = "get" // ListVerb represents a list access on a resource. ListVerb = "list" // WatchVerb represents a watch access on a resource. WatchVerb = "watch" )
Variables ¶
var ( // GetAccess reads a resource. GetAccess = []string{GetVerb} // ListAccess list resources. ListAccess = []string{ListVerb} // MonitorAccess monitors a collection of resources. MonitorAccess = []string{ListVerb, WatchVerb} // ReadAllAccess represents an all read access to a resource. ReadAllAccess = []string{GetVerb, ListVerb, WatchVerb} )
Functions ¶
func CleanseNamespace ¶
CleanseNamespace ensures all ns maps to blank.
func IsAllNamespaces ¶
IsAllNamespaces returns true if all namespaces, false otherwise.
func IsClusterScoped ¶
IsClusterScoped returns true if resource is not namespaced.
func IsClusterWide ¶
IsClusterWide returns true if ns designates cluster scope, false otherwise.
func IsNamespaced ¶
IsNamespaced returns true if a specific ns is given.
func MetaFQN ¶
func MetaFQN(m metav1.ObjectMeta) string
MetaFQN returns a fully qualified resource name.
func Namespaced ¶
Namespaced converts a resource path to namespace and resource name.
Types ¶
type APIClient ¶
type APIClient struct {
// contains filtered or unexported fields
}
APIClient represents a Kubernetes api client.
func InitConnectionOrDie ¶
InitConnectionOrDie initialize connection from command line args. Checks for connectivity with the api server.
func (*APIClient) CachedDiscoveryOrDie ¶
func (a *APIClient) CachedDiscoveryOrDie() *disk.CachedDiscoveryClient
CachedDiscoveryOrDie returns a cached discovery client.
func (*APIClient) CurrentNamespaceName ¶
CurrentNamespaceName return namespace name set via either cli arg or cluster config.
func (*APIClient) DialOrDie ¶
func (a *APIClient) DialOrDie() kubernetes.Interface
DialOrDie returns a handle to api server or die.
func (*APIClient) DynDialOrDie ¶
DynDialOrDie returns a handle to a dynamic interface.
func (*APIClient) HasMetrics ¶
HasMetrics returns true if the cluster supports metrics.
func (*APIClient) IsNamespaced ¶
IsNamespaced check on server if given resource is namespaced
func (*APIClient) RestConfigOrDie ¶
func (a *APIClient) RestConfigOrDie() *restclient.Config
RestConfigOrDie returns a rest api client.
func (*APIClient) ServerVersion ¶
ServerVersion returns the current server version info.
func (*APIClient) SupportsRes ¶
SupportsRes checks latest supported version.
func (*APIClient) SupportsResource ¶
SupportsResource checks for resource supported version against the server.
func (*APIClient) SwitchContextOrDie ¶
SwitchContextOrDie handles kubeconfig context switches.
type Authorizer ¶
type Authorizer interface { // CanI returns true if the user can use these actions for a given resource. CanI(ns, gvr string, verbs []string) (bool, error) }
Authorizer checks what a user can or cannot do to a resource.
type ClusterMetrics ¶
ClusterMetrics summarizes total node metrics as percentages.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config tracks a kubernetes configuration.
func NewConfig ¶
func NewConfig(f *genericclioptions.ConfigFlags) *Config
NewConfig returns a new k8s config or an error if the flags are invalid.
func (*Config) CheckConnectivity ¶
CheckConnectivity return true if api server is cool or false otherwise.
func (*Config) ClusterNameFromContext ¶
ClusterNameFromContext returns the cluster associated with the given context.
func (*Config) ClusterNames ¶
ClusterNames fetch all kubeconfig defined clusters.
func (*Config) ConfigAccess ¶
func (c *Config) ConfigAccess() (clientcmd.ConfigAccess, error)
ConfigAccess return the current kubeconfig api server access configuration.
func (*Config) ContextNames ¶
ContextNames fetch all available contexts.
func (*Config) Contexts ¶
func (c *Config) Contexts() (map[string]*clientcmdapi.Context, error)
Contexts fetch all available contexts.
func (*Config) CurrentClusterName ¶
CurrentClusterName returns the active cluster name.
func (*Config) CurrentContextName ¶
CurrentContextName returns the currently active config context.
func (*Config) CurrentGroupNames ¶
CurrentGroupNames retrieves the active group names.
func (*Config) CurrentNamespaceName ¶
CurrentNamespaceName retrieves the active namespace.
func (*Config) CurrentUserName ¶
CurrentUserName retrieves the active user name.
func (*Config) DelContext ¶
DelContext remove a given context from the configuration.
func (*Config) Flags ¶
func (c *Config) Flags() *genericclioptions.ConfigFlags
Flags returns configuration flags.
func (*Config) GetContext ¶
func (c *Config) GetContext(n string) (*clientcmdapi.Context, error)
GetContext fetch a given context or error if it does not exists.
func (*Config) NamespaceNames ¶
NamespaceNames fetch all available namespaces on current cluster.
func (*Config) RESTConfig ¶
func (c *Config) RESTConfig() (*restclient.Config, error)
RESTConfig fetch the current REST api service connection.
func (*Config) RawConfig ¶
func (c *Config) RawConfig() (clientcmdapi.Config, error)
RawConfig fetch the current kubeconfig with no overrides.
func (*Config) SwitchContext ¶
SwitchContext changes the kubeconfig context to a new cluster.
type Connection ¶
type Connection interface { Authorizer Config() *Config DialOrDie() kubernetes.Interface SwitchContextOrDie(ctx string) CachedDiscoveryOrDie() *disk.CachedDiscoveryClient RestConfigOrDie() *restclient.Config MXDial() (*versioned.Clientset, error) DynDialOrDie() dynamic.Interface HasMetrics() bool IsNamespaced(n string) bool SupportsResource(group string) bool ValidNamespaces() ([]v1.Namespace, error) SupportsRes(grp string, versions []string) (string, bool, error) ServerVersion() (*version.Info, error) CurrentNamespaceName() (string, error) }
Connection represents a Kubenetes apiserver connection. BOZO!! Refactor!
type GVR ¶
type GVR struct {
// contains filtered or unexported fields
}
GVR represents a kubernetes resource schema as a string. Format is group/version/resources:subresource
func FromGVAndR ¶
FromGVAndR builds a gvr from a group/version and resource.
func NewGVRFromMeta ¶
func NewGVRFromMeta(a metav1.APIResource) GVR
NewGVRFromMeta builds a gvr from resource metadata.
func (GVR) AsResourceName ¶
AsResourceName returns a resource . separated descriptor in the shape of kind.version.group.
func (GVR) GR ¶ added in v0.13.1
func (g GVR) GR() *schema.GroupResource
AsGR returns a a full schema representation.
func (GVR) GV ¶ added in v0.13.1
func (g GVR) GV() schema.GroupVersion
AsGV returns the group version scheme representation.
func (GVR) GVR ¶ added in v0.13.1
func (g GVR) GVR() schema.GroupVersionResource
AsGVR returns a a full schema representation.
func (GVR) SubResource ¶
SubResource returns a sub resource if available.
type MetricsServer ¶
type MetricsServer struct {
Connection
}
MetricsServer serves cluster metrics for nodes and pods.
func NewMetricsServer ¶
func NewMetricsServer(c Connection) *MetricsServer
NewMetricsServer return a metric server instance.
func (*MetricsServer) ClusterLoad ¶
func (m *MetricsServer) ClusterLoad(nos *v1.NodeList, nmx *mv1beta1.NodeMetricsList, mx *ClusterMetrics) error
ClusterLoad retrieves all cluster nodes metrics.
func (*MetricsServer) FetchNodesMetrics ¶
func (m *MetricsServer) FetchNodesMetrics() (*mv1beta1.NodeMetricsList, error)
FetchNodesMetrics return all metrics for pods in a given namespace.
func (*MetricsServer) FetchPodMetrics ¶
func (m *MetricsServer) FetchPodMetrics(ns, sel string) (*mv1beta1.PodMetrics, error)
FetchPodMetrics return all metrics for pods in a given namespace.
func (*MetricsServer) FetchPodsMetrics ¶
func (m *MetricsServer) FetchPodsMetrics(ns string) (*mv1beta1.PodMetricsList, error)
FetchPodsMetrics return all metrics for pods in a given namespace.
func (*MetricsServer) NodesMetrics ¶
func (m *MetricsServer) NodesMetrics(nodes *v1.NodeList, metrics *mv1beta1.NodeMetricsList, mmx NodesMetrics)
NodesMetrics retrieves metrics for a given set of nodes.
func (*MetricsServer) PodsMetrics ¶
func (m *MetricsServer) PodsMetrics(pods *mv1beta1.PodMetricsList, mmx PodsMetrics)
PodsMetrics retrieves metrics for all pods in a given namespace.
type NodeMetrics ¶
type NodeMetrics struct { AvailCPU int64 AvailMEM float64 TotalCPU int64 TotalMEM float64 // contains filtered or unexported fields }
NodeMetrics describes raw node metrics.
type NodesMetrics ¶
type NodesMetrics map[string]NodeMetrics
NodesMetrics tracks usage metrics per nodes.
type PodMetrics ¶
type PodMetrics currentMetrics
PodMetrics represent an aggregation of all pod containers metrics.
type PodsMetrics ¶
type PodsMetrics map[string]PodMetrics
PodsMetrics tracks usage metrics per pods.