From c4b5f165dc5c21a1b36c4ef8b086667cbe2eddfc Mon Sep 17 00:00:00 2001 From: Tobi Nehrlich Date: Tue, 13 Aug 2024 23:43:42 +0200 Subject: [PATCH] fix: Use distinct container port names (#354) This introduces the port name "php" for the additional PHP container. Using the same port name twice can lead to situations where a service pointing to a named port would route the traffic to the wrong container. --- internal/servicetypes/nginx.go | 2 +- .../services/test-resources/deployment/result-nginx-1.yaml | 4 ++-- .../services/test-resources/deployment/result-nginx-2.yaml | 4 ++-- .../service-templates/service1/deployment-nginx-php.yaml | 2 +- .../service-templates/service2/deployment-nginx-php.yaml | 2 +- .../service-templates/service5/deployment-nginx-php.yaml | 2 +- .../service-templates/service6/deployment-nginx-php.yaml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/servicetypes/nginx.go b/internal/servicetypes/nginx.go index 5ef283c1..efdc82ef 100644 --- a/internal/servicetypes/nginx.go +++ b/internal/servicetypes/nginx.go @@ -137,7 +137,7 @@ var nginxPHP = ServiceType{ SecurityContext: &corev1.SecurityContext{}, Ports: []corev1.ContainerPort{ { - Name: "http", + Name: "php", ContainerPort: defaultPHPPort, Protocol: corev1.ProtocolTCP, }, diff --git a/internal/templating/services/test-resources/deployment/result-nginx-1.yaml b/internal/templating/services/test-resources/deployment/result-nginx-1.yaml index 5f36889e..73c1c15b 100644 --- a/internal/templating/services/test-resources/deployment/result-nginx-1.yaml +++ b/internal/templating/services/test-resources/deployment/result-nginx-1.yaml @@ -101,7 +101,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 @@ -228,7 +228,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 diff --git a/internal/templating/services/test-resources/deployment/result-nginx-2.yaml b/internal/templating/services/test-resources/deployment/result-nginx-2.yaml index 2dc0e24b..9ec06a60 100644 --- a/internal/templating/services/test-resources/deployment/result-nginx-2.yaml +++ b/internal/templating/services/test-resources/deployment/result-nginx-2.yaml @@ -101,7 +101,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 @@ -229,7 +229,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 diff --git a/internal/testdata/complex/service-templates/service1/deployment-nginx-php.yaml b/internal/testdata/complex/service-templates/service1/deployment-nginx-php.yaml index d4209736..f5beceff 100644 --- a/internal/testdata/complex/service-templates/service1/deployment-nginx-php.yaml +++ b/internal/testdata/complex/service-templates/service1/deployment-nginx-php.yaml @@ -104,7 +104,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 diff --git a/internal/testdata/complex/service-templates/service2/deployment-nginx-php.yaml b/internal/testdata/complex/service-templates/service2/deployment-nginx-php.yaml index 72990ae0..71cdbbae 100644 --- a/internal/testdata/complex/service-templates/service2/deployment-nginx-php.yaml +++ b/internal/testdata/complex/service-templates/service2/deployment-nginx-php.yaml @@ -104,7 +104,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 diff --git a/internal/testdata/complex/service-templates/service5/deployment-nginx-php.yaml b/internal/testdata/complex/service-templates/service5/deployment-nginx-php.yaml index 72990ae0..71cdbbae 100644 --- a/internal/testdata/complex/service-templates/service5/deployment-nginx-php.yaml +++ b/internal/testdata/complex/service-templates/service5/deployment-nginx-php.yaml @@ -104,7 +104,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2 diff --git a/internal/testdata/complex/service-templates/service6/deployment-nginx-php.yaml b/internal/testdata/complex/service-templates/service6/deployment-nginx-php.yaml index 01db76d2..4cbac49c 100644 --- a/internal/testdata/complex/service-templates/service6/deployment-nginx-php.yaml +++ b/internal/testdata/complex/service-templates/service6/deployment-nginx-php.yaml @@ -114,7 +114,7 @@ spec: name: php ports: - containerPort: 9000 - name: http + name: php protocol: TCP readinessProbe: initialDelaySeconds: 2