census

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: May 7, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package census surveys container image names in a Kubernetes cluster.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client is a configurable Taker wrapping kubernetes.Interface.

func NewClient

func NewClient(clientset kubernetes.Interface, opts ...Option) (*Client, error)

NewClient returns a Taker that surveys resources from clientset. If no WithLister option is included in opts, no resources will be surveyed.

func NewDefaultClient

func NewDefaultClient(clientset kubernetes.Interface, opts ...Option) (*Client, error)

NewDefaultClient returns a Taker that surveys CronJob, DaemonSet, Deployment, Job, and StatefulSet resources from clientset.

func (*Client) SurveyDeployedImages

func (c *Client) SurveyDeployedImages(ctx context.Context) ([]string, error)

SurveyDeployedImages returns the image references of the containers and init containers of the PodSpecs surveyed by t.

type Option

type Option func(c *Client)

An Option is an option applied when creating a Client.

func WithLister

func WithLister(lister PodSpecLister) Option

WithLister adds a PodSpecLister for a Client to survey.

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger sets a logger for a Client to output to.

func WithPageSize

func WithPageSize(size uint) Option

WithPageSize sets the maximum number of responses a Client should request in a single Kubernetes API call.

func WithStatsdClient

func WithStatsdClient(client statsd.ClientInterface) Option

WithStatsdClient sets a statsd client to use to report metrics from a Client.

type PodSpecLister

type PodSpecLister interface {
	// List returns the result of a List method on the clientset for the
	// resource kind associated with the PodSpecLister.
	List(ctx context.Context, clientset kubernetes.Interface) (runtime.Object, error)
	// GetPodSpec returns the PodSpec associated with obj, which will be of
	// the same type as the elements of the list returned by the List
	// method.
	GetPodSpec(ctx context.Context, obj runtime.Object) (v1.PodSpec, error)
}

PodSpecLister is implemented for resource kinds which contain a PodSpec and can be listed via the Kubernetes API.

var CronJobLister PodSpecLister = &cronJobLister{}

CronJobLister lists the PodSpecs of all CronJobs in a Kubernetes cluster.

var DaemonSetLister PodSpecLister = &daemonSetLister{}

DaemonSetLister lists the PodSpecs of all DaemonSets in a Kubernetes cluster.

var DeploymentLister PodSpecLister = &deploymentLister{}

DeploymentLister lists the PodSpecs of all Deployments in a Kubernetes cluster.

var JobLister PodSpecLister = &jobLister{}

JobLister lists the PodSpecs of all Jobs in a Kubernetes cluster.

var StatefulSetLister PodSpecLister = &statefulSetLister{}

StatefulSetLister lists the PodSpecs of all StatefulSets in a Kubernetes cluster.

type Taker

type Taker interface {
	SurveyDeployedImages(ctx context.Context) (deployed []string, err error)
}

A Taker surveys container image names in a Kubernetes cluster.

Jump to

Keyboard shortcuts

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