Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local Persistent Volumes support #85

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions stable/yugabyte/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
45 changes: 45 additions & 0 deletions stable/yugabyte/templates/local-pd-pv.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 10 additions & 0 deletions stable/yugabyte/templates/local-pd-sc.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
54 changes: 31 additions & 23 deletions stable/yugabyte/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand Down Expand Up @@ -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:
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -186,7 +193,7 @@ spec:
operator: In
values:
- {{ $root.Values.AZ }}
{{ end }}
{{- end }}
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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:
Expand All @@ -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 }}
Expand Down
8 changes: 8 additions & 0 deletions stable/yugabyte/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down