Skip to content

Commit

Permalink
fix: take injected istio into consideration (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho authored Dec 25, 2023
1 parent ad5a734 commit 82c7214
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/deployment/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

autoscalingv1beta3 "github.com/mercari/tortoise/api/v1beta3"
"github.com/mercari/tortoise/pkg/annotation"
)

type Service struct {
Expand All @@ -28,10 +29,18 @@ func (c *Service) GetDeploymentOnTortoise(ctx context.Context, tortoise *autosca
return d, nil
}

func GetContainerNames(d *v1.Deployment) sets.Set[string] {
func GetContainerNames(dm *v1.Deployment) sets.Set[string] {
names := sets.New[string]()
for _, c := range d.Spec.Template.Spec.Containers {
for _, c := range dm.Spec.Template.Spec.Containers {
names.Insert(c.Name)
}
if dm.Spec.Template.Annotations != nil {
if v, ok := dm.Spec.Template.Annotations[annotation.IstioSidecarInjectionAnnotation]; ok && v == "true" {
// Istio sidecar injection is enabled.
// Because the istio container spec is not in the deployment spec, we need to get it from the deployment's annotation.
names.Insert(annotation.IstioSidecarInjectionAnnotation)
}
}

return names
}

0 comments on commit 82c7214

Please sign in to comment.