cluster

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DaemonSet is the related owner key for that type of k8s entity.
	DaemonSet = "DaemonSet"
	// ReplicaSet is the related owner key for that type of k8s entity.
	ReplicaSet = "ReplicaSet"
	// StatefulSet is the related owner key for that type of k8s entity.
	StatefulSet = "StatefulSet"
)
View Source
const (
	// DaemonSetName is the resource name for the envchecker daemon set.
	DaemonSetName = "envchecker"
	// ManagedBy is the resource managed by identifier.
	ManagedBy = "envcheckctl"
	// PingerName is the resource name for the pinger daemon set.
	PingerName = "pinger"
)
View Source
const (
	// LabelManagedBy is the string for the k8s default managed-by key.
	LabelManagedBy = "app.kubernetes.io/managed-by"
	// LabelName is the string for the k8s default name key.
	LabelName = "app.kubernetes.io/name"
	// LabelVersion is the string for the k8s default version key.
	LabelVersion = "app.kubernetes.io/version"
)

Variables

View Source
var (
	// ErrLeaderUndefined is returned when the instana endpoint exists but no leader annotation exists.
	ErrLeaderUndefined = fmt.Errorf("endpoint found but leader undefined")
	// ErrInvalidLeaseFormat is returned when the leader annotation does not contain a valid LeaderLease.
	ErrInvalidLeaseFormat = fmt.Errorf("invalid lease format")
)

Functions

func Daemon added in v0.0.4

func Daemon(config DaemonConfig) *appsv1.DaemonSet

Daemon creates the envchecker daemon set resource from the provided DaemonConfig.

func FieldPath added in v0.0.4

func FieldPath(name, path string) v1.EnvVar

FieldPath returns a single env var based on the given field name and path.

func IsCNIPlugin added in v0.0.13

func IsCNIPlugin(n string) bool

func IsInstanaAgent added in v0.0.13

func IsInstanaAgent(pod PodInfo) bool

func PingHost added in v0.0.6

func PingHost(host string, useGateway bool) v1.EnvVar

PingHost outputs the "PINGHOST" env var key value based on host and useGateway.

func Pinger added in v0.0.4

func Pinger(config PingerConfig) *appsv1.DaemonSet

Pinger creates the pinger DaemonSet resource from the provided PingerConfig.

func ResourceRequirements added in v0.0.4

func ResourceRequirements(resources Resources) v1.ResourceRequirements

ResourceRequirements builds a kubernetes resource requirements from the provided Resources.

func Service added in v0.0.12

func Service(config DaemonConfig) *v1.Service

Types

type AgentEvent added in v0.0.9

type AgentEvent struct {
	EventTime time.Time
	Reason    string
	Message   string
}

AgentEvent represents a single K8S event associated with the agent.

type AgentInfo added in v0.0.9

type AgentInfo struct {
	Available    int32
	Desired      int32
	EventList    []AgentEvent
	Misscheduled int32
	Ready        int32
	Unavailable  int32
}

AgentInfo provides general information relating to the agent.

type Applyable added in v0.0.13

type Applyable interface {
	EachPod(PodInfo)
	EachNode(NodeInfo)
}

Applyable is the interface to receive pod info from a pod collection.

type Command added in v0.0.4

type Command interface {
	CreateDaemon(DaemonConfig) error
	CreatePinger(PingerConfig) error
	CreateService(DaemonConfig) error
}

Command provides an interface for creating envcheck entities in a cluster.

type ContainerInfo

type ContainerInfo struct {
	Name  string
	Image string
}

ContainerInfo is summary details for a container.

type Counter added in v0.0.13

type Counter map[string]int

func (Counter) Add added in v0.0.13

func (c Counter) Add(item string)

func (Counter) Len added in v0.0.13

func (c Counter) Len() int

func (Counter) Set added in v0.0.13

func (c Counter) Set(item string, value int)

type DaemonConfig added in v0.0.4

type DaemonConfig struct {
	Namespace string
	Image     string
	Version   string
	Host      string
	Port      int32
}

DaemonConfig is the configuration for the envchecker daemon set.

func (*DaemonConfig) Address added in v0.0.4

func (dc *DaemonConfig) Address() string

Address provides the combined host and port pair as an address.

type Index

type Index struct {
	Containers        Set
	DaemonSets        Set
	Deployments       Set
	Namespaces        Set
	Nodes             Set
	Pods              Set
	Running           Set
	StatefulSets      Set
	AgentRestarts     Counter
	AgentStatus       Counter
	ChartVersions     Counter
	CNIPlugins        Counter
	ContainerRuntimes Counter
	InstanceTypes     Counter
	KernelVersions    Counter
	KubeletVersions   Counter
	LinkedConfigMaps  Counter
	OSImages          Counter
	ProxyVersions     Counter
	Zones             Counter
	PodStatus         Counter
	Owners            Counter
}

Index provides indexes for a number of the cluster entities.

func NewIndex added in v0.0.4

func NewIndex() *Index

NewIndex builds a new empty index for PodInfo.

func (*Index) EachNode added in v0.0.13

func (index *Index) EachNode(node NodeInfo)

func (*Index) EachPod added in v0.0.13

func (index *Index) EachPod(pod PodInfo)

EachPod extracts the relevant pod details and integrates it into the index.

func (*Index) Summary

func (index *Index) Summary() Summary

Summary provides a summary pods for all the entities.

type Info

type Info struct {
	Name          string
	NodeCount     int
	Nodes         []NodeInfo
	PodCount      int
	Pods          []PodInfo
	ServerVersion string
	Version       string
	Started       time.Time
	Finished      time.Time
}

Info is a data structure for relevant cluster data.

func (*Info) Apply

func (info *Info) Apply(applyable ...Applyable)

Apply iterates over each pod and yields it to the list of applyables.

type KubernetesCommand added in v0.0.4

type KubernetesCommand struct {
	appsv1.AppsV1Interface
	corev1.CoreV1Interface
}

KubernetesCommand is a k8s implementation of the Command interface.

func NewCommand added in v0.0.4

func NewCommand(kubeconfig string) (*KubernetesCommand, error)

NewCommand allocates and returns a new Command.

func (*KubernetesCommand) CreateDaemon added in v0.0.4

func (kc *KubernetesCommand) CreateDaemon(config DaemonConfig) error

CreateDaemon creates an envchecker daemonset in the current K8S environment.

func (*KubernetesCommand) CreatePinger added in v0.0.4

func (kc *KubernetesCommand) CreatePinger(config PingerConfig) error

CreatePinger creates a pinger daemonset in the current K8S environment.

func (*KubernetesCommand) CreateService added in v0.0.4

func (kc *KubernetesCommand) CreateService(config DaemonConfig) error

CreateService creates an envchecker service in the current K8S environment.

type KubernetesQuery added in v0.0.3

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

KubernetesQuery is a concrete Kubernetes client to query various cluster info.

func New

func New(kubeconfig string) (*KubernetesQuery, error)

New builds a new KubernetesQuery implementation with the given kubeconfig.

func NewQuery added in v0.0.4

func NewQuery(h string, cs typev1.CoreV1Interface, apps appv1.AppsV1Interface, version func() (*version.Info, error)) *KubernetesQuery

NewQuery allocates and returns a new Query.

func (*KubernetesQuery) AgentInfo added in v0.0.9

func (q *KubernetesQuery) AgentInfo(namespace string, name string) (*AgentInfo, error)

AgentInfo queries the api-server for details about the Instana agent.

func (*KubernetesQuery) AllNodes added in v0.0.13

func (q *KubernetesQuery) AllNodes() ([]NodeInfo, error)

func (*KubernetesQuery) AllPods added in v0.0.3

func (q *KubernetesQuery) AllPods() ([]PodInfo, error)

AllPods retrieves all pod info from the cluster.

func (*KubernetesQuery) Host added in v0.0.3

func (q *KubernetesQuery) Host() string

Host provides the host info for the cluster.

func (*KubernetesQuery) InstanaLeader added in v0.0.8

func (q *KubernetesQuery) InstanaLeader() (string, error)

InstanaLeader returns the instana agent leader pod name.

func (*KubernetesQuery) ServerVersion added in v0.0.16

func (q *KubernetesQuery) ServerVersion() (string, error)

func (*KubernetesQuery) Time added in v0.0.8

func (q *KubernetesQuery) Time() time.Time

Time returns the current time.

type LeaderLease added in v0.0.8

type LeaderLease struct {
	HolderIdentity string `json:"holderIdentity"`
}

LeaderLease is the lease struct for the leader elector sidecar.

type LinkedConfigMap added in v0.0.13

type LinkedConfigMap struct {
	Name      string
	Namespace string
}

type NodeInfo added in v0.0.13

type NodeInfo struct {
	ContainerRuntime string
	InstanceType     string
	KernelVersion    string
	KubeletVersion   string
	Name             string
	OSImage          string
	ProxyVersion     string
	Zone             string
}

type PingerConfig added in v0.0.4

type PingerConfig struct {
	Namespace  string
	Image      string
	Version    string
	Host       string
	Port       int32
	UseGateway bool
}

PingerConfig is the input configuration for the pinger DaemonSet.

type PodInfo

type PodInfo struct {
	Annotations      map[string]string `json:",omitempty"`
	ChartVersion     string
	Containers       []ContainerInfo
	LinkedConfigMaps []LinkedConfigMap
	Host             string
	IsRunning        bool
	Name             string
	Namespace        string
	Owners           map[string]string
	Restarts         int
	Status           string
}

PodInfo is summary details for a pod.

type Query added in v0.0.3

type Query interface {
	// AllPods returns the list of pods from the related cluster.
	AllPods() ([]PodInfo, error)
	AllNodes() ([]NodeInfo, error)
	Host() string
	InstanaLeader() (string, error)
	ServerVersion() (string, error)
	Time() time.Time
}

Query is a query interface for the cluster.

type Resources added in v0.0.4

type Resources struct {
	RequestCPU    string
	RequestMemory string
	LimitCPU      string
	LimitMemory   string
}

Resources is the system resource contraints associated with an entity.

type Set

type Set map[string]bool

Set provides a set collection for strings.

func (Set) Add

func (s Set) Add(item string)

Add integrates the item into the underlying set.

func (Set) Len

func (s Set) Len() int

Len lists the number of items in the set.

type Summary

type Summary struct {
	Containers   int
	DaemonSets   int
	Deployments  int
	Namespaces   int
	Nodes        int
	Pods         int
	Running      int
	StatefulSets int
}

Summary provides a summary overview of the number of entities in the cluster.

Jump to

Keyboard shortcuts

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