Add loadbalancersourceranges to ssh service #105

Merged
techknowlogick merged 7 commits from JPRbrs/helm-chart:master into master 2021-02-04 20:42:42 +00:00
2 changed files with 10 additions and 1 deletions

View File

@ -8,8 +8,16 @@ metadata:
{{- toYaml .Values.service.ssh.annotations | nindent 4 }}
spec:
type: {{ .Values.service.ssh.type }}
{{- if and .Values.service.ssh.loadBalancerIP (eq .Values.service.ssh.type "LoadBalancer") }}
{{- if eq .Values.service.ssh.type "LoadBalancer" }}

The "and" seems to be wrong here.

I think it would be better, if we make one if to check if type == loadBalancer.
Including two other ifs to check if sourceRanges and/or an ip is provided.

Something like this:

{{- if eq .Values.service.ssh.type "LoadBalancer" }}
{{- if .Values.service.ssh.loadBalancerSourceRanges }}
...
{{- end }}
{{- if .Values.service.ssh.loadBalancerIP }}
....
{{- end }}
{{- end }}
The "and" seems to be wrong here. I think it would be better, if we make one if to check if type == loadBalancer. Including two other ifs to check if sourceRanges and/or an ip is provided. Something like this: ```yaml {{- if eq .Values.service.ssh.type "LoadBalancer" }} {{- if .Values.service.ssh.loadBalancerSourceRanges }} ... {{- end }} {{- if .Values.service.ssh.loadBalancerIP }} .... {{- end }} {{- end }} ```

thanks for the feedback @luhahn I've pushed the changes

thanks for the feedback @luhahn I've pushed the changes

This will now only trigger, if loadBalancerIP is set AND type == LoadBalancer.
I guess you would want to use loadBalancerSourceRanges with and without a loadBalancerIP.

Please split the if above like that:

{{- if eq .Values.service.ssh.type "LoadBalancer" }}
{{- if .Values.service.ssh.loadBalancerIP }}
...
{{- end }}
{{- if .Values.service.ssh.loadBalancerSourceRanges }}
...
{{- end }}
{{- end }}
This will now only trigger, if loadBalancerIP is set AND type == LoadBalancer. I guess you would want to use loadBalancerSourceRanges with and without a loadBalancerIP. Please split the if above like that: ```yaml {{- if eq .Values.service.ssh.type "LoadBalancer" }} {{- if .Values.service.ssh.loadBalancerIP }} ... {{- end }} {{- if .Values.service.ssh.loadBalancerSourceRanges }} ... {{- end }} {{- end }}

@luhahn if I'm not mistaken, loadBalancerSourceRanges is only effective for LoadBancer type services, so there is no need to use it if the service type is not LoadBalancer

It doesn't say so specifically but that is my uderstanding from the documentatoin

@luhahn if I'm not mistaken, loadBalancerSourceRanges is only effective for LoadBancer type services, so there is no need to use it if the service type is not LoadBalancer It doesn't say so specifically but that is my uderstanding from the [documentatoin](https://cloud.google.com/kubernetes-engine/docs/how-to/service-parameters#lb_source_ranges)

Yes, I know. But currently your loadBalancerSourceRanges would only apply if also a loadBalancerIP is given.

Please have a closer look at my suggested if.

{{- if eq .Values.service.ssh.type "LoadBalancer" }} # if type == loadBalancer
  {{- if .Values.service.ssh.loadBalancerIP }} # if a load balancer IP is given
    loadBalancerIP: 
  {{- end }} # end if loadBalancerIP
  {{- if .Values.service.ssh.loadBalancerSourceRanges }} # if sourceRanges are given
    loadBalancerSourceRanges: ...
  {{- end }} # end if loadBalancerSourceRanges
{{- end }} # end if type == loadBalancer
Yes, I know. But currently your loadBalancerSourceRanges would only apply if also a loadBalancerIP is given. Please have a closer look at my suggested if. ```yaml {{- if eq .Values.service.ssh.type "LoadBalancer" }} # if type == loadBalancer {{- if .Values.service.ssh.loadBalancerIP }} # if a load balancer IP is given loadBalancerIP: {{- end }} # end if loadBalancerIP {{- if .Values.service.ssh.loadBalancerSourceRanges }} # if sourceRanges are given loadBalancerSourceRanges: ... {{- end }} # end if loadBalancerSourceRanges {{- end }} # end if type == loadBalancer ```

Oh, I see! Many thanks for your detailed explanation, I reckon that's way better. I've just pushed the commit :)

Oh, I see! Many thanks for your detailed explanation, I reckon that's way better. I've just pushed the commit :)
{{- if .Values.service.ssh.loadBalancerIP }}

Can you wrap a conditional around loadBalancerSourceRanges in case the array is empty?

Can you wrap a conditional around `loadBalancerSourceRanges` in case the array is empty?
loadBalancerIP: {{ .Values.service.ssh.loadBalancerIP }}
{{- end -}}
{{- if .Values.service.ssh.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range .Values.service.ssh.loadBalancerSourceRanges }}
- {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- if and .Values.service.ssh.clusterIP (eq .Values.service.ssh.type "ClusterIP") }}
clusterIP: {{ .Values.service.ssh.clusterIP }}

View File

@ -29,6 +29,7 @@ service:
#nodePort:
#externalTrafficPolicy:
#externalIPs:
loadBalancerSourceRanges: []
annotations:
ingress: