Skip to content

Commit

Permalink
feat(cdl): add helm charts support
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Nov 15, 2024
1 parent ec788cd commit 9a3a989
Show file tree
Hide file tree
Showing 22 changed files with 755 additions and 10 deletions.
2 changes: 1 addition & 1 deletion charts/cdl-dataset/templates/model_claim.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
deletionPolicy:
{{- toYaml .Values.deletionPolicy | nindent 4 }}
resources:
{{- toYaml .Values.claim.resources | nindent 4 }}
{{- toYaml .Values.resources | nindent 4 }}
storage: ObjectStorage
storageName:
{{- toYaml .Values.static.targetStorageName | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/cdl-dataset/templates/model_storage_binding.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ spec:
{{- toYaml .Values.deletionPolicy | nindent 4 }}
model: {{ .Release.Name }}
resources:
{{- toYaml .Values.claim.resources | nindent 4 }}
{{- toYaml .Values.resources | nindent 4 }}
storage:
{{- if .Values.static.sourceStorageName }}
cloned:
Expand Down
23 changes: 23 additions & 0 deletions charts/cdl-endpoint/.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/
13 changes: 13 additions & 0 deletions charts/cdl-endpoint/.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
input:
- values.yaml

draft: 2020
indent: 2
output: values.schema.json

schemaRoot:
id: https://smartx-team.github.io/mobilex-api/charts/nvidia-isaac-sim
title: NVIDIA Issac-Sim Schema
description: Schema for NVIDIA Issac-Sim Helm Chart
additionalProperties: true
25 changes: 25 additions & 0 deletions charts/cdl-endpoint/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
apiVersion: v2
name: cdl-endpoint
description: Convenient Connected Data Lake endpoint instance deployment tool

# 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.2

# 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: "latest-devel"
30 changes: 30 additions & 0 deletions charts/cdl-endpoint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Connected Data Lake instance Helm Chart

## Usage

```bash
# Register the MobileX API repository
helm repo add mobilex "https://smartx-team.github.io/mobilex-api"

# Deploy a Connected Data Lake endpoint instance instance
NAME="object-storage" # NOTE: the name is fixed per namespace!
helm install $NAME "mobilex/cdl-endpoint" \
--namespace "name-twin"
```

## Uninstall

```bash
NAME="object-storage" # NOTE: the name is fixed per namespace!
helm uninstall $NAME --namespace "name-twin"
```

## Validating

```bash
# Install json schema generator
helm plugin install "https://github.com/losisin/helm-values-schema-json.git"

# Create a json schema
helm schema
```
1 change: 1 addition & 0 deletions charts/cdl-endpoint/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Installed!
84 changes: 84 additions & 0 deletions charts/cdl-endpoint/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cdl-endpoint.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 "cdl-endpoint.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 "cdl-endpoint.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "cdl-endpoint.labels" -}}
dash.ulagbulag.io/modelstorage-type: "object-storage"
helm.sh/chart: {{ include "cdl-endpoint.chart" . }}
{{ include "cdl-endpoint.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

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

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

{{/*
Create the name of the clusterrole to use
*/}}
{{- define "cdl-endpoint.clusterRoleName" -}}
{{- printf "dash:cdl-endpoint:%s:%s" .Release.Namespace .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the name of the ingressclass to use
*/}}
{{- define "cdl-endpoint.ingressClassName" -}}
{{- default (printf "dash.%s.%s" .Release.Name .Release.Namespace) .Values.ingressClassNameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the name of the ingress controller to use
*/}}
{{- define "cdl-endpoint.ingressControllerName" -}}
{{- default (printf "k8s.io/dash/%s/%s" .Release.Name .Release.Namespace) .Values.ingressControllerNameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/cdl-endpoint/templates/configmap.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
labels:
{{- include "cdl-endpoint.labels" . | nindent 4 }}
immutable: true
data:
allow-snippet-annotations: "true"
{{- with .Values.ingress.extraConfigs }}
{{- toYaml . | nindent 2 }}
{{- end }}
117 changes: 117 additions & 0 deletions charts/cdl-endpoint/templates/deployment.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{{/*
The release name should be fixed.
*/}}
{{- if not (contains "object-storage" .Release.Name) }}
{{- fail "The helm release name should be \"object-storage\"" }}
{{- end }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}
labels:
{{- include "cdl-endpoint.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "cdl-endpoint.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
prometheus.io/port: "10254"
prometheus.io/scrape: "true"
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "cdl-endpoint.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
affinity:
{{- toYaml .Values.affinity | nindent 8 }}
enableServiceLinks: false
{{- with .Values.image.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
nodeSelector:
{{- toYaml .Values.nodeSelector | nindent 8 }}
priorityClassName: {{ .Values.priorityClassName }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccount: {{ include "cdl-endpoint.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}

containers:
- name: controller
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- "/nginx-ingress-controller"
- "--publish-service=$(POD_NAMESPACE)/{{ .Release.Name }}"
- "--election-id=ingress-nginx-leader"
- "--controller-class={{ include "cdl-endpoint.ingressControllerName" . }}"
- "--ingress-class={{ include "cdl-endpoint.ingressClassName" . }}"
- "--configmap=$(POD_NAMESPACE)/{{ .Release.Name }}"
env:
- name: POD_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: LD_PRELOAD
value: /usr/local/lib/libmimalloc.so
{{- with .Values.env }}
{{- toYaml . | nindent 12 }}
{{- end }}
lifecycle:
preStop:
exec:
command:
- /wait-shutdown
livenessProbe:
failureThreshold: 5
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
ports:
- name: http
protocol: TCP
containerPort: 80
- name: https
protocol: TCP
containerPort: 443
- name: metrics
protocol: TCP
containerPort: 10254
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
readinessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10254
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- toYaml .Values.extraVolumeMounts | nindent 12 }}
volumes:
{{- toYaml .Values.extraVolumes | nindent 8 }}
22 changes: 22 additions & 0 deletions charts/cdl-endpoint/templates/ingress.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}
labels:
{{- include "cdl-endpoint.labels" . | nindent 4 }}
{{- with .Values.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ include "cdl-endpoint.ingressClassName" . }}
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: minio
port:
name: http-minio
9 changes: 9 additions & 0 deletions charts/cdl-endpoint/templates/ingress_class.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: {{ include "cdl-endpoint.ingressClassName" . }}
labels:
{{- include "cdl-endpoint.labels" . | nindent 4 }}
spec:
controller: {{ include "cdl-endpoint.ingressControllerName" . }}
Loading

0 comments on commit 9a3a989

Please sign in to comment.