Documentation
¶
Overview ¶
Kubernetes workloads in discovery: the EKS clusters of an account and region, and a target group traced to the one Deployment or StatefulSet behind it.
Ports manager packages/discovery/src/kubernetes.ts (clustersOf, kubernetesBackend).
Package kubernetes is the Kubernetes API of an EKS cluster, without a Kubernetes library: plain HTTPS trusting the cluster's certificate authority, with an EKS token signed here by hand.
Token ports the router's lambda/src/lib/k8s.mjs (presignUrl, eksToken).
Index ¶
- Constants
- Variables
- func LabelSelector(s Selector) (string, error)
- func OwnerPath(ref Ref) string
- func Token(cluster, region string, creds aws.Credentials, now time.Time) string
- type AccessConfig
- type Autoscaler
- type Candidate
- type CertificateAuthority
- type Client
- type Cluster
- type ClusterView
- type Condition
- type Container
- type DescribeClusterInput
- type DescribeClusterOutput
- type EKSCluster
- type EKSPort
- type Error
- type Expression
- type Group
- type Ingress
- type K8sBackend
- type Label
- type Labels
- type ListClustersInput
- type ListClustersOutput
- type Metadata
- type Owner
- type OwnerReference
- type Pod
- type Port
- type Ports
- type Ref
- type Result
- type Selector
- type Service
- type Timeouts
- type VPCConfig
- type Workload
Constants ¶
const ClusterTTL = 15 * time.Minute
ClusterTTL is how long a cluster's view is kept (15 minutes).
Variables ¶
DefaultTimeouts are the AWS calls' bounds (the router's TIMEOUTS): 3 seconds to connect, 10 seconds idle.
Functions ¶
func LabelSelector ¶
LabelSelector writes an owner's selector as the API's labelSelector parameter takes it.
Types ¶
type AccessConfig ¶
type AccessConfig struct {
AuthenticationMode string `json:"authenticationMode,omitempty"`
}
AccessConfig is the cluster's authentication mode.
type Autoscaler ¶
type Autoscaler string
Autoscaler is the node autoscaler of a cluster: karpenter, cluster-autoscaler or none (empty, null in JSON).
func (Autoscaler) MarshalJSON ¶
func (a Autoscaler) MarshalJSON() ([]byte, error)
MarshalJSON writes none as null.
func (*Autoscaler) UnmarshalJSON ¶
func (a *Autoscaler) UnmarshalJSON(b []byte) error
UnmarshalJSON reads null as none.
type Candidate ¶
type Candidate struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Owner Owner `json:"owner"`
Switch string `json:"switch"`
Ingress *Ingress `json:"ingress,omitempty"`
GitOps string `json:"gitops,omitempty"`
HPA bool `json:"hpa"`
Keda *bool `json:"keda"`
Capacity string `json:"capacity"`
Autoscaler Autoscaler `json:"autoscaler"`
}
Candidate is the Kubernetes workload behind a target group, with how the waker is switched in. Switch is rule, ingress or patched-ingress; GitOps argocd or flux (empty: none); Keda nil when the cluster refuses to show its ScaledObjects; Capacity fargate or nodes.
type CertificateAuthority ¶
type CertificateAuthority struct {
Data string `json:"data,omitempty"`
}
CertificateAuthority holds the cluster's CA, PEM in base64.
type Client ¶
type Client interface {
// Get returns the object at path (nil for an empty answer).
Get(ctx context.Context, path string) (json.RawMessage, error)
// List returns every item at path, following the API's continue tokens.
List(ctx context.Context, path string, query map[string]string) ([]json.RawMessage, error)
}
Client reads one cluster's API (GET only).
type Cluster ¶
type Cluster struct {
Name string
VPCID string
Reason string // empty when read
Client Client
Pods []Pod
Autoscaler Autoscaler
// contains filtered or unexported fields
}
Cluster is a cluster of the region with what discovery can read of it: its pods (by IP) and whether a node autoscaler runs. A cluster it cannot reach or read keeps the Reason (its target groups are ineligible with it, the account goes on).
func ClustersOf ¶
ClustersOf reads every cluster of the region.
func (Cluster) MarshalJSON ¶
MarshalJSON writes the cluster as the scan reports it: its name and its reason (null when read).
type ClusterView ¶
type ClusterView struct {
Endpoint string
CA []byte // PEM, decoded
PublicAccess bool
PublicCidrs []string
PrivateOnly bool
AuthMode string // CONFIG_MAP for a cluster without accessConfig
Version string
}
ClusterView is a cluster's endpoint, certificate authority, reach and authentication mode (the router's clusterOf).
type Container ¶
type Container struct {
Resources struct {
Requests map[string]string `json:"requests,omitempty"`
} `json:"resources"`
}
Container is a pod's container (its requests only).
type DescribeClusterInput ¶
type DescribeClusterInput struct {
Name string `json:"name"`
}
DescribeClusterInput is EKS DescribeCluster's input.
type DescribeClusterOutput ¶
type DescribeClusterOutput struct {
Cluster *EKSCluster `json:"cluster,omitempty"`
}
DescribeClusterOutput is its answer.
type EKSCluster ¶
type EKSCluster struct {
Name string `json:"name,omitempty"`
Version string `json:"version,omitempty"`
Endpoint string `json:"endpoint,omitempty"`
CertificateAuthority *CertificateAuthority `json:"certificateAuthority,omitempty"`
ResourcesVpcConfig *VPCConfig `json:"resourcesVpcConfig,omitempty"`
AccessConfig *AccessConfig `json:"accessConfig,omitempty"`
}
EKSCluster is the part of an EKS cluster the estimate reads.
type EKSPort ¶
type EKSPort interface {
ListClusters(ctx context.Context, in ListClustersInput) (ListClustersOutput, error)
DescribeCluster(ctx context.Context, in DescribeClusterInput) (DescribeClusterOutput, error)
}
EKSPort is the EKS API (ListClusters, DescribeCluster).
type Error ¶
Error is a failed Kubernetes call. Status is the HTTP status, 0 when no answer came; Reason the API's (Forbidden, NotFound, Conflict...), the HTTP status's text, Timeout, or the network error's code.
type Expression ¶
type Expression struct {
Key string `json:"key"`
Operator string `json:"operator"`
Values []string `json:"values,omitempty"`
}
Expression is a selector's matchExpressions entry.
type Group ¶
type Group struct {
ARN string `json:"arn"`
Type string `json:"type,omitempty"`
VPCID string `json:"vpcId,omitempty"`
Tags map[string]string `json:"tags"`
Targets []string `json:"targets"`
}
Group is a target group to trace.
type Ingress ¶
type Ingress struct {
Name string `json:"name"`
RuleIndex int `json:"ruleIndex"`
GroupOrder *int `json:"groupOrder,omitempty"`
Service Service `json:"service"`
}
Ingress is the Ingress rule the target group was made for.
type K8sBackend ¶
type K8sBackend struct {
Kind string `json:"kind"`
ID string `json:"id"`
Kubernetes Candidate `json:"kubernetes"`
}
K8sBackend is the backend discovery reports for a Kubernetes workload.
type Labels ¶
type Labels []Label
Labels are a selector's matchLabels, in the order the API wrote them (the label selector keeps it).
func (Labels) MarshalJSON ¶
MarshalJSON writes the object back.
func (*Labels) UnmarshalJSON ¶
UnmarshalJSON reads an object keeping its keys' order.
type ListClustersInput ¶
type ListClustersInput struct {
NextToken string `json:"nextToken,omitempty"`
}
ListClustersInput is EKS ListClusters' input (a page).
type ListClustersOutput ¶
type ListClustersOutput struct {
Clusters []string `json:"clusters,omitempty"`
NextToken string `json:"nextToken,omitempty"`
}
ListClustersOutput is its answer.
type Metadata ¶
type Metadata struct {
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty"`
DeletionTimestamp string `json:"deletionTimestamp,omitempty"`
}
Metadata is an object's metadata.
func (Metadata) Controller ¶
func (m Metadata) Controller() (OwnerReference, bool)
Controller is the reference that controls the object, if any.
type Owner ¶
Owner is a Deployment or a StatefulSet.
func ServiceOwner ¶ added in v0.8.0
func ServiceOwner(ctx context.Context, k Client, namespace, service string) (owner *Owner, reason string, err error)
ServiceOwner traces a Service to the one Deployment or StatefulSet behind it: its selector, the pods it selects, then their owner. reason says why it cannot be told, with no owner; err is a refused or failed call.
type OwnerReference ¶
type OwnerReference struct {
Kind string `json:"kind"`
Name string `json:"name"`
Controller bool `json:"controller,omitempty"`
}
OwnerReference is a metadata.ownerReferences entry.
type Pod ¶
type Pod struct {
Metadata Metadata `json:"metadata"`
Spec struct {
NodeName string `json:"nodeName,omitempty"`
SchedulerName string `json:"schedulerName,omitempty"`
Containers []Container `json:"containers,omitempty"`
InitContainers []Container `json:"initContainers,omitempty"`
Overhead map[string]string `json:"overhead,omitempty"`
} `json:"spec"`
Status struct {
Phase string `json:"phase,omitempty"`
PodIP string `json:"podIP,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
} `json:"status"`
}
Pod is a pod with the fields the estimate reads.
type Ports ¶
type Ports struct {
EKS EKSPort
Of func(ctx context.Context, cluster string) (Client, error)
Reader string
Account string
Region string
}
Ports are what discovery reads clusters through. Of gives the client of a cluster by name (for real: its endpoint and certificate authority from DescribeCluster, an EKS token). Reader names who reads the clusters, in the reason of one refused (DmtDiscoveryRole when empty). Account and Region name the router to install, in the reason of a private cluster.
type Result ¶
type Result struct {
Backend *K8sBackend
Reason string
}
Result is the answer of Backend: the owner (Backend), why the target group cannot be napped (Reason), or neither when it is not a Kubernetes target group. It marshals to the Node value: the backend, the reason or null.
func Backend ¶
Backend finds the target group's Kubernetes owner, why it cannot be napped, or neither when it is not a Kubernetes target group (no cluster's tag, and no target among a reachable cluster's pods).
func (Result) MarshalJSON ¶
MarshalJSON writes the backend, the reason, or null.
type Selector ¶
type Selector struct {
MatchLabels Labels `json:"matchLabels,omitempty"`
MatchExpressions []Expression `json:"matchExpressions,omitempty"`
}
Selector is a label selector (matchLabels and matchExpressions).
type Timeouts ¶
Timeouts are the calls' bounds: connected (TLS included) within Connect, failed after Idle of silence (no byte read).
type VPCConfig ¶
type VPCConfig struct {
VPCID string `json:"vpcId,omitempty"`
EndpointPublicAccess bool `json:"endpointPublicAccess,omitempty"`
EndpointPrivateAccess bool `json:"endpointPrivateAccess,omitempty"`
PublicAccessCidrs []string `json:"publicAccessCidrs,omitempty"`
}
VPCConfig is the cluster's VPC and endpoint access.
type Workload ¶
type Workload struct {
Kind string `json:"kind,omitempty"`
Metadata Metadata `json:"metadata"`
Spec struct {
Replicas *int `json:"replicas,omitempty"`
Selector *Selector `json:"selector,omitempty"`
} `json:"spec"`
}
Workload is a Deployment or a StatefulSet (or a ReplicaSet: its metadata).
func GetWorkload ¶
GetWorkload reads the owner; a missing one is the API's 404.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package kubernetestest holds the fakes of the Kubernetes ports for tests: the recorded answers of the shared cases, as the ports of internal/kubernetes.
|
Package kubernetestest holds the fakes of the Kubernetes ports for tests: the recorded answers of the shared cases, as the ports of internal/kubernetes. |