Skip to content

Commit 4aaeeaf

Browse files
committed
Add ai-model workload
Signed-off-by: Jeroen van Erp <[email protected]>
1 parent 707c7a7 commit 4aaeeaf

File tree

7 files changed

+199
-0
lines changed

7 files changed

+199
-0
lines changed

charts/ai-model/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
name: ai-model
3+
description: A Helm chart for ai-model Mackroservices
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"
7+
keywords:
8+
- challenge
9+
- observability
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "common.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "common.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "common.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "common.labels" -}}
37+
helm.sh/chart: {{ include "common.chart" . }}
38+
{{ include "common.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "common.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "common.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "common.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "common.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: ai-model-cm
5+
labels:
6+
{{- include "common.labels" . | nindent 4 }}
7+
data:
8+
config.toml: |
9+
# General configuration
10+
port = 11434
11+
address = "0.0.0.0"
12+
serviceName = "AI Model"
13+
logLevel = "info"
14+
15+
# Endpoints
16+
[[endpoints]]
17+
uri = "/api/chat"
18+
delay = "1000ms"
19+
body.status = "success"
20+
body.msg = "Your dino is a T-Rex"
21+
22+
[endpoints.logging]
23+
before = "Processing [[.Endpoint.Uri]] request"
24+
beforeLevel = "Info"
25+
after = "Completed [[.Endpoint.Uri]] request"
26+
afterLevel = "Info"
27+
28+
# OpenTelemetry
29+
[otel.trace]
30+
enabled = false
31+
tracer-name = "ai-model"
32+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: ai-model
5+
labels:
6+
service: ai-model
7+
{{- include "common.labels" . | nindent 4 }}
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
service: ai-model
13+
{{- include "common.selectorLabels" . | nindent 6 }}
14+
template:
15+
metadata:
16+
labels:
17+
{{- include "common.labels" . | nindent 8 }}
18+
service: ai-model
19+
annotations:
20+
checksum/config: '{{ include (print $.Template.BasePath "/ai-model-cm.yaml") . | sha256sum}}'
21+
spec:
22+
containers:
23+
- name: ai-model
24+
image: {{.Values.image}}
25+
env:
26+
- name: CONFIG_FILE
27+
value: /etc/app/config.toml
28+
ports:
29+
- containerPort: 8080
30+
resources:
31+
{{- toYaml .Values.resources | nindent 12 }}
32+
volumeMounts:
33+
- name: config-volume
34+
mountPath: /etc/app
35+
volumes:
36+
- name: config-volume
37+
configMap:
38+
name: ai-model-cm
39+
items:
40+
- key: config.toml
41+
path: config.toml
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
annotations:
5+
cert-manager.io/cluster-issuer: letsencrypt-prod
6+
nginx.ingress.kubernetes.io/proxy-body-size: 50m
7+
labels:
8+
service: ai-model
9+
{{- include "common.labels" . | nindent 4 }}
10+
name: ai-model
11+
spec:
12+
ingressClassName: traefik
13+
rules:
14+
- host: {{ .Values.ingress.host }}
15+
http:
16+
paths:
17+
- backend:
18+
service:
19+
name: ai-model
20+
port:
21+
number: 11434
22+
path: /
23+
pathType: Prefix
24+
tls:
25+
- hosts:
26+
- {{ .Values.ingress.host }}
27+
secretName: tls-secret
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: ai-model
5+
labels:
6+
service: ai-model
7+
{{- include "common.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
service: ai-model
11+
{{- include "common.selectorLabels" . | nindent 4 }}
12+
ports:
13+
- protocol: TCP
14+
port: 80 # Service port
15+
targetPort: 8080 # Container port
16+
type: ClusterIP # Internal service within the Kubernetes cluster

charts/ai-model/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
nameOverride: ''
2+
fullnameOverride: ''
3+
image: ravan/mockroservice:0.0.23
4+
resources:
5+
requests:
6+
memory: '8Mi'
7+
cpu: '5m'
8+
limits:
9+
memory: '10Mi'
10+
cpu: '10m'
11+
ingress:
12+
host:

0 commit comments

Comments
 (0)