Skip to content

Commit

Permalink
Merge pull request #1 from truemark/initial-commit
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
d3vb0ox authored Dec 1, 2024
2 parents 799dd95 + 5da4b19 commit 0611103
Show file tree
Hide file tree
Showing 25 changed files with 5,748 additions and 0 deletions.
19 changes: 19 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This project includes code from the following sources:

1. [application](https://github.com/stakater/application)
- Copyright (c) 2023 Stakater
- Licensed under the MIT License. The license for this code can be found in the `k8s-app/LICENSE`.

Additional Notes:

This project is licensed under the following terms:

Copyright (c) 2024, TrueMark Technologies, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of TrueMark Technologies, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 changes: 37 additions & 0 deletions k8s-app/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Ignore editor and IDE files
.vscode/
.idea/
.DS_Store
.AppleDouble
.LSOverride
Icon
._*

# Ignore build artifacts
dist/
build/

# Ignore temporary files
*.tmp
*.bak

# Ignore version control files
.git/
.gitignore

# Ignore documentation files
docs/

# Ignore test files
test/
tests/

# Ignore configuration files
config/
configs/

# Ignore logs
logs/

# Ignore cache files
.cache/
10 changes: 10 additions & 0 deletions k8s-app/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: k8s-app
description: |
This Helm chart is designed to deploy applications on Kubernetes.
type: application
version: 0.0.1
maintainers:
- name: TrueMark DevOps
email: devops@truemark.io
icon: https://www.truemark.io/brand/logo_icon_for_profiles.png
21 changes: 21 additions & 0 deletions k8s-app/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Stakater

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
360 changes: 360 additions & 0 deletions k8s-app/README.md

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions k8s-app/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "k8s-app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Define app version to be used in labels
*/}}
{{- define "k8s-app.version" -}}
{{- $appVersion := default .Chart.Version .Values.deployment.image.tag -}}
{{- regexReplaceAll "[^a-zA-Z0-9_\\.\\-]" $appVersion "-" | trunc 63 | trimSuffix "-" -}}
{{- end }}

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

