Skip to content
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
3 changes: 3 additions & 0 deletions deploy/helm/trendradar/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files/
*.md
.gitkeep
16 changes: 16 additions & 0 deletions deploy/helm/trendradar/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v2
name: trendradar
description: TrendRadar - 多平台热点聚合与 AI 分析工具 (Helm Chart for k3s/k8s)
type: application
version: 1.0.0
appVersion: "latest"
keywords:
- trendradar
- hot-list
- news-aggregator
- ai-analysis
home: https://github.com/sansan0/TrendRadar
sources:
- https://github.com/sansan0/TrendRadar
maintainers:
- name: trendradar-community
Empty file.
37 changes: 37 additions & 0 deletions deploy/helm/trendradar/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
TrendRadar 已安装!

{{- if eq .Values.runMode "cron" }}

📡 Web 报告访问:
Port-Forward: kubectl port-forward svc/{{ include "trendradar.fullname" . }} {{ .Values.webserver.port }}:{{ .Values.webserver.service.port }}
浏览器访问: http://localhost:{{ .Values.webserver.port }}

{{- if eq .Values.webserver.service.type "NodePort" }}
NodePort: http://<NODE_IP>:{{ .Values.webserver.service.nodePort }}
{{- end }}

{{- if and .Values.ingress.enabled (len .Values.ingress.hosts) }}
Ingress: http://{{ (index .Values.ingress.hosts 0).host }}
{{- end }}

⏰ 定时任务: {{ .Values.cronSchedule }}

{{- end }}

{{- if .Values.mcp.enabled }}

🤖 MCP 服务:
Port-Forward: kubectl port-forward svc/{{ include "trendradar.mcp.fullname" . }} {{ .Values.mcp.port }}:{{ .Values.mcp.service.port }}
MCP 地址: http://localhost:{{ .Values.mcp.port }}

{{- end }}

📋 常用命令:
查看日志: kubectl logs -f deployment/{{ include "trendradar.fullname" . }}
查看状态: kubectl get pods -l app.kubernetes.io/instance={{ .Release.Name }}
手动执行: kubectl exec deployment/{{ include "trendradar.fullname" . }} -- python -m trendradar
升级版本: helm upgrade {{ .Release.Name }} deploy/helm/trendradar --set image.tag=vX.Y.Z

