diff --git a/charts/core/README.md b/charts/core/README.md index 499079bd..21872d76 100644 --- a/charts/core/README.md +++ b/charts/core/README.md @@ -80,6 +80,7 @@ Parameter | Description | Default | Notes `controller.certificate.keyFile` | Replace controller REST API certificate key file | `tls.key` | `controller.certificate.pemFile` | Replace controller REST API certificate pem file | `tls.pem` | `controller.federation.mastersvc.type` | Multi-cluster primary cluster service type. If specified, the deployment will be used to manage other clusters. Possible values include NodePort, LoadBalancer and ClusterIP. | `nil` | +`controller.federation.mastersvc.loadBalancerIP` | Multi-cluster primary cluster service load balancer IP. If specified, the deployment must also specify controller.federation.mastersvc.type of LoadBalancer. | `nil` | `controller.federation.mastersvc.clusterIP` | Set clusterIP to be used for mastersvc | `nil` | `controller.federation.mastersvc.nodePort` | Define a nodePort for mastersvc | `nil` | Must be a valid NodePort (30000-32767) `controller.federation.mastersvc.externalTrafficPolicy` | Set externalTrafficPolicy to be used for mastersvc | `nil` | @@ -99,7 +100,8 @@ Parameter | Description | Default | Notes `controller.federation.mastersvc.ingress.secretName` | Name of the secret to be used for TLS-encryption | `nil` | Secret must be created separately (Let's encrypt, manually) `controller.federation.mastersvc.ingress.path` | Set ingress path |`/` | If set, it might be necessary to set a rewrite rule in annotations. `controller.federation.mastersvc.ingress.annotations` | Add annotations to ingress to influence behavior | `nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"` | see examples in [values.yaml](values.yaml) -`controller.federation.managedsvc.type` | Multi-cluster managed cluster service type. If specified, the deployment will be managed by the managed cluster. Possible values include NodePort, LoadBalancer and ClusterIP. | `nil` | +`controller.federation.managedsvc.type` | Multi-cluster managed cluster service type. If specified, the deployment will be managed by the managed clsuter. Possible values include NodePort, LoadBalancer and ClusterIP. | `nil` | +`controller.federation.managedsvc.loadBalancerIP` | Multi-cluster primary cluster service load balancer IP. If specified, the deployment must also specify controller.federation.mastersvc.type of LoadBalancer. | `nil` | `controller.federation.managedsvc.clusterIP` | Set clusterIP to be used for managedsvc | `nil` | `controller.federation.managedsvc.nodePort` | Define a nodePort for managedsvc | `nil` | Must be a valid NodePort (30000-32767) `controller.federation.managedsvc.externalTrafficPolicy` | Set externalTrafficPolicy to be used for managedsvc | `nil` | diff --git a/charts/core/templates/controller-service.yaml b/charts/core/templates/controller-service.yaml index dc1813b9..1eeae5ac 100644 --- a/charts/core/templates/controller-service.yaml +++ b/charts/core/templates/controller-service.yaml @@ -63,6 +63,9 @@ metadata: heritage: Helm spec: type: {{ .Values.controller.federation.mastersvc.type }} +{{- if and .Values.controller.federation.mastersvc.loadBalancerIP (eq .Values.controller.federation.mastersvc.type "LoadBalancer") }} + loadBalancerIP: {{ .Values.controller.federation.mastersvc.loadBalancerIP }} +{{- end }} {{- if .Values.controller.federation.mastersvc.clusterIP }} clusterIP: {{ .Values.controller.federation.mastersvc.clusterIP }} {{- end }} @@ -99,6 +102,9 @@ metadata: heritage: Helm spec: type: {{ .Values.controller.federation.managedsvc.type }} +{{- if and .Values.controller.federation.managedsvc.loadBalancerIP (eq .Values.controller.federation.managedsvc.type "LoadBalancer") }} + loadBalancerIP: {{ .Values.controller.federation.managedsvc.loadBalancerIP }} +{{- end }} {{- if .Values.controller.federation.managedsvc.clusterIP }} clusterIP: {{ .Values.controller.federation.managedsvc.clusterIP }} {{- end }} diff --git a/charts/core/values.yaml b/charts/core/values.yaml index 8a1d1f20..5e6670a1 100644 --- a/charts/core/values.yaml +++ b/charts/core/values.yaml @@ -154,6 +154,7 @@ controller: federation: mastersvc: type: + loadBalancerIP: clusterIP: nodePort: # Must be a valid NodePort: 30000-32767 externalTrafficPolicy: @@ -191,6 +192,7 @@ controller: # -----END PRIVATE KEY----- managedsvc: type: + loadBalancerIP: clusterIP: nodePort: # Must be a valid NodePort: 30000-32767 externalTrafficPolicy: diff --git a/test/service_test.go b/test/service_test.go index 821cce78..8507394b 100644 --- a/test/service_test.go +++ b/test/service_test.go @@ -327,3 +327,61 @@ func TestManagerServiceLBIP(t *testing.T) { checkManagerService(t, svc, svcType) } + +func TestFedMasterServiceLBIP(t *testing.T) { + helmChartPath := "../charts/core" + + svcType := "LoadBalancer" + options := &helm.Options{ + SetValues: map[string]string{ + "controller.federation.mastersvc.type": svcType, + "controller.federation.mastersvc.loadBalancerIP": "1.2.3.4", + }, + } + + // Test controller service + out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-service.yaml"}) + outs := splitYaml(out) + + if len(outs) != 2 { + t.Errorf("Resource count is wrong. count=%v\n", len(outs)) + } + + var svc corev1.Service + helm.UnmarshalK8SYaml(t, outs[1], &svc) + + if svc.Spec.LoadBalancerIP != "1.2.3.4" { + t.Errorf("Service loadbalancerIP is wrong. ip=%+v\n", svc.Spec.LoadBalancerIP) + } + + checkControllerServiceFedMaster(t, svc, svcType) +} + +func TestFedManagedServiceLBIP(t *testing.T) { + helmChartPath := "../charts/core" + + svcType := "LoadBalancer" + options := &helm.Options{ + SetValues: map[string]string{ + "controller.federation.managedsvc.type": svcType, + "controller.federation.managedsvc.loadBalancerIP": "1.2.3.4", + }, + } + + // Test controller service + out := helm.RenderTemplate(t, options, helmChartPath, nvRel, []string{"templates/controller-service.yaml"}) + outs := splitYaml(out) + + if len(outs) != 2 { + t.Errorf("Resource count is wrong. count=%v\n", len(outs)) + } + + var svc corev1.Service + helm.UnmarshalK8SYaml(t, outs[1], &svc) + + if svc.Spec.LoadBalancerIP != "1.2.3.4" { + t.Errorf("Service loadbalancerIP is wrong. ip=%+v\n", svc.Spec.LoadBalancerIP) + } + + checkControllerServiceFedManaged(t, svc, svcType) +} \ No newline at end of file