Skip to content

Commit

Permalink
Fix injection check for existing sidecars
Browse files Browse the repository at this point in the history
  • Loading branch information
alpeb committed Apr 23, 2024
1 parent 44e9625 commit a8ebe76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/healthcheck/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
// HasExistingSidecars returns true if the pod spec already has the proxy init
// and sidecar containers injected. Otherwise, it returns false.
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:") ||
strings.HasPrefix(container.Image, "gcr.io/istio-release/proxyv2:") ||
container.Name == k8s.ProxyContainerName ||
Expand Down
10 changes: 10 additions & 0 deletions pkg/healthcheck/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ func TestHasExistingSidecars(t *testing.T) {
},
expected: true,
},
{
podSpec: &corev1.PodSpec{
InitContainers: []corev1.Container{
{
Name: k8s.ProxyContainerName,
},
},
},
expected: true,
},
{
podSpec: &corev1.PodSpec{
Containers: []corev1.Container{
Expand Down

0 comments on commit a8ebe76

Please sign in to comment.