inject

package
v1.6.1-0...-2e04536 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package inject contains code for sidecar injection.

Index

Constants

View Source
const (
	RedirectPath = "/health-redirects/"
)

Variables

This section is empty.

Functions

func IntoFile

func IntoFile(
	injectConfig Inject,
	meshConfig mesh.FullMeshConfig,
) (string, error)

IntoFile takes a yaml or json resource file and adds the sidecar containers.

func IsNamespaceInjectable

func IsNamespaceInjectable(ctx context.Context, k8sClient client.Client, namespace string) (bool, error)

IsNamespaceInjectable determines if namespace is injectable.

func ValidateMTLSAnnotation

func ValidateMTLSAnnotation(podAnnotation, globalMode string) error

Types

type IgnorePorts

type IgnorePorts struct {
	Incoming []int
	Outgoing []int
}

IgnorePorts holds the list of ports to ignore for both incoming and outgoing traffic.

func GetIgnorePorts

func GetIgnorePorts(annotations map[string]string, ports IgnorePorts) (IgnorePorts, error)

GetIgnorePorts returns the ignored ports whether specified via arg or annotation.

func GetIgnorePortsFromAnnotations

func GetIgnorePortsFromAnnotations(annotations map[string]string) (IgnorePorts, error)

GetIgnorePortsFromAnnotations returns the ignored ports that are set in the Pod annotations.

func (IgnorePorts) IsEmpty

func (ip IgnorePorts) IsEmpty() bool

IsEmpty reports whether or not IgnorePorts struct is empty.

func (IgnorePorts) Validate

func (ip IgnorePorts) Validate() error

Validate returns an error if the ports are not valid.

type Inject

type Inject struct {
	Resources   []byte
	IgnorePorts IgnorePorts
}

Inject holds the config for a manual sidecar injection.

type InjectionConfig

type InjectionConfig struct {
	Annotations      map[string]string
	RegistryKey      *v1.Secret
	Labels           map[string]string
	Volumes          []v1.Volume
	ImagePullSecrets []v1.LocalObjectReference
	Probes           []Probe
	InitContainers   []v1.Container
	Containers       []v1.Container
}

InjectionConfig is the proxy sidecar configuration to be injected.

func CreateInjectionConfig

func CreateInjectionConfig(
	meshConfig mesh.FullMeshConfig,
	ignorePorts IgnorePorts,
	containers []v1.Container,
	parentName,
	parentNamespace,
	parentType string,
	podAnnotations map[string]string,
) (*InjectionConfig, error)

CreateInjectionConfig builds the config for injecting the sidecar proxy.

type PortSet

type PortSet map[string]struct{}

func ValidatePorts

func ValidatePorts(containers []v1.Container) (PortSet, error)

ValidatePorts parses and formats ports returns an error if port protocol is not supported or if port is a duplicate.

type Probe

type Probe struct {
	ProbeType    string
	HTTPGet      v1.HTTPGetAction
	OrigHTTPGet  v1.HTTPGetAction
	ContainerIdx int
}

func GetProbes

func GetProbes(containers []v1.Container, httpPort, httpsPort int) []Probe

GetProbes builds and returns the redirected health probes for an application with a sidecar.

Jump to

Keyboard shortcuts

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