Skip to content

Commit

Permalink
Add initial helm chart (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
rblaine95 authored Nov 10, 2023
1 parent e0d0610 commit 79dc4b0
Show file tree
Hide file tree
Showing 12 changed files with 395 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ project/project
.config
DID_Me

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode
# Created by https://www.toptal.com/developers/gitignore/api/helm,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=helm,visualstudiocode

### Helm ###
# Chart dependencies
**/charts/*.tgz

### VisualStudioCode ###
.vscode/*
Expand All @@ -52,4 +56,4 @@ DID_Me
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode
# End of https://www.toptal.com/developers/gitignore/api/helm,visualstudiocode
23 changes: 23 additions & 0 deletions helm/dawn-patrol/.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/
6 changes: 6 additions & 0 deletions helm/dawn-patrol/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.13.3
digest: sha256:a644d1db2f5945323d6ea7c472e2b61d6667452d160558e3c0d57eadf8dffdf2
generated: "2023-11-07T13:52:58.386511+02:00"
17 changes: 17 additions & 0 deletions helm/dawn-patrol/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: dawn-patrol
description: A Helm chart to deploy DawnPatrol on Kubernetes

sources:
- https://github.com/didx-xyz/dawn-patrol

type: application

version: 0.1.0
appVersion: latest

dependencies:
# https://github.com/bitnami/charts/tree/main/bitnami/common
- name: common
version: 2.13.3
repository: oci://registry-1.docker.io/bitnamicharts
Empty file.
62 changes: 62 additions & 0 deletions helm/dawn-patrol/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dawn-patrol.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 "dawn-patrol.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 "dawn-patrol.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "dawn-patrol.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "dawn-patrol.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
79 changes: 79 additions & 0 deletions helm/dawn-patrol/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "dawn-patrol.fullname" . }}
labels:
{{- include "dawn-patrol.labels" . | nindent 4 }}
{{- with .Values.deploymentLabels }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "dawn-patrol.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
labels:
{{- include "dawn-patrol.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "dawn-patrol.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: dawn-patrol
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- secretRef:
name: {{ include "dawn-patrol.fullname" . }}
{{- with .Values.extraEnv }}
env:
{{- range $k,$v := . }}
- name: {{ $k }}
{{- $type := printf "%s" (typeOf $v) }}
{{- if or (eq $type "string") (eq $type "float64") (eq $type "bool") }}
value: {{ tpl (toString $v) $ | quote }}
{{- else }}
{{- tpl (toYaml $v) $ | nindent 14 }}
{{- end }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
32 changes: 32 additions & 0 deletions helm/dawn-patrol/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "dawn-patrol.fullname" . }}
labels:
{{- include "dawn-patrol.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "dawn-patrol.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions helm/dawn-patrol/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "dawn-patrol.fullname" . }}
labels:
{{- include "dawn-patrol.labels" . | nindent 4 }}
stringData:
{{- range $k,$v := .Values.secretEnv }}
{{ $k }}: {{ tpl (toString $v) $ | quote }}
{{- end }}
13 changes: 13 additions & 0 deletions helm/dawn-patrol/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "dawn-patrol.serviceAccountName" . }}
labels:
{{- include "dawn-patrol.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
104 changes: 104 additions & 0 deletions helm/dawn-patrol/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Default values for dawn-patrol.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

nameOverride: ""
fullnameOverride: ""

image:
repository: ghcr.io/didx-xyz/dawn-patrol
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: latest

imagePullSecrets: []

serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

deploymentLabels:
# tags.datadoghq.com/env: <env>
tags.datadoghq.com/service: '{{ include "dawn-patrol.fullname" . }}'
tags.datadoghq.com/version: '{{ .Values.image.tag }}'
podAnnotations:
# gcr.io/datadoghq/dd-lib-java-init
admission.datadoghq.com/java-lib.version: v1.22.0
podLabels:
# tags.datadoghq.com/env: <env>
tags.datadoghq.com/service: '{{ include "dawn-patrol.fullname" . }}'
tags.datadoghq.com/version: '{{ .Values.image.tag }}'
admission.datadoghq.com/enabled: 'false'

podSecurityContext:
fsGroup: 1000

securityContext:
# readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
# capabilities:
# drop:
# - ALL

extraEnv:
DD_LOGS_INJECTION: true
# DD_TRACE_SAMPLE_RATE: 1
DD_PROFILING_ENABLED: false
DD_RUNTIME_METRICS_ENABLED: true
DD_APPSEC_ENABLED: false
DD_IAST_ENABLED: false
# FOO: bar
# MY_POD_IP:
# valueFrom:
# metadata:
# name: status.podIP
# fieldPath: status.podIP
secretEnv:
HF_API_KEY: ""
OPENAI_TOKEN: ""

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# requests:
# cpu: 100m
# memory: 128Mi
# limits:
# cpu: 100m
# memory: 128Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false

# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true

nodeSelector: {}
tolerations: []
affinity: {}
Loading

0 comments on commit 79dc4b0

Please sign in to comment.