Skip to content

Commit ce1fe97

Browse files
plagnessclaude
andcommitted
feat(k8s): add Kubernetes manifests for channel-mcp module
Namespace ns-channel, StatefulSet chdb, Deployment chmcp, Services, ConfigMap, Secret, PVC with ns-db-local storageClass. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 94addd4 commit ce1fe97

File tree

9 files changed

+370
-0
lines changed

9 files changed

+370
-0
lines changed

k8s/chdb-pvc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: chdb-pvc
5+
namespace: ns-channel
6+
spec:
7+
accessModes:
8+
- ReadWriteOnce
9+
storageClassName: ns-db-local
10+
resources:
11+
requests:
12+
storage: 10Gi

k8s/chdb-service.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: chdb-service
5+
namespace: ns-channel
6+
labels:
7+
app: chdb
8+
app.kubernetes.io/part-of: neuronswarm
9+
spec:
10+
type: ClusterIP
11+
clusterIP: None
12+
selector:
13+
app: chdb
14+
ports:
15+
- name: postgres
16+
port: 5432
17+
targetPort: 5432
18+
protocol: TCP
19+
---
20+
# NodePort сервис для доступа извне кластера (если требуется)
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: chdb-nodeport
25+
namespace: ns-channel
26+
labels:
27+
app: chdb
28+
app.kubernetes.io/part-of: neuronswarm
29+
spec:
30+
type: NodePort
31+
selector:
32+
app: chdb
33+
ports:
34+
- name: postgres
35+
port: 5432
36+
targetPort: 5432
37+
nodePort: 30434
38+
protocol: TCP

k8s/chdb-statefulset.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
apiVersion: apps/v1
2+
kind: StatefulSet
3+
metadata:
4+
name: chdb
5+
namespace: ns-channel
6+
labels:
7+
app: chdb
8+
app.kubernetes.io/part-of: neuronswarm
9+
spec:
10+
serviceName: chdb-service
11+
replicas: 1
12+
selector:
13+
matchLabels:
14+
app: chdb
15+
template:
16+
metadata:
17+
labels:
18+
app: chdb
19+
app.kubernetes.io/part-of: neuronswarm
20+
spec:
21+
containers:
22+
- name: postgres
23+
image: pgvector/pgvector:pg16
24+
imagePullPolicy: IfNotPresent
25+
ports:
26+
- name: postgres
27+
containerPort: 5432
28+
protocol: TCP
29+
env:
30+
# Имя пользователя базы данных
31+
- name: POSTGRES_USER
32+
value: "channel"
33+
# Пароль из Secret
34+
- name: POSTGRES_PASSWORD
35+
valueFrom:
36+
secretKeyRef:
37+
name: channel-secrets
38+
key: CHANNEL_DB_PASSWORD
39+
# Название базы данных
40+
- name: POSTGRES_DB
41+
value: "channel_mcp"
42+
# Проверка живости контейнера
43+
livenessProbe:
44+
exec:
45+
command:
46+
- /bin/sh
47+
- -c
48+
- pg_isready -U channel
49+
initialDelaySeconds: 30
50+
periodSeconds: 10
51+
timeoutSeconds: 5
52+
failureThreshold: 3
53+
# Проверка готовности контейнера
54+
readinessProbe:
55+
exec:
56+
command:
57+
- /bin/sh
58+
- -c
59+
- pg_isready -U channel
60+
initialDelaySeconds: 10
61+
periodSeconds: 5
62+
timeoutSeconds: 3
63+
failureThreshold: 3
64+
resources:
65+
requests:
66+
memory: "128Mi"
67+
cpu: "100m"
68+
limits:
69+
memory: "512Mi"
70+
cpu: "500m"
71+
volumeMounts:
72+
# Хранилище данных базы
73+
- name: postgres-data
74+
mountPath: /var/lib/postgresql/data
75+
subPath: pgdata
76+
# Скрипты инициализации базы
77+
- name: init-scripts
78+
mountPath: /docker-entrypoint-initdb.d
79+
readOnly: true
80+
# Монтирование инит-скриптов с хоста
81+
volumes:
82+
- name: init-scripts
83+
hostPath:
84+
path: /home/plag/NeuronSwarm/channel-mcp/db/init
85+
type: Directory
86+
# Запрос постоянного хранилища
87+
volumeClaimTemplates:
88+
- metadata:
89+
name: postgres-data
90+
spec:
91+
accessModes:
92+
- ReadWriteOnce
93+
storageClassName: local-path
94+
resources:
95+
requests:
96+
storage: 10Gi

