Skip to content

Check sidecar not right #602

@hzxuzhonghu

Description

@hzxuzhonghu

Currently we check whether a pod has sidecar injected based on below function in bypass controller

func checkSidecar(client kubernetes.Interface, pod *corev1.Pod) (bool, error) {
	namespace, err := client.CoreV1().Namespaces().Get(context.TODO(), pod.Namespace, metav1.GetOptions{})
	if err != nil {
		return false, err
	}

	if value, ok := namespace.Labels["istio-injection"]; ok && value == "enabled" {
		return true, nil
	}

	if _, ok := pod.Annotations[SidecarAnnotation]; ok {
		return true, nil
	}

	return false, nil
}

Maybe it is also not right in cni, i havn't look into yet.

Because a namespace with istio-injection: enabled label doesnot mean a pod within it has a sidecar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions