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

Adding a helm chart #81

Open
wants to merge 4 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
23 changes: 23 additions & 0 deletions deploy/helm/csi-gcs/.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/
24 changes: 24 additions & 0 deletions deploy/helm/csi-gcs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: csi-gcs
description: A Helm chart for deploying a CSI driver for Google Container Storage

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.8.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we starting with 0.8.0?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I wasn't sure how you're doing versioning, so happy to let you make the decision there!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah wait, is this the helm chart version or the csi gcs version?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appVersion is the CSI GCS version, version is the chart version, which some people choose to version together, others choose to do separately, depending on how much out-of-band development there might be on the chart independent of features in the app I guess?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think versioning that together makes sense. @ofek We need to make sure to change this on releases.

53 changes: 53 additions & 0 deletions deploy/helm/csi-gcs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "csi-gcs.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 "csi-gcs.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 "csi-gcs.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "csi-gcs.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "csi-gcs.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "csi-gcs" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the priority class to use
*/}}
{{- define "csi-gcs.priorityClassName" -}}
{{- if .Values.priorityClass.create }}
{{- default (include "csi-gcs.fullname" .) .Values.priorityClass.name }}
{{- else }}
{{- default "csi-gcs-priority" .Values.priorityClass.name }}
{{- end }}
{{- end }}
141 changes: 141 additions & 0 deletions deploy/helm/csi-gcs/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: {{ include "csi-gcs.fullname" . }}
Copy link
Collaborator

@maennchen maennchen Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add the following labels (to most resources):

    app.kubernetes.io/name: {{ template "csi-gcs.name" $ }}
    app.kubernetes.io/managed-by: {{ $.Release.Service }}
    app.kubernetes.io/instance: {{ $.Release.Name }}
    app.kubernetes.io/version: {{ template "csi-gcs.version" $ }}
    helm.sh/chart: {{ template "csi-gcs.chart" $ }}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

spec:
selector:
matchLabels:
app: {{ include "csi-gcs.fullname" . }}
template:
metadata:
labels:
app: {{ include "csi-gcs.fullname" . }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
priorityClassName: {{ include "csi-gcs.priorityClassName" . }}
tolerations:
- operator: "Exists"
hostNetwork: true
serviceAccount: {{ include "csi-gcs.serviceAccountName" . }}
containers:
- name: csi-node-driver-registrar
image: {{ .Values.images.registrar.repository }}:{{ .Values.images.registrar.tag }}
imagePullPolicy: Always
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
env:
- name: ADDRESS
value: /csi/csi.sock
- name: DRIVER_REG_SOCK_PATH
value: /var/lib/kubelet/plugins/{{ .Values.driverName }}/csi.sock
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
volumeMounts:
- name: registration-dir
mountPath: /registration
- name: socket-dir
mountPath: /csi
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 10m
memory: 20Mi
- name: csi-provisioner
image: {{ .Values.images.provisioner.repository }}:{{ .Values.images.provisioner.tag }}
args:
- "--csi-address=$(ADDRESS)"
- "--extra-create-metadata"
- "--enable-leader-election"
- "--leader-election-namespace=$(NAMESPACE)"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
- name: NAMESPACE
value: {{ .Release.Namespace }}
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
- name: csi-resizer
image: {{ .Values.images.resizer.repository }}:{{ .Values.images.resizer.tag }}
args:
- "--v=5"
- "--csi-address=$(ADDRESS)"
- "--leader-election"
- "--leader-election-namespace=$(NAMESPACE)"
env:
- name: ADDRESS
value: /var/lib/csi/sockets/pluginproxy/csi.sock
- name: NAMESPACE
value: {{ .Release.Namespace }}
imagePullPolicy: "IfNotPresent"
volumeMounts:
- name: socket-dir
mountPath: /var/lib/csi/sockets/pluginproxy/
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 10m
memory: 20Mi
- name: {{ include "csi-gcs.fullname" . }}
securityContext:
privileged: true
capabilities:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
image: {{ .Values.images.driver.repository }}:{{ .Values.images.driver.tag }}
imagePullPolicy: Always
args:
- "--node-name=$(KUBE_NODE_NAME)"
# https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md
- "--v=5"
- "--delete-orphaned-pods=true"
env:
- name: KUBE_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumeMounts:
- name: fuse-device
mountPath: /dev/fuse
- name: mountpoint-dir
mountPath: /var/lib/kubelet/pods
mountPropagation: Bidirectional
- name: socket-dir
mountPath: /csi
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 10m
memory: 80Mi
volumes:
- name: fuse-device
hostPath:
path: /dev/fuse
# https://kubernetes-csi.github.io/docs/deploying.html#driver-volume-mounts
- name: socket-dir
hostPath:
path: /var/lib/kubelet/plugins/{{ .Values.driverName }}
type: DirectoryOrCreate
- name: mountpoint-dir
hostPath:
path: /var/lib/kubelet/pods
type: Directory
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
type: Directory
8 changes: 8 additions & 0 deletions deploy/helm/csi-gcs/templates/driver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: storage.k8s.io/v1beta1
kind: CSIDriver
metadata:
name: {{ .Values.driverName }}
# https://kubernetes-csi.github.io/docs/csi-driver-object.html
spec:
attachRequired: false
podInfoOnMount: true
9 changes: 9 additions & 0 deletions deploy/helm/csi-gcs/templates/priorityclass.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.priorityClass.create }}
apiVersion: scheduling.k8s.io/v1
description: Priority class for the GCS driver
kind: PriorityClass
metadata:
name: {{ include "csi-gcs.priorityClassName" . }}
preemptionPolicy: Never
value: 1000000
Comment on lines +7 to +8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should probably be configurable if the priority class is editable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make these and a few more things that are usually configurable (like the image pull policies, extra labels/annotations, etc) later today

{{- end }}
51 changes: 51 additions & 0 deletions deploy/helm/csi-gcs/templates/published-volumes-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: publishedvolumes.{{ .Values.driverName }}
spec:
group: {{ .Values.driverName }}
versions:
- name: v1beta1
served: true
storage: true
preserveUnknownFields: false
scope: Cluster
names:
plural: publishedvolumes
singular: publishedvolume
kind: PublishedVolume
validation:
openAPIV3Schema:
type: object
required:
- spec
properties:
spec:
type: object
required:
- node
- targetPath
- volumeHandle
- options
- pod
properties:
node:
type: string
targetPath:
type: string
volumeHandle:
type: string
options:
type: object
additionalProperties:
type: string
pod:
type: object
required:
- name
- namespace
properties:
name:
type: string
namespace:
type: string
Loading