⚠️ 首次部署须知:
确保 config/ 目录已准备就绪 (包含 config.yaml 和 frequency_words.txt)。
hostPath 模式: sudo cp -r config/* {{ .Values.persistence.config.hostPath.path }}/
86 changes: 86 additions & 0 deletions deploy/helm/trendradar/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{/*
Chart 名称
*/}}
{{- define "trendradar.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
全限定名 (release-name-chart-name)
*/}}
{{- define "trendradar.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 }}

{{/*
Chart 版本标签
*/}}
{{- define "trendradar.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
公共标签
*/}}
{{- define "trendradar.labels" -}}
helm.sh/chart: {{ include "trendradar.chart" . }}
{{ include "trendradar.selectorLabels" . }}
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
选择器标签
*/}}
{{- define "trendradar.selectorLabels" -}}
app.kubernetes.io/name: {{ include "trendradar.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
MCP 全限定名
*/}}
{{- define "trendradar.mcp.fullname" -}}
{{- printf "%s-mcp" (include "trendradar.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
MCP 选择器标签
*/}}
{{- define "trendradar.mcp.selectorLabels" -}}
app.kubernetes.io/name: {{ include "trendradar.name" . }}-mcp
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
MCP 公共标签
*/}}
{{- define "trendradar.mcp.labels" -}}
helm.sh/chart: {{ include "trendradar.chart" . }}
{{ include "trendradar.mcp.selectorLabels" . }}
app.kubernetes.io/version: {{ .Values.imageMcp.tag | default .Chart.AppVersion | quote }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Config 卷名
*/}}
{{- define "trendradar.configVolumeName" -}}
{{- printf "%s-config" (include "trendradar.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Output 卷名
*/}}
{{- define "trendradar.outputVolumeName" -}}
{{- printf "%s-output" (include "trendradar.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
21 changes: 21 additions & 0 deletions deploy/helm/trendradar/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "trendradar.fullname" . }}
labels:
{{- include "trendradar.labels" . | nindent 4 }}
data:
TZ: {{ .Values.timezone | quote }}
RUN_MODE: {{ .Values.runMode | quote }}
CRON_SCHEDULE: {{ .Values.cronSchedule | quote }}
IMMEDIATE_RUN: {{ .Values.immediateRun | quote }}
WEBSERVER_PORT: {{ .Values.webserver.port | quote }}
{{- if .Values.schedule.enabled }}
SCHEDULE_ENABLED: {{ .Values.schedule.enabled | quote }}
{{- end }}
{{- if .Values.schedule.preset }}
SCHEDULE_PRESET: {{ .Values.schedule.preset | quote }}
{{- end }}
{{- if .Values.reportMode }}
REPORT_MODE: {{ .Values.reportMode | quote }}
{{- end }}
112 changes: 112 additions & 0 deletions deploy/helm/trendradar/templates/deployment-mcp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{{- if .Values.mcp.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "trendradar.mcp.fullname" . }}
labels:
{{- include "trendradar.mcp.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "trendradar.mcp.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "trendradar.mcp.selectorLabels" . | nindent 8 }}
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: mcp
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.imageMcp.repository }}:{{ .Values.imageMcp.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.imageMcp.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "trendradar.fullname" . }}
- secretRef:
name: {{ include "trendradar.fullname" . }}
env:
- name: MCP_PORT
value: {{ .Values.mcp.port | quote }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: mcp
containerPort: {{ .Values.mcp.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: mcp
initialDelaySeconds: 15
periodSeconds: 30
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: mcp
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
volumeMounts:
- name: config
mountPath: /app/config
readOnly: true
- name: output
mountPath: /app/output
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.mcpResources | nindent 12 }}
volumes:
- name: config
{{- if and .Values.persistence.config.enabled (eq .Values.persistence.config.type "pvc") }}
persistentVolumeClaim:
claimName: {{ include "trendradar.fullname" . }}-config
{{- else if .Values.persistence.config.enabled }}
hostPath:
path: {{ .Values.persistence.config.hostPath.path }}
type: DirectoryOrCreate
{{- else }}
emptyDir: {}
{{- end }}
- name: output
{{- if and .Values.persistence.output.enabled (eq .Values.persistence.output.type "pvc") }}
persistentVolumeClaim:
claimName: {{ include "trendradar.fullname" . }}-output
{{- else if .Values.persistence.output.enabled }}
hostPath:
path: {{ .Values.persistence.output.hostPath.path }}
type: DirectoryOrCreate
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.extraVolumes }}
{{- 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 }}
{{- end }}
111 changes: 111 additions & 0 deletions deploy/helm/trendradar/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "trendradar.fullname" . }}
labels:
{{- include "trendradar.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "trendradar.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "trendradar.selectorLabels" . | nindent 8 }}
annotations:
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "trendradar.fullname" . }}
- secretRef:
name: {{ include "trendradar.fullname" . }}
env:
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.webserver.port }}
protocol: TCP
{{- if eq .Values.runMode "cron" }}
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 60
periodSeconds: 60
timeoutSeconds: 5
failureThreshold: 5
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: 30
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 6
{{- end }}
volumeMounts:
- name: config
mountPath: /app/config
readOnly: true
- name: output
mountPath: /app/output
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: config
{{- if and .Values.persistence.config.enabled (eq .Values.persistence.config.type "pvc") }}
persistentVolumeClaim:
claimName: {{ include "trendradar.fullname" . }}-config
{{- else if .Values.persistence.config.enabled }}
hostPath:
path: {{ .Values.persistence.config.hostPath.path }}
type: DirectoryOrCreate
{{- else }}
emptyDir: {}
{{- end }}
- name: output
{{- if and .Values.persistence.output.enabled (eq .Values.persistence.output.type "pvc") }}
persistentVolumeClaim:
claimName: {{ include "trendradar.fullname" . }}-output
{{- else if .Values.persistence.output.enabled }}
hostPath:
path: {{ .Values.persistence.output.hostPath.path }}
type: DirectoryOrCreate
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.extraVolumes }}
{{- 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 }}
Loading