|
| 1 | +{{- $hasMachines := gt (len .Values.spec.admin.machineProfiles.machines) 0 }} |
| 2 | +{{- $hasAvailable := gt (len .Values.spec.admin.machineProfiles.available) 0 }} |
| 3 | +{{- $commonCompute := dict |
| 4 | + "trigger" "Off" |
| 5 | + "podLifeTimeThreshold" "10m" |
| 6 | + "resourceDiffPercentage" 20 |
| 7 | +}} |
| 8 | +{{- if $hasMachines }} |
| 9 | + {{- $_ := set $commonCompute "minAllowed" (dict |
| 10 | + "cpu" (index .Values.spec.admin.machineProfiles.machines 0).limits.cpu |
| 11 | + "memory" (index .Values.spec.admin.machineProfiles.machines 0).limits.memory |
| 12 | + ) }} |
| 13 | + {{- $_ = set $commonCompute "maxAllowed" (dict |
| 14 | + "cpu" (index .Values.spec.admin.machineProfiles.machines (sub (len .Values.spec.admin.machineProfiles.machines) 1)).limits.cpu |
| 15 | + "memory" (index .Values.spec.admin.machineProfiles.machines (sub (len .Values.spec.admin.machineProfiles.machines) 1)).limits.memory |
| 16 | + ) }} |
| 17 | +{{- else }} |
| 18 | + {{- $_ := set $commonCompute "minAllowed" (dict |
| 19 | + "cpu" "400m" |
| 20 | + "memory" "400Mi" |
| 21 | + ) }} |
| 22 | + {{- $_ = set $commonCompute "maxAllowed" (dict |
| 23 | + "cpu" "1" |
| 24 | + "memory" "2Gi" |
| 25 | + ) }} |
| 26 | +{{- end }} |
| 27 | + |
| 28 | +{{- define "minmax-profiles" -}} |
| 29 | + {{- $validMachines := list }} |
| 30 | + {{- range $machine := .Values.spec.admin.machineProfiles.available }} |
| 31 | + {{- if ne $machine "custom" }} |
| 32 | + {{- $validMachines = append $validMachines $machine }} |
| 33 | + {{- end }} |
| 34 | + {{- end }} |
| 35 | + {{- $instanceStr := "" }} |
| 36 | + {{- if gt (len $validMachines) 0 }} |
| 37 | + {{- $minMachine := index $validMachines 0 }} |
| 38 | + {{- $maxMachine := index $validMachines (sub (len $validMachines) 1) }} |
| 39 | + {{- $instanceStr = printf "%s,%s" $minMachine $maxMachine }} |
| 40 | + {{- else }} |
| 41 | + {{- $instanceStr = "{}" }} |
| 42 | + {{- end }} |
| 43 | + {{- $instanceStr -}} |
| 44 | +{{- end }} |
| 45 | + |
| 46 | +apiVersion: autoscaling.kubedb.com/v1alpha1 |
| 47 | +kind: HazelcastAutoscaler |
| 48 | +metadata: |
| 49 | + name: {{ include "kubedbcom-hazelcast-editor-options.fullname" . }} |
| 50 | + namespace: {{ .Release.Namespace }} |
| 51 | + labels: |
| 52 | + {{- include "kubedbcom-hazelcast-editor-options.labels" . | nindent 4 }} |
| 53 | + {{- if $hasAvailable }} |
| 54 | + annotations: |
| 55 | + kubernetes.io/instance-type: {{ printf "%s" (include "minmax-profiles" .) | quote }} |
| 56 | + {{- end }} |
| 57 | +spec: |
| 58 | + databaseRef: |
| 59 | + name: {{ include "kubedbcom-hazelcast-editor-options.fullname" . }} |
| 60 | + opsRequestOptions: |
| 61 | + timeout: 10m |
| 62 | + apply: IfReady |
| 63 | + compute: |
| 64 | + hazelcast: |
| 65 | + {{- $commonCompute | toYaml | nindent 6 }} |
| 66 | +{{- if eq .Values.spec.admin.deployment.default "Dedicated" }} |
| 67 | + nodeTopology: |
| 68 | + name: {{ .Values.spec.admin.clusterTier.nodeTopology.default }} |
| 69 | +{{- else if $hasAvailable }} |
| 70 | + nodeTopology: |
| 71 | + name: kubedb-ui-machine-profiles |
| 72 | +{{- end }} |
0 commit comments