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

[GENERIC] Add a generic chart to deploy simple containers #35

Open
wants to merge 2 commits into
base: main
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
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- create-generic-helm-chart

jobs:
release:
Expand Down
4 changes: 4 additions & 0 deletions charts/generic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: generic
type: application
version: 0.0.1-devel
4 changes: 4 additions & 0 deletions charts/generic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- define "custom.labels" -}}
app: {{ .name }}
version: {{ .image.tag }}
{{- end -}}
131 changes: 131 additions & 0 deletions charts/generic/templates/_stack.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{{- define "custom.stack" -}}
{{- if .Values.components }}
{{- range $key, $component := .Values.components }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $component.name }}
namespace: {{ $.Release.Namespace | quote }}
labels:
{{ include "custom.labels" $component | indent 4 }}
spec:
replicas: {{ $component.replicas }}
{{- if hasKey $component.strategy "type" }}
strategy:
type: {{ $component.strategy.type }}
{{ end -}}
selector:
matchLabels:
{{ include "custom.labels" $component | indent 6 }}
template:
metadata:
labels:
{{ include "custom.labels" $component | indent 8 }}
spec:
{{- if $component.securityContext }}
securityContext:
{{ toYaml $component.securityContext | indent 8 }}
{{- end }}
{{ if $component.volumes -}}
volumes:
{{ toYaml $component.volumes | indent 8 }}
{{ end -}}
{{- if $component.initContainers }}
initContainers:
{{ toYaml $component.initContainers | indent 8 }}
{{- end }}
containers:
- name: {{ $component.name }}
{{- if $component.env }}
env:
{{ toYaml $component.env | indent 12 }}
{{ end -}}
{{- if $component.args -}}
args:
{{ toYaml $component.args | indent 12 }}
{{- end }}
{{ if $component.command -}}
command:
{{ toYaml $component.command | indent 12 }}
{{- end }}
{{ if $component.resources -}}
resources:
{{ toYaml $component.resources | indent 12 }}
{{- end -}}
{{- if $component.volumeMounts }}
volumeMounts:
{{ toYaml $component.volumeMounts | indent 12 }}
{{ end -}}
imagePullPolicy: {{ $component.image.pullPolicy }}
image: {{ $component.image.repository }}:{{ $component.image.tag }}
{{- with $component.ports }}
ports:
{{- range $key, $port := $component.ports }}
- containerPort: {{ $port.port }}
{{- end }}
{{- end }}
{{- if $component.sidecars }}
{{ toYaml $component.sidecars | indent 8 }}
{{ end }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $component.name }}
namespace: {{ $.Release.Namespace | quote }}
labels:
{{ include "custom.labels" $component | indent 4 }}
spec:
selector:
{{ include "custom.labels" $component | indent 4 }}
ports:
{{- range $key, $port := $component.ports }}
- protocol: TCP
port: {{ $port.port }}
targetPort: {{ $port.port }}
{{ end }}
---
{{- range $key, $port := $component.ports }}
{{ if $port.ingress }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
{{- if $port.ingress.annotations }}
annotations:
{{ toYaml $port.ingress.annotations | indent 4 }}
{{- end }}
name: {{ $component.name }}-{{ $port.port }}
namespace: {{ $.Release.Namespace | quote }}
labels:
{{ include "custom.labels" $component | indent 4 }}
spec:
ingressClassName: {{ $port.ingress.ingressClass | default "nginx" }}
{{- range $key2, $port2 := $component.ports }}
rules:
{{- if $port2.ingress }}
- host: {{ $port2.ingress.host }}
http:
paths:
- pathType: Prefix
path: {{ $port2.ingress.path | default "/" }}
backend:
service:
name: {{ $component.name }}
port:
number: {{ $port2.port }}
{{- end -}}
{{- end -}}
{{- range $key2, $port2 := $component.ports }}
tls:
{{- if $port2.ingress.tls }}
- hosts:
- {{ $port2.ingress.host }}
secretName: {{ $component.name }}-{{ $port2.port }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{- end -}}
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions charts/generic/templates/stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ include "custom.stack" . }}
49 changes: 49 additions & 0 deletions charts/generic/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
components:
- name: languagetool
command:
- bash
args:
- bash
- scripts/start.sh
env:
- name: toto
value: tutu
replicas: 3
securityContext:
runAsUser: 1000
fsGroup: 1000
sidecars:
- name: goofys
image: goofys
initContainers:
- name: ubuntu
image: ubuntu
strategy:
type: Recreate
volumes:
- name: config-vol
configMap:
name: log-config
items:
- key: log_level
path: log_leve
volumeMounts:
- name: config-vol
mountPath: /etc/config
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
ports:
- port: 8010
ingress:
annotations:
cert-manager.io/cluster-issuer: demo
host: toto.exemple.com
tls: true
image:
repository: erikvl87/languagetool
tag: latest
pullPolicy: IfNotPresent
Loading