diff --git a/charts/temporal/templates/server-service.yaml b/charts/temporal/templates/server-service.yaml index 52b82a11..a7891f93 100644 --- a/charts/temporal/templates/server-service.yaml +++ b/charts/temporal/templates/server-service.yaml @@ -13,6 +13,9 @@ metadata: {{- end }} spec: type: {{ $serviceValues.service.type }} + {{- if hasKey $serviceValues.service "clusterIP" }} + clusterIP: {{ $serviceValues.service.clusterIP }} + {{- end }} ports: - port: {{ $serviceValues.service.port }} targetPort: rpc diff --git a/charts/temporal/tests/service_test.go b/charts/temporal/tests/service_test.go new file mode 100644 index 00000000..933c522b --- /dev/null +++ b/charts/temporal/tests/service_test.go @@ -0,0 +1,58 @@ +package test + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/gruntwork-io/terratest/modules/helm" + "github.com/gruntwork-io/terratest/modules/k8s" + "github.com/gruntwork-io/terratest/modules/random" + "github.com/stretchr/testify/require" + appsv1 "k8s.io/api/apps/v1" +) + +func TestTemplateServerServiceDefault(t *testing.T) { + // t.Parallel() + + helmChartPath, err := filepath.Abs("../") + releaseName := "temporal" + require.NoError(t, err) + + namespaceName := "temporal-" + strings.ToLower(random.UniqueId()) + + var deployment appsv1.Deployment + + options := &helm.Options{ + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + BuildDependencies: true, + } + + output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/server-service.yaml"}) + + helm.UnmarshalK8SYaml(t, output, &deployment) +} + +func TestTemplateServerServiceFrontendClusterIP(t *testing.T) { + // t.Parallel() + + helmChartPath, err := filepath.Abs("../") + releaseName := "temporal" + require.NoError(t, err) + + namespaceName := "temporal-" + strings.ToLower(random.UniqueId()) + + var deployment appsv1.Deployment + + options := &helm.Options{ + SetValues: map[string]string{ + "frontend.service.clusterIP": "None", + }, + KubectlOptions: k8s.NewKubectlOptions("", "", namespaceName), + BuildDependencies: true, + } + + output := helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/server-service.yaml"}) + + helm.UnmarshalK8SYaml(t, output, &deployment) +}