{{/*
Common labels
*/}}
{{- define "k8s-app.labels" -}}
helm.sh/chart: {{ include "k8s-app.chart" . }}
{{ include "k8s-app.selectorLabels" . }}
{{- with include "k8s-app.version" . }}
app.kubernetes.io/version: {{ . | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: {{ .Values.partOfOverride | default (include "k8s-app.name" .) }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "k8s-app.selectorLabels" -}}
app.kubernetes.io/name: {{ include "k8s-app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: {{ .Values.componentOverride | default (include "k8s-app.name" .) }}
{{- end }}

{{/*
Renders a value that contains template.
Usage:
{{ include "k8s-app.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }}
*/}}
{{- define "k8s-app.tplvalues.render" -}}
{{- if typeIs "string" .value }}
{{- tpl .value .context }}
{{- else }}
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
174 changes: 174 additions & 0 deletions k8s-app/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{{- define "k8s-app.podTemplate" }}
metadata:
labels:
{{- include "k8s-app.selectorLabels" . | nindent 8 }}
{{- if .Values.deployment.additionalPodLabels }}
{{- toYaml .Values.deployment.additionalPodLabels | nindent 8 }}
{{- end }}
{{- if .Values.deployment.disableIstioInject }}
sidecar.istio.io/inject: "false"
{{- end }}
{{- if .Values.deployment.additionalPodAnnotations }}
annotations:
{{- toYaml .Values.deployment.additionalPodAnnotations | nindent 8 }}
{{- end }}
spec:
{{- if .Values.deployment.hostAliases }}
hostAliases:
{{- toYaml .Values.deployment.hostAliases | nindent 6 }}
{{- end }}
{{- if .Values.deployment.initContainers }}
initContainers:
{{- range $key, $value := .Values.deployment.initContainers }}
- name: {{ $key }}
{{- include "k8s-app.tplvalues.render" ( dict "value" $value "context" $ ) | nindent 10 }}
{{- end }}
{{- end }}
{{- with .Values.deployment.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.deployment.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.deployment.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.deployment.hostNetwork }}
hostNetwork: true
{{- end }}
{{- if .Values.rbac.serviceAccount.enabled }}
{{- if .Values.rbac.serviceAccount.name }}
serviceAccountName: {{ .Values.rbac.serviceAccount.name }}
{{- else }}
serviceAccountName: {{ template "k8s-app.name" $ }}
{{- end }}
{{- end }}
{{- if .Values.deployment.securityContext }}
securityContext:
{{ toYaml .Values.deployment.securityContext | indent 8 }}
{{- end }}
{{- if .Values.deployment.dnsConfig }}
dnsConfig:
{{- toYaml .Values.deployment.dnsConfig | nindent 8 }}
{{- end }}
terminationGracePeriodSeconds: {{ .Values.deployment.terminationGracePeriodSeconds }}
{{- if or (.Values.deployment.volumes) (and (eq .Values.persistence.enabled true) (eq .Values.persistence.mountPVC true) )}}
volumes:
{{- if (eq .Values.persistence.mountPVC true) }}
- name: {{ template "k8s-app.name" . }}-data
persistentVolumeClaim:
{{- if .Values.persistence.name }}
claimName: {{ .Values.persistence.name }}
{{- else }}
claimName: {{ template "k8s-app.name" . }}-data
{{- end }}
{{- end }}
{{- if .Values.deployment.volumes }}
{{- range $key, $value := .Values.deployment.volumes }}
- name: {{ $key }}
{{- include "k8s-app.tplvalues.render" ( dict "value" $value "context" $ ) | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: {{ template "k8s-app.name" . }}
image: "{{ .Values.deployment.image.repository }}{{ if .Values.deployment.image.tag }}:{{ .Values.deployment.image.tag }}{{ else }}@{{ .Values.deployment.image.digest }}{{ end }}"
imagePullPolicy: {{ .Values.deployment.image.pullPolicy }}
{{- with .Values.deployment.command }}
command:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.deployment.args }}
args:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.deployment.ports }}
ports:
{{- $hostNetwork := .Values.deployment.hostNetwork }}
{{- range $name, $config := .Values.deployment.ports }}
{{- if $config }}
{{- if and $hostNetwork (and $config.hostPort $config.port) }}
{{- if ne ($config.hostPort | int) ($config.port | int) }}
{{- fail "ERROR: All hostPort must match their respective containerPort when `hostNetwork` is enabled" }}
{{- end }}
{{- end }}
- name: {{ $name | quote }}
containerPort: {{ default $config.port $config.containerPort }}
{{- if $config.hostPort }}
hostPort: {{ $config.hostPort }}
{{- end }}
protocol: {{ default "TCP" $config.protocol | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.deployment.envFrom }}
envFrom:
{{- range $value := .Values.deployment.envFrom }}
{{- if (eq .type "configmap") }}
- configMapRef:
{{- if .name }}
name: {{ include "k8s-app.tplvalues.render" ( dict "value" $value.name "context" $ ) }}
{{- else if .nameSuffix }}
name: {{ template "k8s-app.name" $ }}-{{ include "k8s-app.tplvalues.render" ( dict "value" $value.nameSuffix "context" $ ) }}
{{- else }}
name: {{ template "k8s-app.name" $ }}
{{- end }}
{{- end }}
{{- if (eq .type "secret") }}
- secretRef:
{{- if .name }}
name: {{ include "k8s-app.tplvalues.render" ( dict "value" $value.name "context" $ ) }}
{{- else if .nameSuffix }}
name: {{ template "k8s-app.name" $ }}-{{ include "k8s-app.tplvalues.render" ( dict "value" $value.nameSuffix "context" $ ) }}
{{- else }}
name: {{ template "k8s-app.name" $ }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.deployment.env }}
env:
{{- range $key, $value := .Values.deployment.env }}
- name: {{ include "k8s-app.tplvalues.render" ( dict "value" $key "context" $ ) }}
{{- include "k8s-app.tplvalues.render" ( dict "value" $value "context" $ ) | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.deployment.probes }}
{{- if .livenessProbe }}
livenessProbe:
{{- toYaml .livenessProbe | nindent 12 }}
{{- end }}
{{- if .readinessProbe }}
readinessProbe:
{{- toYaml .readinessProbe | nindent 12 }}
{{- end }}
{{- if .startupProbe }}
startupProbe:
{{- toYaml .startupProbe | nindent 12 }}
{{- end }}
{{- end }}
{{- if or (.Values.deployment.volumeMounts) (and (eq .Values.persistence.enabled true) (eq .Values.persistence.mountPVC true) )}}
volumeMounts:
{{- if (eq .Values.persistence.mountPVC true) }}
- mountPath: {{ .Values.persistence.mountPath }}
name: {{ template "application.name" . }}-data
{{- end }}
{{- if .Values.deployment.volumeMounts }}
{{- range $key, $value := .Values.deployment.volumeMounts }}
- name: {{ $key }}
{{- include "k8s-app.tplvalues.render" ( dict "value" $value "context" $ ) | nindent 12 }}
{{- end }}
{{- end }}
{{- end }}
{{ end -}}
Empty file.
Loading

0 comments on commit 0611103

Please sign in to comment.