fix: service selector indexed name

This commit is contained in:
RouxAntoine 2023-10-05 01:31:06 +02:00
parent 1adb18e186
commit db693aab26
Signed by: antoine
GPG Key ID: 098FB66FC0475E70

View File

@ -135,12 +135,13 @@ func createResources(ctx *pulumi.Context, configuration *configuration, opts ...
var ingressesParameter []ingressConfiguration var ingressesParameter []ingressConfiguration
var deployments []*appsv1.Deployment var deployments []*appsv1.Deployment
for index, image := range configuration.Images { for index, image := range configuration.Images {
indexedName := fmt.Sprintf("%s-%d", configuration.Name, index)
appLabels := pulumi.StringMap{ appLabels := pulumi.StringMap{
"app.kubernetes.io/name": pulumi.String(configuration.Name), "app.kubernetes.io/name": pulumi.String(indexedName),
} }
deploymentParameter := &deploymentConfiguration{ deploymentParameter := &deploymentConfiguration{
Name: fmt.Sprintf("%s-%d", configuration.Name, index), Name: indexedName,
Env: configuration.Env, Env: configuration.Env,
Replicas: configuration.Replicas, Replicas: configuration.Replicas,
ImageReference: image, ImageReference: image,
@ -152,7 +153,7 @@ func createResources(ctx *pulumi.Context, configuration *configuration, opts ...
application.DeploymentName = deployment.Metadata.Name().Elem() application.DeploymentName = deployment.Metadata.Name().Elem()
serviceParameter := serviceConfiguration{ serviceParameter := serviceConfiguration{
Name: fmt.Sprintf("%s-%d", configuration.Name, index), Name: indexedName,
} }
service, err := createService(ctx, serviceParameter, namespace, appLabels, application) service, err := createService(ctx, serviceParameter, namespace, appLabels, application)
if err != nil { if err != nil {
@ -230,7 +231,7 @@ func createMiddlewareAddResponseHeader(
return nil, nil 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 { if configuration.ShouldCreateIngress {
host := pulumi.String(configuration.Dns) host := pulumi.String(configuration.Dns)
@ -249,7 +250,7 @@ func createIngress(ctx *pulumi.Context, configuration *configuration, namespace
} }
var ingressPaths netv1.HTTPIngressPathArray var ingressPaths netv1.HTTPIngressPathArray
for _, service := range servicesConfiguration { for _, service := range ingressConfiguration {
ingressPaths = append(ingressPaths, netv1.HTTPIngressPathArgs{ ingressPaths = append(ingressPaths, netv1.HTTPIngressPathArgs{
Path: pulumi.String(service.ImageReference.Path), Path: pulumi.String(service.ImageReference.Path),
PathType: pulumi.String("Prefix"), PathType: pulumi.String("Prefix"),