k8s/chmcp-deployment.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: chmcp
5+
namespace: ns-channel
6+
labels:
7+
app: chmcp
8+
app.kubernetes.io/part-of: neuronswarm
9+
spec:
10+
replicas: 1
11+
selector:
12+
matchLabels:
13+
app: chmcp
14+
template:
15+
metadata:
16+
labels:
17+
app: chmcp
18+
app.kubernetes.io/part-of: neuronswarm
19+
spec:
20+
# Ожидание готовности базы данных перед запуском приложения
21+
initContainers:
22+
- name: wait-for-db
23+
image: busybox:1.35
24+
command:
25+
- sh
26+
- -c
27+
- |
28+
until nc -z chdb-service.ns-channel.svc.cluster.local 5432; do
29+
echo "Waiting for PostgreSQL..."
30+
sleep 2
31+
done
32+
echo "PostgreSQL is ready"
33+
containers:
34+
- name: chmcp
35+
# Локальный образ без pull-версии
36+
image: channel-mcp-chmcp:latest
37+
imagePullPolicy: Never
38+
ports:
39+
- name: http
40+
containerPort: 3333
41+
protocol: TCP
42+
env:
43+
# Хост базы данных
44+
- name: CHANNEL_DB_HOST
45+
valueFrom:
46+
configMapKeyRef:
47+
name: channel-config
48+
key: DB_HOST
49+
# Пользователь базы данных
50+
- name: CHANNEL_DB_USER
51+
value: "channel"
52+
# Пароль базы данных
53+
- name: CHANNEL_DB_PASSWORD
54+
valueFrom:
55+
secretKeyRef:
56+
name: channel-secrets
57+
key: CHANNEL_DB_PASSWORD
58+
# Название базы данных
59+
- name: CHANNEL_DB_NAME
60+
value: "channel_mcp"
61+
# Порт базы данных
62+
- name: CHANNEL_DB_PORT
63+
value: "5432"
64+
# URL LLM Core сервиса
65+
- name: LLM_MCP_BASE_URL
66+
valueFrom:
67+
configMapKeyRef:
68+
name: channel-config
69+
key: LLM_CORE_URL
70+
# Флаг использования Telegram MCP
71+
- name: TELEGRAM_USE_MCP
72+
valueFrom:
73+
configMapKeyRef:
74+
name: channel-config
75+
key: TELEGRAM_USE_MCP
76+
# URL Telegram API сервиса
77+
- name: TELEGRAM_MCP_BASE_URL
78+
valueFrom:
79+
configMapKeyRef:
80+
name: channel-config
81+
key: TGAPI_URL
82+
# Токен HTTP для MCP
83+
- name: MCP_HTTP_TOKEN
84+
valueFrom:
85+
secretKeyRef:
86+
name: channel-secrets
87+
key: MCP_HTTP_TOKEN
88+
# Уровень логирования
89+
- name: LOG_LEVEL
90+
valueFrom:
91+
configMapKeyRef:
92+
name: channel-config
93+
key: LOG_LEVEL
94+
# Проверка живости контейнера
95+
livenessProbe:
96+
httpGet:
97+
path: /health
98+
port: 3333
99+
scheme: HTTP
100+
initialDelaySeconds: 30
101+
periodSeconds: 10
102+
timeoutSeconds: 5
103+
failureThreshold: 3
104+
# Проверка готовности контейнера
105+
readinessProbe:
106+
httpGet:
107+
path: /health
108+
port: 3333
109+
scheme: HTTP
110+
initialDelaySeconds: 10
111+
periodSeconds: 5
112+
timeoutSeconds: 3
113+
failureThreshold: 2
114+
resources:
115+
requests:
116+
memory: "128Mi"
117+
cpu: "100m"
118+
limits:
119+
memory: "256Mi"
120+
cpu: "500m"
121+
# Стратегия перезапуска при сбое
122+
restartPolicy: Always

