From 65c783be894b2bc497b6a1709104bbe5413a79a4 Mon Sep 17 00:00:00 2001 From: Elad Ben-Israel Date: Tue, 10 Oct 2023 02:00:53 +0300 Subject: [PATCH] only public workloads should be use NODE_PORT --- test/containers.test.w | 2 +- tf-aws/workload.w | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/containers.test.w b/test/containers.test.w index e72febd..5f9b4e7 100644 --- a/test/containers.test.w +++ b/test/containers.test.w @@ -7,7 +7,7 @@ let hello = new containers.Workload( image: "paulbouwer/hello-kubernetes:1", port: 8080, readiness: "/", - replicas: 4, + replicas: 3, env: { "MESSAGE" => message, }, diff --git a/tf-aws/workload.w b/tf-aws/workload.w index 9c4b196..cd96276 100644 --- a/tf-aws/workload.w +++ b/tf-aws/workload.w @@ -71,12 +71,19 @@ class _Chart extends k8s.Chart { } ); + let isPublic = props.public ?? false; + let var serviceType: cdk8s.ServiceType? = nil; + + if isPublic { + serviceType = cdk8s.ServiceType.NODE_PORT; + } + let service = deployment.exposeViaService( name: name, - serviceType: cdk8s.ServiceType.NODE_PORT, + serviceType: serviceType, ); - if (props.public ?? false) { + if isPublic { new cdk8s.Ingress( metadata: { name: name,