Skip to content

Commit

Permalink
Merge pull request #265 from dysnix/gcp-local-nvme-raid
Browse files Browse the repository at this point in the history
Gcp local nvme raid chart
  • Loading branch information
plejik authored Jan 16, 2024
2 parents c262ce3 + 38f5d7e commit 166509e
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 0 deletions.
23 changes: 23 additions & 0 deletions dysnix/gcp-local-nvme-raid/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
20 changes: 20 additions & 0 deletions dysnix/gcp-local-nvme-raid/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: gcp-local-nvme-raid
description: Deamon installation which create raid with local nvme disk in gke node

type: application

version: 0.1.0

appVersion: "1.16.0"

keywords:
- gke
- nvme

sources:
- https://github.com/dysnix/charts

maintainers:
- name: plejik
email: anton.rubets@dysnix.com
62 changes: 62 additions & 0 deletions dysnix/gcp-local-nvme-raid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "gcp-local-nvme-raid.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "gcp-local-nvme-raid.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "gcp-local-nvme-raid.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "gcp-local-nvme-raid.labels" -}}
helm.sh/chart: {{ include "gcp-local-nvme-raid.chart" . }}
{{ include "gcp-local-nvme-raid.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "gcp-local-nvme-raid.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gcp-local-nvme-raid.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "gcp-local-nvme-raid.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "gcp-local-nvme-raid.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
79 changes: 79 additions & 0 deletions dysnix/gcp-local-nvme-raid/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "gcp-local-nvme-raid.fullname" . }}
labels:
{{- include "gcp-local-nvme-raid.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "gcp-local-nvme-raid.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "gcp-local-nvme-raid.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
hostPID: true
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: STARTUP_SCRIPT
value: |
set -o errexit
set -o nounset
set -o pipefail
devices=()
for ssd in /dev/disk/by-id/google-local-ssd-block*; do
if [ -e "${ssd}" ]; then
devices+=("${ssd}")
fi
done
if [ "${#devices[@]}" -eq 0 ]; then
echo "No Local NVMe SSD disks found."
exit 0
fi
raid_id="md0"
device="/dev/${raid_id}"
echo "Setting RAID array with Local SSDs on device ${device}"
if ! grep -q "$raid_id" /proc/mdstat; then
echo "y" | mdadm --create "${device}" --level=0 --force --raid-devices=${#devices[@]} "${devices[@]}"
fi
if ! tune2fs -l "${device}" ; then
echo "Formatting '${device}'"
mkfs.ext4 {{ .Values.localSsd.mkfsOpts }} "${device}"
fi
mountpoint={{ .Values.localSsd.mountPoint }}
mkdir -p "${mountpoint}"
echo "Mounting '${device}' at '${mountpoint}'"
mount -o discard,defaults "${device}" "${mountpoint}"
chmod a+w "${mountpoint}"
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
34 changes: 34 additions & 0 deletions dysnix/gcp-local-nvme-raid/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Default values for gcp-local-nvme-raid.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: gcr.io/google-containers/startup-script
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "v1"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext:
privileged: true

nodeSelector:
cloud.google.com/gke-local-nvme-ssd: "true"

tolerations:
- effect: NoSchedule
operator: Exists

affinity: {}

localSsd:
mkfsOpts: ""
mountPoint: /mnt/disks/raid0

0 comments on commit 166509e

Please sign in to comment.