k8s/chmcp-service.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: chmcp-service
5+
namespace: ns-channel
6+
labels:
7+
app: chmcp
8+
app.kubernetes.io/part-of: neuronswarm
9+
spec:
10+
type: ClusterIP
11+
selector:
12+
app: chmcp
13+
ports:
14+
- name: http
15+
port: 3333
16+
targetPort: 3333
17+
protocol: TCP
18+
---
19+
# NodePort сервис для доступа извне кластера (если требуется)
20+
apiVersion: v1
21+
kind: Service
22+
metadata:
23+
name: chmcp-nodeport
24+
namespace: ns-channel
25+
labels:
26+
app: chmcp
27+
app.kubernetes.io/part-of: neuronswarm
28+
spec:
29+
type: NodePort
30+
selector:
31+
app: chmcp
32+
ports:
33+
- name: http
34+
port: 3333
35+
targetPort: 3333
36+
nodePort: 30334
37+
protocol: TCP

k8s/configmap.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: channel-config
5+
namespace: ns-channel
6+
data:
7+
# Конфигурация подключения к базе данных
8+
DB_HOST: chdb
9+
# URL LLM Core сервиса в кластере (ns-llm namespace)
10+
LLM_CORE_URL: "http://llmcore.ns-llm.svc.cluster.local:8080"
11+
# URL Telegram API сервиса в кластере (ns-telegram namespace)
12+
TGAPI_URL: "http://tgapi.ns-telegram.svc.cluster.local:8000"
13+
# Использование Telegram MCP (отключено - используется прямое подключение)
14+
TELEGRAM_USE_MCP: "0"
15+
# Уровень логирования
16+
LOG_LEVEL: "info"

k8s/kustomization.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
4+
# Целевой namespace для всех ресурсов
5+
namespace: ns-channel
6+
7+
# Список всех файлов ресурсов
8+
resources:
9+
- namespace.yaml
10+
- secret.yaml
11+
- configmap.yaml
12+
- chdb-pvc.yaml
13+
- chdb-statefulset.yaml
14+
- chdb-service.yaml
15+
- chmcp-deployment.yaml
16+
- chmcp-service.yaml
17+
18+
# Общие метаданные для всех ресурсов
19+
labels:
20+
- pairs:
21+
app.kubernetes.io/part-of: neuronswarm
22+
app.kubernetes.io/managed-by: kustomize
23+
24+
# Замены названий образов (опционально)
25+
# Можно использовать для переопределения в разных окружениях
26+
images:
27+
- name: pgvector/pgvector
28+
newName: pgvector/pgvector
29+
newTag: pg16
30+
- name: channel-mcp-chmcp
31+
newName: channel-mcp-chmcp
32+
newTag: latest

k8s/namespace.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: ns-channel
5+
labels:
6+
app.kubernetes.io/part-of: neuronswarm

k8s/secret.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: channel-secrets
5+
namespace: ns-channel
6+
type: Opaque
7+
stringData:
8+
# Пароль базы данных для пользователя 'channel'
9+
CHANNEL_DB_PASSWORD: channel_secret
10+
# Токен HTTP для MCP-сервера
11+
MCP_HTTP_TOKEN: ""

0 commit comments

Comments
 (0)