meshdetect

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 13 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

	// Pod is the pod in which the mesh detector is running.
	Pod apitypes.NamespacedName

	// PublishServiceName is the Kubernetes service used for ingress traffic
	// to the Kong Gateway.
	PublishService apitypes.NamespacedName
}

Detector provides methods to detect the following:

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

func NewDetectorByConfig

func NewDetectorByConfig(
	client client.Client,
	pod apitypes.NamespacedName,
	publishService apitypes.NamespacedName,
) (*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) meshDeploymentResults

DetectMeshDeployment detects which kinds of mesh networks are deployed.

func (*Detector) DetectRunUnder

func (d *Detector) DetectRunUnder(ctx context.Context) (meshRunUnderResults, error)

DetectRunUnder detects whether the 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 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 pod 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.

func (*ServiceDistributionResults) ToProviderReport

func (s *ServiceDistributionResults) ToProviderReport() types.ProviderReport

Jump to

Keyboard shortcuts

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