Skip to content
Merged
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
25 changes: 25 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Validate Helm chart

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: azure/setup-helm@v4
with:
version: v3.19.0

- name: Chart contract
run: bash tests/test_chart.sh

- name: Render standalone chart
run: helm template chat-api . --namespace smoke >/dev/null
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: chat-api
description: ai-app (mind)
type: application
version: 0.3.0
appVersion: "1.0.0"
version: 0.4.0
appVersion: "1.1.1"
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ Helm chart для деплоя [Chat API Microservice](https://github.com/justgi

## Быстрый старт

### 1. Создать secrets
### 1. Установить chart

Для health-check и локальной SQLite secrets не нужны:

```bash
helm install chat-api . \
--namespace chat-api \
--create-namespace
```

### 2. Опционально подключить внешние сервисы

```bash
# OpenRouter API key
Expand All @@ -18,14 +28,6 @@ kubectl create secret generic chat-postgres \
--from-literal=DATABASE_URL=postgresql://user:pass@host:5432/db
```

### 2. Установить chart

```bash
helm install chat-api . \
--namespace chat-api \
--create-namespace
```

### 3. Проверить

```bash
Expand All @@ -39,9 +41,9 @@ kubectl logs -f deployment/chat-api -n chat-api

| Параметр | Описание | Default |
|----------|----------|---------|
| `replicaCount` | Количество реплик | `2` |
| `image.repository` | Docker image | `ghcr.io/justgithubaccount/chat-api` |
| `image.tag` | Image tag | `1.0.0` |
| `replicaCount` | Количество реплик | `1` |
| `image.repository` | Docker image | `ghcr.io/justgithubaccount/app-poly-gitops-fastapi` |
| `image.tag` | Image tag | `1.1.1` |
| `containerPort` | Порт приложения | `8000` |
| `service.type` | Тип сервиса | `ClusterIP` |
| `service.port` | Порт сервиса | `80` |
Expand Down Expand Up @@ -98,7 +100,7 @@ env:

```
.
├── Chart.yaml # Metadata (v0.3.0)
├── Chart.yaml # Metadata (v0.4.0)
├── values.yaml # Default values
└── templates/
├── _helpers.tpl # Template helpers
Expand Down
6 changes: 5 additions & 1 deletion templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{{- end }}
{{- end }}

{{- define "chat-api.namespace" -}}
{{- default .Release.Namespace .Values.namespace -}}
{{- end }}

{{- define "chat-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
Expand All @@ -31,4 +35,4 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- define "chat-api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chat-api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- end }}
22 changes: 12 additions & 10 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "chat-api.fullname" . }}
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
labels:
{{- include "chat-api.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -73,13 +73,17 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}

{{- if or .Values.openrouterSecretRefName .Values.postgresSecretRefName }}
envFrom:
{{- if .Values.openrouterSecretRefName }}
- secretRef:
name: {{ .Values.openrouterSecretRefName | default "chat-openrouter" }}
name: {{ .Values.openrouterSecretRefName }}
{{- end }}
{{- if .Values.postgresSecretRefName }}
- secretRef:
name: {{ .Values.postgresSecretRefName }}
{{- end }}
{{- end }}

resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand All @@ -98,13 +102,11 @@ spec:
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds | default 10 }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds | default 30 }}

{{- if .Values.command }}
command: {{ .Values.command }}
{{- with .Values.command }}
command:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if .Values.args }}
args: {{ .Values.args }}
{{- else }}
command: ["/bin/sh", "-c"]
{{- with .Values.args }}
args:
- uvicorn app.main:app --host 0.0.0.0 --port {{ .Values.containerPort }}
{{- end }}
{{- toYaml . | nindent 12 }}
{{- end }}
2 changes: 1 addition & 1 deletion templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "chat-api.fullname" . }}
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
labels:
app: {{ include "chat-api.name" . }}
annotations:
Expand Down
8 changes: 4 additions & 4 deletions templates/pg-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ apiVersion: v1
kind: Service
metadata:
name: postgres-external
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
labels:
app: {{ include "chat-api.name" . }}
component: database
spec:
type: ExternalName
externalName: {{ .Values.postgres.externalService.host }}
ports:
- port: 5432
targetPort: 5432
{{- end }}
- port: {{ .Values.postgres.externalService.port }}
targetPort: {{ .Values.postgres.externalService.port }}
{{- end }}
4 changes: 2 additions & 2 deletions templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ include "chat-api.fullname" . }}-config
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
type: Opaque
stringData:
# OpenRouter Configuration
Expand All @@ -16,4 +16,4 @@ stringData:
{{- if .Values.openrouter.xTitle }}
OPENROUTER_X_TITLE: {{ .Values.openrouter.xTitle | quote }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "chat-api.fullname" . }}
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
labels:
app: {{ include "chat-api.name" . }}
spec:
Expand All @@ -11,4 +11,4 @@ spec:
- port: {{ .Values.service.port | default 80 }}
targetPort: {{ .Values.containerPort | default 8000 }}
selector:
{{- include "chat-api.selectorLabels" . | nindent 4 }}
{{- include "chat-api.selectorLabels" . | nindent 4 }}
4 changes: 2 additions & 2 deletions templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "chat-api.fullname" . }}
namespace: {{ .Values.namespace | default "chat-api" }}
namespace: {{ include "chat-api.namespace" . }}
labels:
{{- include "chat-api.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions tests/test_chart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

helm lint "${repo_root}"
rendered="$(helm template chat-api "${repo_root}" --namespace smoke)"

grep -q 'namespace: smoke' <<<"${rendered}"
grep -q 'image: "ghcr.io/justgithubaccount/app-poly-gitops-fastapi:1.1.1"' <<<"${rendered}"
! grep -q 'secretRef:' <<<"${rendered}"
! grep -q 'command:' <<<"${rendered}"

workflow="${repo_root}/.github/workflows/validate.yaml"
test -f "${workflow}"
grep -q 'bash tests/test_chart.sh' "${workflow}"
29 changes: 13 additions & 16 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# charts/chat/values.yaml

# === Основные настройки приложения ===
replicaCount: 2
namespace: "chat-api"
replicaCount: 1
namespace: ""

# === Docker образ ===
image:
repository: ghcr.io/justgithubaccount/chat-api
pullPolicy: Always
tag: "1.0.0"
repository: ghcr.io/justgithubaccount/app-poly-gitops-fastapi
pullPolicy: IfNotPresent
tag: "1.1.1"

# === Сетевые настройки ===
containerPort: 8000
Expand Down Expand Up @@ -43,10 +43,10 @@ serviceAccount:
env:
# OpenTelemetry
OTEL_SERVICE_NAME: "chat-api"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://vector-gateway.observability.svc.cluster.local:4318"
OTEL_EXPORTER_OTLP_ENDPOINT: ""
OTEL_EXPORTER_OTLP_PROTOCOL: "http/protobuf"
OTEL_TRACES_EXPORTER: "otlp"
OTEL_LOGS_EXPORTER: "otlp"
OTEL_TRACES_EXPORTER: "none"
OTEL_LOGS_EXPORTER: "none"

# Application
ENVIRONMENT: "production"
Expand All @@ -63,20 +63,16 @@ openrouter:
# xTitle: "Chat Microservice" # Optional

# === External Dependencies ===
externalServices:
postgresql:
enabled: false
host: ""
port: 5432

# Secrets
openrouterSecretRefName: "chat-openrouter"
postgresSecretRefName: "chat-postgree"
openrouterSecretRefName: ""
postgresSecretRefName: ""

# PostgreSQL
postgres:
externalService:
enabled: false
host: ""
port: 5432

# Ingress
ingress:
Expand All @@ -85,6 +81,7 @@ ingress:
host: ""
path: /
tls: false
tlsSecretName: ""

# Extra environment variables (for PGO secrets mapping, etc.)
extraEnv: []
Expand Down
Loading