mirror of https://github.com/linkerd/linkerd2.git
Fix injection check for existing sidecars
This commit is contained in:
parent
44e9625e0d
commit
a8ebe76e3f
|
@ -10,7 +10,8 @@ import (
|
||||||
// HasExistingSidecars returns true if the pod spec already has the proxy init
|
// HasExistingSidecars returns true if the pod spec already has the proxy init
|
||||||
// and sidecar containers injected. Otherwise, it returns false.
|
// and sidecar containers injected. Otherwise, it returns false.
|
||||||
func HasExistingSidecars(podSpec *corev1.PodSpec) bool {
|
func HasExistingSidecars(podSpec *corev1.PodSpec) bool {
|
||||||
for _, container := range podSpec.Containers {
|
containers := append(podSpec.InitContainers, podSpec.Containers...)
|
||||||
|
for _, container := range containers {
|
||||||
if strings.HasPrefix(container.Image, "cr.l5d.io/linkerd/proxy:") ||
|
if strings.HasPrefix(container.Image, "cr.l5d.io/linkerd/proxy:") ||
|
||||||
strings.HasPrefix(container.Image, "gcr.io/istio-release/proxyv2:") ||
|
strings.HasPrefix(container.Image, "gcr.io/istio-release/proxyv2:") ||
|
||||||
container.Name == k8s.ProxyContainerName ||
|
container.Name == k8s.ProxyContainerName ||
|
||||||
|
|
|
@ -44,6 +44,16 @@ func TestHasExistingSidecars(t *testing.T) {
|
||||||
},
|
},
|
||||||
expected: true,
|
expected: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
podSpec: &corev1.PodSpec{
|
||||||
|
InitContainers: []corev1.Container{
|
||||||
|
{
|
||||||
|
Name: k8s.ProxyContainerName,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
podSpec: &corev1.PodSpec{
|
podSpec: &corev1.PodSpec{
|
||||||
Containers: []corev1.Container{
|
Containers: []corev1.Container{
|
||||||
|
|
Loading…
Reference in New Issue