Skip to content

Commit 0685f3c

Browse files
added helm chart
1 parent 7c13c94 commit 0685f3c

File tree

11 files changed

+512
-0
lines changed

11 files changed

+512
-0
lines changed

k8s/helm/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

k8s/helm/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: mcp-victorialogs
3+
description: A Helm chart for VictoriaLogs MCP server
4+
type: application
5+
version: 0.1.0
6+
appVersion: 1.5.0

k8s/helm/templates/NOTES.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.route.enabled }}
3+
{{- if .Values.route.hostnames }}
4+
export APP_HOSTNAME={{ .Values.route.hostnames | first }}
5+
{{- else }}
6+
export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.route.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.route.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}")
7+
{{- end }}
8+
{{- if and .Values.route.rules (first .Values.route.rules).matches (first (first .Values.route.rules).matches).path.value }}
9+
echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.route.rules).matches).path.value }} to use your application"
10+
11+
NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules.
12+
The rules can be set for path, method, header and query parameters.
13+
You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.route.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.route.parentRefs).name }} -o yaml'
14+
{{- end }}
15+
{{- else if .Values.ingress.enabled }}
16+
{{- range $host := .Values.ingress.hosts }}
17+
{{- range .paths }}
18+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
19+
{{- end }}
20+
{{- end }}
21+
{{- else if contains "NodePort" .Values.service.type }}
22+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "mcp-victorialogs.fullname" . }})
23+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
24+
echo http://$NODE_IP:$NODE_PORT
25+
{{- else if contains "LoadBalancer" .Values.service.type }}
26+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
27+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "mcp-victorialogs.fullname" . }}'
28+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "mcp-victorialogs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
29+
echo http://$SERVICE_IP:{{ .Values.service.port }}
30+
{{- else if contains "ClusterIP" .Values.service.type }}
31+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "mcp-victorialogs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
32+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
33+
echo "Visit http://127.0.0.1:8080 to use your application"
34+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
35+
{{- end }}

k8s/helm/templates/_helpers.tpl

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 "mcp-victorialogs.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 "mcp-victorialogs.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 "mcp-victorialogs.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "mcp-victorialogs.labels" -}}
37+
helm.sh/chart: {{ include "mcp-victorialogs.chart" . }}
38+
{{ include "mcp-victorialogs.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 "mcp-victorialogs.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "mcp-victorialogs.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 "mcp-victorialogs.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "mcp-victorialogs.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

k8s/helm/templates/deployment.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "mcp-victorialogs.fullname" . }}
5+
labels: {{ include "mcp-victorialogs.labels" . | nindent 4 }}
6+
spec:
7+
replicas: {{ .Values.replicaCount }}
8+
selector:
9+
matchLabels: {{ include "mcp-victorialogs.selectorLabels" . | nindent 6 }}
10+
template:
11+
metadata:
12+
{{- with .Values.podAnnotations }}
13+
annotations: {{ toYaml . | nindent 8 }}
14+
{{- end }}
15+
labels:
16+
{{- include "mcp-victorialogs.labels" . | nindent 8 }}
17+
{{- with .Values.podLabels }}
18+
{{- toYaml . | nindent 8 }}
19+
{{- end }}
20+
spec:
21+
{{- with .Values.imagePullSecrets }}
22+
imagePullSecrets: {{ toYaml . | nindent 8 }}
23+
{{- end }}
24+
serviceAccountName: {{ include "mcp-victorialogs.serviceAccountName" . }}
25+
{{- with .Values.podSecurityContext }}
26+
securityContext: {{ toYaml . | nindent 8 }}
27+
{{- end }}
28+
containers:
29+
- name: {{ .Chart.Name }}
30+
{{- with .Values.securityContext }}
31+
securityContext: {{ toYaml . | nindent 12 }}
32+
{{- end }}
33+
{{- $repo := .Values.image.repository }}
34+
{{- with .Values.image.registry }}
35+
{{- $repo = printf "%s/%s" . $repo }}
36+
{{- end }}
37+
image: "{{ $repo }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
38+
imagePullPolicy: {{ .Values.image.pullPolicy }}
39+
env:
40+
- name: MCP_LISTEN_ADDR
41+
value: "0.0.0.0:{{ .Values.service.port }}"
42+
- name: MCP_SERVER_MODE
43+
value: "{{ .Values.mcp.mode }}"
44+
- name: VL_INSTANCE_ENTRYPOINT
45+
value: "{{ required ".Values.vl.entrypoint should be set" .Values.vl.entrypoint }}"
46+
{{- with .Values.vl.bearerToken }}
47+
- name: VL_INSTANCE_BEARER_TOKEN
48+
{{- if kindIs "map" . }}
49+
valueFrom: {{ toYaml . | nindent 16 }}
50+
{{- else }}
51+
value: "{{ . }}"
52+
{{- end }}
53+
{{- end }}
54+
{{- with .Values.vl.headers }}
55+
- name: VL_INSTANCE_HEADERS
56+
value: "{{ join "," . }}"
57+
{{- end }}
58+
{{- with .Values.mcp.disable.resources }}
59+
- name: MCP_DISABLE_RESOURCES
60+
value: "{{ . }}"
61+
{{- end }}
62+
{{- with .Values.mcp.disable.tools }}
63+
- name: MCP_DISABLED_TOOLS
64+
value: "{{ join "," . }}"
65+
{{- end }}
66+
{{- with .Values.mcp.heartbeatInterval }}
67+
- name: MCP_HEARTBEAT_INTERVAL
68+
value: "{{ . }}"
69+
{{- end }}
70+
{{- with .Values.env }}
71+
{{- toYaml . | nindent 12 }}
72+
{{- end }}
73+
ports:
74+
- name: http
75+
containerPort: {{ .Values.service.port }}
76+
protocol: TCP
77+
{{- with .Values.livenessProbe }}
78+
livenessProbe: {{ toYaml . | nindent 12 }}
79+
{{- end }}
80+
{{- with .Values.readinessProbe }}
81+
readinessProbe: {{ toYaml . | nindent 12 }}
82+
{{- end }}
83+
{{- with .Values.resources }}
84+
resources: {{ toYaml . | nindent 12 }}
85+
{{- end }}
86+
{{- with .Values.volumeMounts }}
87+
volumeMounts: {{ toYaml . | nindent 12 }}
88+
{{- end }}
89+
{{- with .Values.volumes }}
90+
volumes: {{ toYaml . | nindent 8 }}
91+
{{- end }}
92+
{{- with .Values.nodeSelector }}
93+
nodeSelector: {{ toYaml . | nindent 8 }}
94+
{{- end }}
95+
{{- with .Values.affinity }}
96+
affinity: {{ toYaml . | nindent 8 }}
97+
{{- end }}
98+
{{- with .Values.tolerations }}
99+
tolerations: {{ toYaml . | nindent 8 }}
100+
{{- end }}

k8s/helm/templates/ingress.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "mcp-victorialogs.fullname" . }}
6+
labels: {{ include "mcp-victorialogs.labels" . | nindent 4 }}
7+
{{- with .Values.ingress.annotations }}
8+
annotations: {{ toYaml . | nindent 4 }}
9+
{{- end }}
10+
spec:
11+
{{- with .Values.ingress.className }}
12+
ingressClassName: {{ . }}
13+
{{- end }}
14+
{{- if .Values.ingress.tls }}
15+
tls:
16+
{{- range .Values.ingress.tls }}
17+
- hosts:
18+
{{- range .hosts }}
19+
- {{ . | quote }}
20+
{{- end }}
21+
secretName: {{ .secretName }}
22+
{{- end }}
23+
{{- end }}
24+
rules:
25+
{{- range .Values.ingress.hosts }}
26+
- host: {{ .host | quote }}
27+
http:
28+
paths:
29+
{{- range .paths }}
30+
- path: {{ .path }}
31+
{{- with .pathType }}
32+
pathType: {{ . }}
33+
{{- end }}
34+
backend:
35+
service:
36+
name: {{ include "mcp-victorialogs.fullname" $ }}
37+
port:
38+
number: {{ $.Values.service.port }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}

k8s/helm/templates/route.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Values.route.enabled -}}
2+
{{- $fullName := include "mcp-victorialogs.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: gateway.networking.k8s.io/v1
5+
kind: HTTPRoute
6+
metadata:
7+
name: {{ $fullName }}
8+
labels: {{ include "mcp-victorialogs.labels" . | nindent 4 }}
9+
{{- with .Values.route.annotations }}
10+
annotations: {{ toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
parentRefs:
14+
{{- with .Values.route.parentRefs }}
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
{{- with .Values.route.hostnames }}
18+
hostnames: {{ toYaml . | nindent 4 }}
19+
{{- end }}
20+
rules:
21+
{{- range .Values.route.rules }}
22+
{{- with .matches }}
23+
- matches: {{ toYaml . | nindent 8 }}
24+
{{- end }}
25+
{{- with .filters }}
26+
filters: {{ toYaml . | nindent 8 }}
27+
{{- end }}
28+
backendRefs:
29+
- name: {{ $fullName }}
30+
port: {{ $svcPort }}
31+
weight: 1
32+
{{- end }}
33+
{{- end }}

k8s/helm/templates/scrape.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.scrape.enabled }}
2+
---
3+
apiVersion: operator.victorialogs.com/v1beta1
4+
kind: VMServiceScrape
5+
metadata:
6+
labels: {{ include "mcp-victorialogs.labels" . | nindent 4 }}
7+
name: {{ include "mcp-victorialogs.fullname" . }}
8+
spec:
9+
endpoints:
10+
- path: /metrics
11+
port: http
12+
namespaceSelector: { }
13+
selector:
14+
matchLabels: {{ include "mcp-victorialogs.labels" . | nindent 6 }}
15+
{{- end }}

k8s/helm/templates/service.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "mcp-victorialogs.fullname" . }}
5+
labels: {{ include "mcp-victorialogs.labels" . | nindent 4 }}
6+
spec:
7+
type: {{ .Values.service.type }}
8+
ports:
9+
- port: {{ .Values.service.port }}
10+
targetPort: http
11+
protocol: TCP
12+
name: http
13+
selector: {{ include "mcp-victorialogs.selectorLabels" . | nindent 4 }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "mcp-victorialogs.serviceAccountName" . }}
6+
labels:
7+
{{- include "mcp-victorialogs.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

0 commit comments

Comments
 (0)