Documentation
¶
Index ¶
- type Client
- func (c *Client) APIResource(apiVersion, kind string) (*metav1.APIResource, error)
- func (c *Client) APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
- func (c *Client) ApiExt() apixv1client.ApiextensionsV1Interface
- func (c *Client) DefaultNamespace() string
- func (c *Client) Dynamic() dynamic.Interface
- func (c *Client) GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
- func (c *Client) Init() error
- func (c *Client) InvalidateDiscoveryCache()
- func (c *Client) Metadata() metadata.Interface
- func (c *Client) NewBuilder() *resource.Builder
- func (c *Client) ReloadDynamic(gvrList map[schema.GroupVersionResource]string)
- func (c *Client) RestConfig() *rest.Config
- func (c *Client) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (c *Client) ToRESTConfig() (*rest.Config, error)
- func (c *Client) ToRESTMapper() (meta.RESTMapper, error)
- func (c *Client) ToRawKubeConfigLoader() clientcmd.ClientConfig
- func (c *Client) WithAcceptOnlyJSONContentType(e bool)
- func (c *Client) WithConfigPath(path string)
- func (c *Client) WithContextName(name string)
- func (c *Client) WithLogger(logger *log.Logger)
- func (c *Client) WithMetricLabels(labels map[string]string)
- func (c *Client) WithMetricPrefix(prefix string)
- func (c *Client) WithMetricStorage(storage MetricStorage)
- func (c *Client) WithRateLimiterSettings(qps float32, burst int)
- func (c *Client) WithRestConfig(config *rest.Config)
- func (c *Client) WithServer(server string)
- func (c *Client) WithTimeout(timeout time.Duration)
- type MetricStorage
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
kubernetes.Interface
// contains filtered or unexported fields
}
func (*Client) APIResource ¶
func (c *Client) APIResource(apiVersion, kind string) (*metav1.APIResource, error)
APIResource fetches APIResource object from cluster that specifies the name of a resource and whether it is namespaced. if resource not found, we try to invalidate cache and
NOTE that fetching with empty apiVersion can give errors if there are non-working api controllers in cluster.
func (*Client) APIResourceList ¶
func (c *Client) APIResourceList(apiVersion string) ([]*metav1.APIResourceList, error)
APIResourceList fetches lists of APIResource objects from cluster. It returns all preferred resources if apiVersion is empty. An array with one list is returned if apiVersion is valid.
NOTE that fetching all preferred resources can give errors if there are non-working api controllers in cluster.
func (*Client) ApiExt ¶
func (c *Client) ApiExt() apixv1client.ApiextensionsV1Interface
func (*Client) DefaultNamespace ¶
func (*Client) GroupVersionResource ¶
func (c *Client) GroupVersionResource(apiVersion, kind string) (schema.GroupVersionResource, error)
GroupVersionResource returns a GroupVersionResource object to use with dynamic informer.
This method is borrowed from kubectl and kubedog. The difference are: - lower case comparison with kind, name and all short names
func (*Client) InvalidateDiscoveryCache ¶ added in v1.0.1
func (c *Client) InvalidateDiscoveryCache()
InvalidateDiscoveryCache allows you to invalidate cache manually, for example, when you are deploying CRD KubeClient tries to invalidate cache automatically when needed, but you can save a few resources to call this manually
func (*Client) NewBuilder ¶ added in v1.2.3
func (*Client) ReloadDynamic ¶ added in v0.25.0
func (c *Client) ReloadDynamic(gvrList map[schema.GroupVersionResource]string)
ReloadDynamic creates new dynamic client with the new set of CRDs.
func (*Client) RestConfig ¶ added in v1.0.0
RestConfig returns kubernetes Config with the common attributes that was passed on initialization.
func (*Client) ToDiscoveryClient ¶ added in v1.2.3
func (c *Client) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
func (*Client) ToRESTMapper ¶ added in v1.2.3
func (c *Client) ToRESTMapper() (meta.RESTMapper, error)
func (*Client) ToRawKubeConfigLoader ¶ added in v1.2.3
func (c *Client) ToRawKubeConfigLoader() clientcmd.ClientConfig
func (*Client) WithAcceptOnlyJSONContentType ¶ added in v1.5.2
func (*Client) WithConfigPath ¶
func (*Client) WithContextName ¶
func (*Client) WithLogger ¶ added in v1.5.2
func (*Client) WithMetricLabels ¶
WithMetricLabels sets extra label key/value pairs that are attached to every metric sample emitted by this client.
func (*Client) WithMetricPrefix ¶ added in v1.7.0
WithMetricPrefix sets the prefix that replaces the {PREFIX} placeholder in all Kubernetes client metric names (see internal/metrics). An empty prefix removes the placeholder, making the metric names start with "kubernetes_".
func (*Client) WithMetricStorage ¶
func (c *Client) WithMetricStorage(storage MetricStorage)
WithMetricStorage sets the metric storage backend used to record Kubernetes client metrics. Call WithMetricLabels and WithMetricPrefix before Init to customise dimensions and the metric name prefix.
func (*Client) WithRateLimiterSettings ¶
func (*Client) WithRestConfig ¶ added in v1.5.1
WithRestConfig sets a pre-configured rest.Config for the client
func (*Client) WithServer ¶
func (*Client) WithTimeout ¶
type MetricStorage ¶
type MetricStorage interface {
RegisterCounter(metric string, labels map[string]string) *prometheus.CounterVec
CounterAdd(metric string, value float64, labels map[string]string)
RegisterHistogram(metric string, labels map[string]string, buckets []float64) *prometheus.HistogramVec
HistogramObserve(metric string, value float64, labels map[string]string, buckets []float64)
}
MetricStorage is the interface that metric backends must implement to receive Kubernetes client metrics. It mirrors the Storage interface in internal/metrics so that callers outside this module can implement it without importing the internal package.
Implementations are typically provided by flant/shell-operator's metrics-storage package or any Prometheus-backed equivalent.