From db693aab2606d205503262933e393bdb04538c67 Mon Sep 17 00:00:00 2001 From: RouxAntoine Date: Thu, 5 Oct 2023 01:31:06 +0200 Subject: [PATCH] fix: service selector indexed name --- pkg/application/generic.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/application/generic.go b/pkg/application/generic.go index fcf91ff..af986d7 100644 --- a/pkg/application/generic.go +++ b/pkg/application/generic.go @@ -135,12 +135,13 @@ func createResources(ctx *pulumi.Context, configuration *configuration, opts ... var ingressesParameter []ingressConfiguration var deployments []*appsv1.Deployment for index, image := range configuration.Images { + indexedName := fmt.Sprintf("%s-%d", configuration.Name, index) appLabels := pulumi.StringMap{ - "app.kubernetes.io/name": pulumi.String(configuration.Name), + "app.kubernetes.io/name": pulumi.String(indexedName), } deploymentParameter := &deploymentConfiguration{ - Name: fmt.Sprintf("%s-%d", configuration.Name, index), + Name: indexedName, Env: configuration.Env, Replicas: configuration.Replicas, ImageReference: image, @@ -152,7 +153,7 @@ func createResources(ctx *pulumi.Context, configuration *configuration, opts ... application.DeploymentName = deployment.Metadata.Name().Elem() serviceParameter := serviceConfiguration{ - Name: fmt.Sprintf("%s-%d", configuration.Name, index), + Name: indexedName, } service, err := createService(ctx, serviceParameter, namespace, appLabels, application) if err != nil { @@ -230,7 +231,7 @@ func createMiddlewareAddResponseHeader( return nil, nil } -func createIngress(ctx *pulumi.Context, configuration *configuration, namespace *corev1.Namespace, certificate *v1.Certificate, servicesConfiguration []ingressConfiguration, application *Application, responseHeaderMiddleware *traefikv1alpha1.Middleware) (*netv1.Ingress, error) { +func createIngress(ctx *pulumi.Context, configuration *configuration, namespace *corev1.Namespace, certificate *v1.Certificate, ingressConfiguration []ingressConfiguration, application *Application, responseHeaderMiddleware *traefikv1alpha1.Middleware) (*netv1.Ingress, error) { if configuration.ShouldCreateIngress { host := pulumi.String(configuration.Dns) @@ -249,7 +250,7 @@ func createIngress(ctx *pulumi.Context, configuration *configuration, namespace } var ingressPaths netv1.HTTPIngressPathArray - for _, service := range servicesConfiguration { + for _, service := range ingressConfiguration { ingressPaths = append(ingressPaths, netv1.HTTPIngressPathArgs{ Path: pulumi.String(service.ImageReference.Path), PathType: pulumi.String("Prefix"),