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

[charts/cosi] add COSI driver helm chart #267

Merged
merged 18 commits into from
Aug 31, 2023
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/kubelinter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: COSI driver

on:
push:
branches: [main]
pull_request:
branches: ["**"]

env:
GOPRIVATE: github.com/dell/*
TOKEN: ${{ secrets.GH_DELL_ACCESS }}

jobs:
kube-linter:
name: Kube Linter
runs-on: ubuntu-latest
steps:
- name: Configure git for private modules
run: |
git config --global url."https://csmbot:[email protected]".insteadOf "https://github.com"
echo "machine github.com login csmbot password $TOKEN" >> ~/.netrc
- name: Checkout the code
uses: actions/[email protected]
- name: Scan repo with kube-linter
uses: stackrox/[email protected]
with:
directory: charts/cosi
config: kubelinter-config.yaml

36 changes: 36 additions & 0 deletions charts/cosi/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright © 2023 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License

apiVersion: v2
name: cosi
description: Container Object Storage Interface (COSI) Driver for Dell ObjectScale

# 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.1.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: 1.0.0-alpha
5 changes: 5 additions & 0 deletions charts/cosi/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Thank you for installing {{ .Chart.Name }}.

Your release is named {{ .Release.Name }}.

For more information visit CSM documentation: https://dell.github.io/csm-docs/
183 changes: 183 additions & 0 deletions charts/cosi/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cosi.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 "cosi.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 "cosi.chart" }}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
# COSI driver log level
# Possible values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
# Default value: 4
*/}}
{{- define "cosi.logLevel" }}
{{- $logLevelValues := list 0 1 2 3 4 5 6 7 8 9 10 }}
{{- if (has .Values.provisioner.logLevel $logLevelValues) }}
{{- .Values.provisioner.logLevel }}
{{- else }}
{{- 4 }}
{{- end }}
{{- end }}

{{/*
# COSI driver sidecar log level
# Values are set to the integer value, higher value means more verbose logging
*/}}
{{- define "cosi.provisionerSidecarVerbosity" }}
{{- if (kindIs "int" .Values.sidecar.verbosity) }}
{{- .Values.sidecar.verbosity }}
{{- else }}
{{- 5 }}
{{- end }}
{{- end }}

{{/*
# COSI driver log format
# Possible values: "json" "text"
# Default value: "json"
*/}}
{{- define "cosi.logFormat" }}
{{- $logFormatValues := list "json" "text" }}
{{- if (has .Values.provisioner.logFormat $logFormatValues) }}
{{- .Values.provisioner.logFormat }}
{{- else }}
{{- "text" }}
{{- end }}
{{- end }}

{{/*
# COSI driver OTEL endpoint
# Default value is left empty on purpose, to not start any tracing if no argument was provided.
# Default value: ""
*/}}
{{- define "cosi.otelEndpoint" }}
{{- if .Values.provisioner.otelEndpoint }}
{{- .Values.provisioner.otelEndpoint }}
{{- else }}
{{- "" }}
{{- end }}
{{- end }}

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

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

{{/*
Create the name of the role to use
*/}}
{{- define "cosi.roleName" }}
{{- if and .Values.rbac.create }}
{{- default (printf "%s" (include "cosi.fullname" .)) .Values.rbac.role.name }}
{{- else }}
{{- .Values.rbac.role.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the role binding to use
*/}}
{{- define "cosi.roleBindingName" }}
{{- if and .Values.rbac.create }}
{{- default (printf "%s" (include "cosi.fullname" .)) .Values.rbac.roleBinding.name }}
{{- else }}
{{- .Values.rbac.roleBinding.name }}
{{- end }}
{{- end }}

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

{{/*
Create the name of provisioner container
*/}}
{{- define "cosi.provisionerContainerName" }}
{{- default "objectstorage-provisioner" .Values.provisioner.name }}
{{- end }}

{{/*
Create the name of provisioner sidecar container
*/}}
{{- define "cosi.provisionerSidecarContainerName" }}
{{- default "objectstorage-provisioner-sidecar" .Values.sidecar.name }}
{{- end }}

{{/*
Create the full name of provisioner image from repository and tag
*/}}
{{- define "cosi.provisionerImageName" }}
{{- .Values.provisioner.image.repository }}:{{ .Values.provisioner.image.tag | default .Chart.AppVersion }}
{{- end }}

{{/*
Create the full name of provisioner sidecar image from repository and tag
*/}}
{{- define "cosi.provisionerSidecarImageName" }}
{{- .Values.sidecar.image.repository }}:{{ .Values.sidecar.image.tag }}
{{- end }}

{{/*
Create the secret name
*/}}
{{- define "cosi.secretName" }}
{{- if .Values.configuration.create }}
{{- default (printf "%s-config" (include "cosi.name" . )) .Values.configuration.secretName }}
{{- else }}
{{- .Values.configuration.secretName }}
{{- end }}
{{- end }}

{{/*
Create the name for secret volume
*/}}
{{- define "cosi.secretVolumeName" }}
{{- printf "%s-config" (include "cosi.name" . ) }}
{{- end }}
90 changes: 90 additions & 0 deletions charts/cosi/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cosi.fullname" . }}
labels:
{{- include "cosi.labels" . | trim | nindent 4 }}
{{- with .Values.rbac.role.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "cosi.selectorLabels" . | trim | nindent 6 }}
template:
metadata:
labels:
{{- include "cosi.labels" . | trim | nindent 8 }}
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "cosi.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ include "cosi.provisionerContainerName" . }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
image: {{ include "cosi.provisionerImageName" . }}
imagePullPolicy: {{ .Values.provisioner.image.pullPolicy }}
args:
- "--log-level={{ include "cosi.logLevel" . }}"
- "--log-format={{ include "cosi.logFormat" . }}"
- "--otel-endpoint={{ include "cosi.otelEndpoint" . }}"
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: {{ include "cosi.secretVolumeName" . }}
mountPath: /cosi
- name: cosi-socket-dir
mountPath: /var/lib/cosi
- name: {{ include "cosi.provisionerSidecarContainerName" . }}
image: {{ include "cosi.provisionerSidecarImageName" . }}
imagePullPolicy: {{ .Values.sidecar.image.pullPolicy }}
args:
- "-v={{ include "cosi.provisionerSidecarVerbosity" . }}"
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: cosi-socket-dir
mountPath: /var/lib/cosi
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: {{ include "cosi.secretVolumeName" . }}
secret:
secretName: {{ include "cosi.secretName" . }}
- name: cosi-socket-dir
emptyDir: {}
Loading
Loading