meshdetect

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

MeshesToDetect is the list of meshes to detect.

Functions

This section is empty.

Types

type DeploymentResults

type DeploymentResults struct {
	ServiceExists bool `json:"serviceExists"`
}

DeploymentResults is the result of detecting signals of whether a certain mesh is deployed in kubernetes cluster.

type Detector

type Detector struct {
	// Client is the kubernetes client to read kubernetes services.
	Client client.Client

	// PodNamespace is the namespace of the pod in which the mesh detector is running.
	PodNamespace string

	// PodName is the name of pod  in which the mesh detector is running.
	PodName string

	// PublishServiceName is the name of the Kubernetes service used for
	// ingress traffic to the Kong Gateway.
	PublishServiceName string

	Logger logr.Logger
}

Detector provides methods to detect the following:

  • whether a service mesh is deployed to the cluster
  • whether KIC is injected with service mesh
  • count of services injected within mesh networks

func NewDetectorByConfig

func NewDetectorByConfig(kubeCfg *rest.Config,
	podNamespace, podName, publishServiceName string,
	logger logr.Logger,
) (*Detector, error)

NewDetectorByConfig creates a new Detector provided a Kubernetes config for the relevant cluster and the name of the Kubernetes service for ingress traffic to the Kong Gateway.

func (*Detector) DetectMeshDeployment

func (d *Detector) DetectMeshDeployment(ctx context.Context) map[MeshKind]*DeploymentResults

DetectMeshDeployment detects which kinds of mesh networks are deployed.

func (*Detector) DetectRunUnder

func (d *Detector) DetectRunUnder(ctx context.Context) map[MeshKind]*RunUnderResults

DetectRunUnder detects whether KIC pod is running under each kind of service mesh. in this function, we want to detect whether the pod running this detector, which is also the KIC pod, is running under a certain kind of service mesh. for example, if the pod is injected with istio sidecar container and init container, we report that the detector is running under istio mesh.

func (*Detector) DetectServiceDistribution

func (d *Detector) DetectServiceDistribution(ctx context.Context) (*ServiceDistributionResults, error)

DetectServiceDistribution detects how many services are running under each mesh.

type MeshKind

type MeshKind string

MeshKind defines names of different service meshes.

const (
	MeshKindIstio      MeshKind = "istio"
	MeshKindLinkerd    MeshKind = "linkerd"
	MeshKindKuma       MeshKind = "kuma"
	MeshKindKongMesh   MeshKind = "kong-mesh"
	MeshKindConsul     MeshKind = "consul"
	MeshKindTraefik    MeshKind = "traefik"
	MeshKindAWSAppMesh MeshKind = "aws-app-mesh"
)

type RunUnderResults

type RunUnderResults struct {
	PodOrServiceAnnotation   bool `json:"podOrServiceAnnotation"`
	SidecarContainerInjected bool `json:"sidecarContainerInjected"`
	InitContainerInjected    bool `json:"initContainerInjected"`
}

RunUnderResults is the result of detecting signals of whether KIC is running under a certain service mesh.

type ServiceDistributionResults

type ServiceDistributionResults struct {
	TotalServices int `json:"totalServices"`
	// MeshDistribution is the number of services running under each kind of mesh.
	// We decided to directly use number here instead of ratio in total services in a
	// floating number because using floating number needs extra work on calculating
	// and serializing.
	MeshDistribution map[MeshKind]int `json:"meshDistribution"`
}

ServiceDistributionResults contains number of total services and number of services running under each mesh.

Jump to

Keyboard shortcuts

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