diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml new file mode 100644 index 0000000..028f437 --- /dev/null +++ b/.github/workflows/helm.yml @@ -0,0 +1,23 @@ +name: Helm + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint-and-template: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: azure/setup-helm@v4 + - run: helm lint charts/logsight-ai + - run: helm template logsight-ai charts/logsight-ai --namespace logsight > rendered-manifests.yaml + - uses: actions/upload-artifact@v7 + with: + name: helm-manifests + path: rendered-manifests.yaml diff --git a/README.md b/README.md index ea735a1..da752cb 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,13 @@ pip install -e ".[api,kafka,observability,ai,parsing,redis]" The optional integrations are deliberately separated so a developer can use the original local-first CLI without downloading heavyweight ML or infrastructure clients. +### Helm deployment + +The production chart at `charts/logsight-ai` deploys the API with an HPA, PDB, +hardened pod/container settings, and a default-deny NetworkPolicy. It requires an +immutable image reference and explicit egress rules for deployment-owned +dependencies. See the [Helm chart guide](charts/logsight-ai/README.md). + ### Distributed inference workers The enterprise Compose stack includes an idle Celery embedding worker. Its task @@ -238,7 +245,7 @@ Pull requests retain the existing formatting, linting, strict typing, unit/integ - [x] Redis-backed deduplication/rate limiting - [x] OTel Collector deployment and trace-log correlation pipeline - [x] Celery/Ray distributed inference workers -- [ ] Helm chart with HPA/PDB/network policies +- [x] Helm chart with HPA/PDB/network policies - [ ] RAG incident investigator with versioned runbooks/commits - [ ] Labeled benchmark corpus with precision/recall and alert-burden metrics @@ -248,6 +255,7 @@ Pull requests retain the existing formatting, linting, strict typing, unit/integ - [Architecture](docs/architecture.md) - [Collector correlation](docs/OTEL_COLLECTOR.md) - [Celery inference workers](docs/CELERY_WORKERS.md) +- [Helm chart](charts/logsight-ai/README.md) - [Deployment and rollback checklist](docs/DEPLOYMENT.md) - [Benchmark methodology](docs/BENCHMARKING.md) - [Mathematical foundations](docs/MATHEMATICAL_FOUNDATIONS.md) diff --git a/charts/logsight-ai/Chart.yaml b/charts/logsight-ai/Chart.yaml new file mode 100644 index 0000000..cac10e5 --- /dev/null +++ b/charts/logsight-ai/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: logsight-ai +description: Production-focused Helm chart for the LogSight-AI API +type: application +version: 0.1.0 +appVersion: "0.2.0" +keywords: + - logs + - observability + - anomaly-detection +maintainers: + - name: CoreyLeath-code diff --git a/charts/logsight-ai/README.md b/charts/logsight-ai/README.md new file mode 100644 index 0000000..786959e --- /dev/null +++ b/charts/logsight-ai/README.md @@ -0,0 +1,27 @@ +# LogSight-AI Helm chart + +This chart deploys the LogSight API as a hardened Kubernetes workload. It expects +the image to contain the `api` extra and leaves Redis, OTLP, and distributed +inference services as deployment-owned dependencies. + +## Install + +```bash +helm upgrade --install logsight-ai ./charts/logsight-ai \ + --namespace logsight --create-namespace \ + --set image.repository=registry.example/logsight-ai \ + --set image.tag=IMMUTABLE_DIGEST_OR_TAG +``` + +## Production configuration + +The chart defaults to two replicas, an HPA, a PDB, non-root/read-only container +security, a dedicated service account without a token, and a restrictive +NetworkPolicy. The default NetworkPolicy permits only ingress from the +`ingress-nginx` namespace and DNS egress. Add explicit `networkPolicy.extraEgress` +rules before configuring Redis, OTLP, Kafka, ClickHouse, or Qdrant endpoints. + +Pass credentials through `extraEnvFrom` references to externally managed Secrets; +do not place connection credentials in values files. Use immutable image tags or +digests, tune resource requests from measured workload behavior, and test +autoscaling/disruption behavior in a non-production namespace before promotion. diff --git a/charts/logsight-ai/templates/_helpers.tpl b/charts/logsight-ai/templates/_helpers.tpl new file mode 100644 index 0000000..1bcb366 --- /dev/null +++ b/charts/logsight-ai/templates/_helpers.tpl @@ -0,0 +1,40 @@ +{{- define "logsight-ai.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "logsight-ai.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := include "logsight-ai.name" . }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{- define "logsight-ai.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "logsight-ai.labels" -}} +helm.sh/chart: {{ include "logsight-ai.chart" . }} +{{ include "logsight-ai.selectorLabels" . }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{- define "logsight-ai.selectorLabels" -}} +app.kubernetes.io/name: {{ include "logsight-ai.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "logsight-ai.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "logsight-ai.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/logsight-ai/templates/deployment.yaml b/charts/logsight-ai/templates/deployment.yaml new file mode 100644 index 0000000..e2da7d6 --- /dev/null +++ b/charts/logsight-ai/templates/deployment.yaml @@ -0,0 +1,88 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "logsight-ai.fullname" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "logsight-ai.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "logsight-ai.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ include "logsight-ai.serviceAccountName" . }} + automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: logsight-api + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["uvicorn"] + args: ["logsight.api:app", "--host", "0.0.0.0", "--port", "8000"] + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + ports: + - name: http + containerPort: 8000 + protocol: TCP + env: + {{- range $name, $value := .Values.env }} + - name: {{ $name }} + value: {{ $value | quote }} + {{- end }} + {{- with .Values.extraEnv }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.extraEnvFrom }} + envFrom: + {{- toYaml . | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + livenessProbe: + httpGet: + path: /health + port: http + {{- toYaml .Values.probes.liveness | nindent 12 }} + readinessProbe: + httpGet: + path: /health + port: http + {{- toYaml .Values.probes.readiness | nindent 12 }} + volumeMounts: + - name: tmp + mountPath: /tmp + volumes: + - name: tmp + emptyDir: + sizeLimit: 64Mi + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- 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 }} diff --git a/charts/logsight-ai/templates/hpa.yaml b/charts/logsight-ai/templates/hpa.yaml new file mode 100644 index 0000000..3c5c824 --- /dev/null +++ b/charts/logsight-ai/templates/hpa.yaml @@ -0,0 +1,30 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "logsight-ai.fullname" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "logsight-ai.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/logsight-ai/templates/networkpolicy.yaml b/charts/logsight-ai/templates/networkpolicy.yaml new file mode 100644 index 0000000..4446845 --- /dev/null +++ b/charts/logsight-ai/templates/networkpolicy.yaml @@ -0,0 +1,19 @@ +{{- if .Values.networkPolicy.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "logsight-ai.fullname" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "logsight-ai.selectorLabels" . | nindent 6 }} + policyTypes: + - Ingress + - Egress + ingress: + {{- toYaml .Values.networkPolicy.ingress | nindent 4 }} + egress: + {{- toYaml (concat .Values.networkPolicy.egress .Values.networkPolicy.extraEgress) | nindent 4 }} +{{- end }} diff --git a/charts/logsight-ai/templates/pdb.yaml b/charts/logsight-ai/templates/pdb.yaml new file mode 100644 index 0000000..5348088 --- /dev/null +++ b/charts/logsight-ai/templates/pdb.yaml @@ -0,0 +1,13 @@ +{{- if .Values.podDisruptionBudget.enabled }} +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "logsight-ai.fullname" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} +spec: + minAvailable: {{ .Values.podDisruptionBudget.minAvailable }} + selector: + matchLabels: + {{- include "logsight-ai.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/logsight-ai/templates/service.yaml b/charts/logsight-ai/templates/service.yaml new file mode 100644 index 0000000..50a7d4b --- /dev/null +++ b/charts/logsight-ai/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "logsight-ai.fullname" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "logsight-ai.selectorLabels" . | nindent 4 }} diff --git a/charts/logsight-ai/templates/serviceaccount.yaml b/charts/logsight-ai/templates/serviceaccount.yaml new file mode 100644 index 0000000..881630d --- /dev/null +++ b/charts/logsight-ai/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "logsight-ai.serviceAccountName" . }} + labels: + {{- include "logsight-ai.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }} +{{- end }} diff --git a/charts/logsight-ai/values.yaml b/charts/logsight-ai/values.yaml new file mode 100644 index 0000000..3865f62 --- /dev/null +++ b/charts/logsight-ai/values.yaml @@ -0,0 +1,105 @@ +replicaCount: 2 + +image: + repository: logsight-ai + pullPolicy: IfNotPresent + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + annotations: {} + name: "" + automountServiceAccountToken: false + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + runAsNonRoot: true + runAsUser: 1000 + runAsGroup: 1000 + fsGroup: 1000 + seccompProfile: + type: RuntimeDefault + +securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: [ALL] + +service: + type: ClusterIP + port: 8000 + +resources: + requests: + cpu: 250m + memory: 512Mi + limits: + cpu: "1" + memory: 1Gi + +probes: + liveness: + initialDelaySeconds: 10 + periodSeconds: 20 + timeoutSeconds: 3 + failureThreshold: 3 + readiness: + initialDelaySeconds: 5 + periodSeconds: 10 + timeoutSeconds: 3 + failureThreshold: 3 + +env: + LOGSIGHT_WINDOW: "500" + LOGSIGHT_OTEL_ENABLED: "false" + LOGSIGHT_CELERY_DISPATCH_ENABLED: "false" + +extraEnv: [] +extraEnvFrom: [] + +autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetCPUUtilizationPercentage: 70 + targetMemoryUtilizationPercentage: 80 + +podDisruptionBudget: + enabled: true + minAvailable: 1 + +networkPolicy: + enabled: true + ingress: + - from: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: ingress-nginx + ports: + - protocol: TCP + port: 8000 + egress: + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: kube-system + podSelector: + matchLabels: + k8s-app: kube-dns + ports: + - protocol: UDP + port: 53 + - protocol: TCP + port: 53 + extraEgress: [] + +nodeSelector: {} +tolerations: [] +affinity: {}