sidecarcontrol

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SidecarSetHashAnnotation represents the key of a sidecarSet hash
	SidecarSetHashAnnotation = "kruise.io/sidecarset-hash"
	// SidecarSetHashWithoutImageAnnotation represents the key of a sidecarset hash without images of sidecar
	SidecarSetHashWithoutImageAnnotation = "kruise.io/sidecarset-hash-without-image"

	// SidecarSetListAnnotation represent sidecarset list that injected pods
	SidecarSetListAnnotation = "kruise.io/sidecarset-injected-list"

	// SidecarEnvKey specifies the environment variable which record a container as injected
	SidecarEnvKey = "IS_INJECTED"

	// SidecarsetInplaceUpdateStateKey records the state of inplace-update.
	// The value of annotation is SidecarsetInplaceUpdateStateKey.
	SidecarsetInplaceUpdateStateKey string = "kruise.io/sidecarset-inplace-update-state"
)

Variables

View Source
var (
	// SidecarIgnoredNamespaces specifies the namespaces where Pods won't get injected
	SidecarIgnoredNamespaces = []string{"kube-system", "kube-public"}
	// SubPathExprEnvReg format: $(ODD_NAME)、$(POD_NAME)...
	SubPathExprEnvReg, _ = regexp.Compile(`\$\(([-._a-zA-Z][-._a-zA-Z0-9]*)\)`)
)

Functions

func GetInjectedVolumeMountsAndEnvs

func GetInjectedVolumeMountsAndEnvs(control SidecarControl, sidecarContainer *appsv1alpha1.SidecarContainer, pod *corev1.Pod) ([]corev1.VolumeMount, []corev1.EnvVar)

func GetPodSidecarSetRevision

func GetPodSidecarSetRevision(sidecarSetName string, pod metav1.Object) string

func GetPodSidecarSetWithoutImageRevision

func GetPodSidecarSetWithoutImageRevision(sidecarSetName string, pod metav1.Object) string

func GetPodsSortFunc

func GetPodsSortFunc(pods []*corev1.Pod, waitUpdateIndexes []int) func(i, j int) bool

func GetSidecarContainersInPod

func GetSidecarContainersInPod(sidecarSet *appsv1alpha1.SidecarSet) sets.String

func GetSidecarSetRevision

func GetSidecarSetRevision(sidecarSet *appsv1alpha1.SidecarSet) string

func GetSidecarSetWithoutImageRevision

func GetSidecarSetWithoutImageRevision(sidecarSet *appsv1alpha1.SidecarSet) string

func GetSidecarTransferEnvs

func GetSidecarTransferEnvs(sidecarContainer *appsv1alpha1.SidecarContainer, pod *corev1.Pod) (injectedEnvs []corev1.EnvVar)

func IsActivePod

func IsActivePod(pod *corev1.Pod) bool

IsActivePod determines the pod whether need be injected and updated

func IsInjectedSidecarContainerInPod

func IsInjectedSidecarContainerInPod(container *corev1.Container) bool

func IsPodSidecarUpdated

func IsPodSidecarUpdated(sidecarSet *appsv1alpha1.SidecarSet, pod *corev1.Pod) bool

whether this pod has been updated based on the latest sidecarSet

func IsSharePodVolumeMounts

func IsSharePodVolumeMounts(container *appsv1alpha1.SidecarContainer) bool

func PodMatchedSidecarSet

func PodMatchedSidecarSet(pod *corev1.Pod, sidecarSet appsv1alpha1.SidecarSet) (bool, error)

PodMatchSidecarSet determines if pod match Selector of sidecar.

Types

type SidecarControl

type SidecarControl interface {
	//common
	// get sidecarset
	GetSidecarset() *appsv1alpha1.SidecarSet

	// inject
	// whether need inject the volumeMount into container
	IsNeedInjectVolumeMount(volumeMount v1.VolumeMount) bool
	// when update pod, judge whether inject sidecar container into pod
	NeedInjectOnUpdatedPod(pod, oldPod *v1.Pod, sidecarContainer *appsv1alpha1.SidecarContainer, injectedEnvs []v1.EnvVar,
		injectedMounts []v1.VolumeMount) (needInject bool, existSidecars []*appsv1alpha1.SidecarContainer, existVolumes []v1.Volume)

	// update
	// pod whether consistent and ready
	IsPodConsistentAndReady(pod *v1.Pod) bool
	// update pod sidecar container to sidecarSet latest version
	UpdateSidecarContainerToLatest(containerInSidecarSet, containerInPod v1.Container) v1.Container
	// update pod information in upgrade
	UpdatePodAnnotationsInUpgrade(changedContainers []string, pod *v1.Pod)
	// IsPodUpdatedConsistent indicates whether pod.spec and pod.status are consistent after updating the sidecar containers
	IsPodUpdatedConsistent(pod *v1.Pod, ignoreContainers sets.String) bool
	// Is sidecarset can upgrade pods
	IsSidecarSetCanUpgrade(pod *v1.Pod) bool
}

type SidecarSetUpgradeSpec

type SidecarSetUpgradeSpec struct {
	UpdateTimestamp metav1.Time `json:"updateTimestamp"`
	SidecarSetHash  string      `json:"hash"`
	SidecarSetName  string      `json:"sidecarSetName"`
}

Jump to

Keyboard shortcuts

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