diff --git a/stable/yugabyte/templates/_helpers.tpl b/stable/yugabyte/templates/_helpers.tpl index 57bb7ecdde..fee1de6773 100644 --- a/stable/yugabyte/templates/_helpers.tpl +++ b/stable/yugabyte/templates/_helpers.tpl @@ -187,3 +187,24 @@ Compute the maximum number of unavailable pods based on the number of master rep {{- $max_unavailable_master_replicas := 100 | div (100 | sub (2 | div ($master_replicas_100x | add 100))) -}} {{- printf "%d" $max_unavailable_master_replicas -}} {{- end -}} + +{{/* +Local persistent disk storage class name +*/}} +{{- define "yugabyte.localsc_name" -}} + {{- printf "%s-local-sc" (include "yugabyte.fullname" .) -}} +{{- end -}} + +{{/* +Local persistent disk name +*/}} +{{- define "yugabyte.localdisk_name" -}} + {{- printf "%s-local-pv" (include "yugabyte.fullname" .) -}} +{{- end -}} + +{{/* +Local persistent disk storage mount path +*/}} +{{- define "yugabyte.localdisk_mntpath" -}} + {{ default .Values.storage.localDisk.mountPath "/mnt/disks/ssd" }} +{{- end -}} diff --git a/stable/yugabyte/templates/local-pd-pv.yaml b/stable/yugabyte/templates/local-pd-pv.yaml new file mode 100644 index 0000000000..0ad2b1c1a7 --- /dev/null +++ b/stable/yugabyte/templates/local-pd-pv.yaml @@ -0,0 +1,45 @@ +{{- if .Values.storage.localDisk.enabled }} + {{- $replicaCounter := 1 }} + {{- $storageInfo := dict "count" 1 "size" "10G" }} + {{- range tuple "master" "tserver" }} + {{- if eq . "master" }} + {{- $replicaCounter = $.Values.replicas.master }} + {{- $storageInfo = dict "count" $.Values.storage.master.count "size" $.Values.storage.master.size }} + {{- else }} + {{- $replicaCounter = $.Values.replicas.tserver }} + {{- $storageInfo = dict "count" $.Values.storage.tserver.count "size" $.Values.storage.tserver.size }} + {{- end}} + {{- range $replicaIndex := until (int ($replicaCounter)) }} + {{- range $index := until (int ($storageInfo.count )) }} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{- include "yugabyte.localdisk_name" $ | indent 1 }}-{{ $replicaCounter }}{{ $replicaIndex }}{{ $index }} + labels: + {{- include "yugabyte.labels" $ | indent 4 }} +spec: + capacity: + storage: {{ $storageInfo.size }} + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + storageClassName: {{- include "yugabyte.localsc_name" $ | indent 1 }} + local: + path: {{- include "yugabyte.localdisk_mntpath" $ | indent 1 }}{{ $index }} + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: failure-domain.beta.kubernetes.io/zone + operator: In + values: + - {{ $.Values.AZ }} + - matchExpressions: + - key: topology.kubernetes.io/zone + operator: In + values: + - {{ $.Values.AZ }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/stable/yugabyte/templates/local-pd-sc.yaml b/stable/yugabyte/templates/local-pd-sc.yaml new file mode 100644 index 0000000000..59ad0b0dfd --- /dev/null +++ b/stable/yugabyte/templates/local-pd-sc.yaml @@ -0,0 +1,10 @@ +{{- if .Values.storage.localDisk.enabled }} +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: {{- include "yugabyte.localsc_name" $ | indent 1 }} + labels: + {{- include "yugabyte.labels" $ | indent 4 }} +provisioner: kubernetes.io/no-provisioner +volumeBindingMode: WaitForFirstConsumer +{{- end }} diff --git a/stable/yugabyte/templates/service.yaml b/stable/yugabyte/templates/service.yaml index 65d1f5df96..87dfe9d0e9 100644 --- a/stable/yugabyte/templates/service.yaml +++ b/stable/yugabyte/templates/service.yaml @@ -55,6 +55,7 @@ data: apiVersion: v1 kind: Service metadata: + namespace: "{{ $root.Release.Namespace }}" name: {{ $root.Values.oldNamingStyle | ternary .name (printf "%s-%s" (include "yugabyte.fullname" $root) .name) | quote }} labels: {{- include "yugabyte.applabel" ($appLabelArgs) | indent 4 }} @@ -77,17 +78,20 @@ spec: apiVersion: v1 kind: Service metadata: + namespace: "{{ $root.Release.Namespace }}" name: {{ $root.Values.oldNamingStyle | ternary $endpoint.name (printf "%s-%s" (include "yugabyte.fullname" $root) $endpoint.name) | quote }} + {{- if $endpoint.annotations }} annotations: {{ toYaml $endpoint.annotations | indent 4 }} + {{- end }} labels: {{- include "yugabyte.applabel" ($appLabelArgs) | indent 4 }} {{- include "yugabyte.labels" $root | indent 4 }} spec: - {{ if eq $root.Release.Service "Tiller" }} + {{- if eq $root.Release.Service "Tiller" }} clusterIP: - {{ else }} - {{ if $endpoint.clusterIP }} + {{- else }} + {{- if $endpoint.clusterIP }} clusterIP: {{ $endpoint.clusterIP }} {{- end }} {{- end }} @@ -115,26 +119,29 @@ metadata: spec: serviceName: {{ $root.Values.oldNamingStyle | ternary .name (printf "%s-%s" (include "yugabyte.fullname" $root) .name) | quote }} podManagementPolicy: {{ $root.Values.PodManagementPolicy }} - {{ if eq .name "yb-masters" }} + {{- if eq .name "yb-masters" }} replicas: {{ $root.Values.replicas.master }} - {{ else }} + {{- else }} replicas: {{ $root.Values.replicas.tserver }} - {{ end }} + {{- end }} {{- $storageInfo := (eq .name "yb-masters") | ternary $root.Values.storage.master $root.Values.storage.tserver -}} - {{ if not $root.Values.storage.ephemeral }} + {{- $sclass := $root.Values.storage.localDisk.enabled | ternary (printf "%s" (include "yugabyte.localsc_name" $root)) $storageInfo.storageClass -}} + {{- if not $root.Values.storage.ephemeral }} volumeClaimTemplates: {{- range $index := until (int ($storageInfo.count )) }} - metadata: name: {{ $root.Values.oldNamingStyle | ternary (printf "datadir%d" $index) (printf "%s%d" (include "yugabyte.volume_name" $root) $index) }} + {{- if $sclass }} annotations: - volume.beta.kubernetes.io/storage-class: {{ $storageInfo.storageClass }} + volume.beta.kubernetes.io/storage-class: {{ $sclass }} + {{- end }} labels: {{- include "yugabyte.labels" $root | indent 10 }} spec: accessModes: - "ReadWriteOnce" - {{- if $storageInfo.storageClass }} - storageClassName: {{ $storageInfo.storageClass }} + {{- if $sclass }} + storageClassName: {{ $sclass }} {{- end }} resources: requests: @@ -144,20 +151,20 @@ spec: updateStrategy: type: RollingUpdate rollingUpdate: - {{ if eq .name "yb-masters" }} + {{- if eq .name "yb-masters" }} partition: {{ $root.Values.partition.master }} - {{ else }} + {{- else }} partition: {{ $root.Values.partition.tserver }} - {{ end }} + {{- end }} selector: matchLabels: {{- include "yugabyte.appselector" ($appLabelArgs) | indent 6 }} template: metadata: - {{ if $root.Values.networkAnnotation }} + {{- if $root.Values.networkAnnotation }} annotations: {{ toYaml $root.Values.networkAnnotation | indent 8}} - {{ end }} + {{- end }} labels: {{- include "yugabyte.applabel" ($appLabelArgs) | indent 8 }} {{- include "yugabyte.labels" $root | indent 8 }} @@ -172,7 +179,7 @@ spec: {{- end }} affinity: # Set the anti-affinity selector scope to YB masters. - {{ if $root.Values.AZ }} + {{- if $root.Values.AZ }} nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: @@ -186,7 +193,7 @@ spec: operator: In values: - {{ $root.Values.AZ }} - {{ end }} + {{- end }} podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 @@ -245,11 +252,11 @@ spec: value: /root/.yugabytedb/root.crt {{- end }} resources: - {{ if eq .name "yb-masters" }} + {{- if eq .name "yb-masters" }} {{ toYaml $root.Values.resource.master | indent 10 }} - {{ else }} + {{- else }} {{ toYaml $root.Values.resource.tserver | indent 10 }} - {{ end }} + {{- end }} # core dumps are collected to workingDir if # kernel.core_pattern is set to a relative path like # core.%e.%p.%t ref: @@ -377,7 +384,7 @@ spec: name: {{ $label | quote }} {{- end}} volumeMounts: - {{ if not $root.Values.storage.ephemeral }} + {{- if not $root.Values.storage.ephemeral }} {{- range $index := until (int ($storageInfo.count)) }} - name: {{ $root.Values.oldNamingStyle | ternary (printf "datadir%d" $index) (printf "%s%d" (include "yugabyte.volume_name" $root) $index) }} mountPath: /mnt/disk{{ $index }} @@ -392,7 +399,7 @@ spec: readOnly: true {{- end }} - {{ if not $root.Values.storage.ephemeral }} + {{- if not $root.Values.storage.ephemeral }} - name: yb-cleanup image: "{{ $root.Values.Image.repository }}:{{ $root.Values.Image.tag }}" imagePullPolicy: {{ $root.Values.Image.pullPolicy }} @@ -417,7 +424,7 @@ spec: {{- end }} volumes: - {{ if not $root.Values.storage.ephemeral }} + {{- if not $root.Values.storage.ephemeral }} {{- range $index := until (int ($storageInfo.count)) }} - name: {{ $root.Values.oldNamingStyle | ternary (printf "datadir%d" $index) (printf "%s%d" (include "yugabyte.volume_name" $root) $index) }} hostPath: @@ -439,6 +446,7 @@ spec: apiVersion: policy/v1beta1 kind: PodDisruptionBudget metadata: + namespace: "{{ $root.Release.Namespace }}" name: {{ $root.Values.oldNamingStyle | ternary (printf "%s-pdb" .label) (printf "%s-%s-pdb" (include "yugabyte.fullname" $root) .name) }} spec: maxUnavailable: {{ template "yugabyte.max_unavailable_for_quorum" $root }} diff --git a/stable/yugabyte/values.yaml b/stable/yugabyte/values.yaml index 4732fa5325..6daac72e16 100644 --- a/stable/yugabyte/values.yaml +++ b/stable/yugabyte/values.yaml @@ -17,6 +17,14 @@ storage: count: 2 size: 10Gi storageClass: standard + localDisk: + # Turning this flag on would configure the local persistent disk. No of disks configured would still depend + # on storage.master.count and storage.tserver.count. Set those values appropriately based on the number of local + # disks configured during cluster creation. This would set the static PVs to be mounted instead of the dynamic + # storage provision. + enabled: false + # This would be the path referred in the static PVs. A running index starting from '0' will be suffixed to this path + mountPath: /mnt/disks/ssd resource: master: