Skip to content

Commit 3610ced

Browse files
committed
Merge branch 'feat/integrate-tag-release-automation-into-k8s' into 'main'
Integrate tag-release automation into k8s Closes #154 See merge request postgres-ai/postgresai!132
2 parents 2af452b + fcc9b45 commit 3610ced

8 files changed

Lines changed: 1441 additions & 6 deletions

File tree

.gitlab-ci.yml

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ stages:
2222
- security
2323
- build
2424
- test
25+
- validate
2526
- publish
27+
- release
2628
- preview
2729

30+
variables:
31+
HELM_VERSION: "3.13.0"
32+
2833
# Build images from current code for e2e tests
2934
# Images are pushed to GitLab Container Registry and pulled by test jobs
3035

@@ -299,6 +304,37 @@ cli:node:tests:
299304
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
300305
- if: '$CI_COMMIT_BRANCH == "main"'
301306

307+
# Validate helm chart on merge requests and main branch
308+
validate-helm-chart:
309+
stage: validate
310+
image:
311+
name: alpine/helm:${HELM_VERSION}
312+
entrypoint: [""]
313+
rules:
314+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
315+
changes:
316+
- postgres_ai_helm/**/*
317+
- .gitlab-ci.yml
318+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
319+
changes:
320+
- postgres_ai_helm/**/*
321+
- .gitlab-ci.yml
322+
script:
323+
- echo "Starting helm chart validation"
324+
- apk add --no-cache bash git
325+
- bash postgres_ai_helm/test-release-logic.sh
326+
- cd postgres_ai_helm
327+
- echo "Validating helm chart"
328+
- helm dependency update
329+
- helm lint .
330+
- helm template test-release .
331+
- helm package .
332+
- ls -lh postgres-ai-monitoring-*.tgz
333+
artifacts:
334+
paths:
335+
- postgres_ai_helm/*.tgz
336+
expire_in: 1 week
337+
302338
cli:npm:publish:
303339
stage: publish
304340
interruptible: false # Never cancel publish jobs
@@ -418,6 +454,8 @@ cli:npm:publish:
418454
after_script:
419455
- rm -f ~/.npmrc
420456
rules:
457+
- if: '$CI_COMMIT_TAG =~ /^helm-v/'
458+
when: never
421459
- if: '$CI_COMMIT_TAG'
422460

423461
.docker-publish-base: &docker-publish-base
@@ -508,8 +546,103 @@ docker:publish:images:
508546
PLATFORMS="linux/amd64,linux/arm64"
509547
- *docker-build-script
510548
rules:
549+
- if: '$CI_COMMIT_TAG =~ /^helm-v/'
550+
when: never
511551
- if: '$CI_COMMIT_TAG'
512552

553+
# Release helm chart when a tag is pushed.
554+
# NOTE: The 'helm-v' prefix is an explicit exception to the org 'vX.Y.Z' tag convention.
555+
# It is required to distinguish helm chart releases from npm/Docker image releases so that
556+
# the cli:npm:publish and docker:publish:images jobs are not triggered on helm chart tags.
557+
release-helm-chart:
558+
stage: release
559+
image:
560+
name: alpine/helm:${HELM_VERSION}
561+
entrypoint: [""]
562+
rules:
563+
- if: '$CI_COMMIT_TAG =~ /^helm-v[0-9]+\.[0-9]+\.[0-9]+$/'
564+
script:
565+
- apk add --no-cache bash
566+
- |
567+
bash -euo pipefail << 'BASH_SCRIPT'
568+
set -euo pipefail
569+
# Extract version from tag
570+
VERSION="${CI_COMMIT_TAG#helm-}"
571+
VERSION="${VERSION#v}"
572+
echo "Version: ${VERSION}"
573+
574+
cd postgres_ai_helm
575+
576+
# Update Chart.yaml chart version only (appVersion tracks the deployed app, not the chart)
577+
sed "s/^version: .*/version: \"${VERSION}\"/" Chart.yaml > Chart.yaml.tmp
578+
mv Chart.yaml.tmp Chart.yaml
579+
580+
# Verify the substitution succeeded
581+
if ! grep -q "^version: \"${VERSION}\"" Chart.yaml; then
582+
echo "ERROR: Failed to update version in Chart.yaml (sed pattern may not match)" >&2
583+
exit 1
584+
fi
585+
586+
# Build and package
587+
helm dependency update
588+
helm lint .
589+
helm package .
590+
pkg=(postgres-ai-monitoring-*.tgz)
591+
if [ ! -f "${pkg[0]}" ]; then
592+
echo "Error: Package file not found after helm package" >&2
593+
exit 1
594+
fi
595+
PACKAGE_FILE="${pkg[0]}"
596+
echo "Packaged: ${PACKAGE_FILE} ($(du -h "${PACKAGE_FILE}" | cut -f1))"
597+
598+
# Copy artifact to fixed name so release: block can reference it with a known path
599+
# (shell variables like ${PACKAGE_FILE} are not available in the release: YAML block)
600+
cp "${PACKAGE_FILE}" "../postgres-ai-monitoring-chart.tgz"
601+
BASH_SCRIPT
602+
artifacts:
603+
paths:
604+
- postgres-ai-monitoring-chart.tgz
605+
expire_in: 30 days
606+
release:
607+
tag_name: $CI_COMMIT_TAG
608+
name: "Helm chart $CI_COMMIT_TAG"
609+
description: |
610+
## PostgresAI monitoring helm chart $CI_COMMIT_TAG
611+
612+
### Installation
613+
614+
Download `postgres-ai-monitoring-chart.tgz` from this release's assets and run:
615+
616+
```bash
617+
helm install postgres-ai-monitoring postgres-ai-monitoring-chart.tgz
618+
```
619+
620+
### Upgrade
621+
622+
```bash
623+
helm upgrade postgres-ai-monitoring postgres-ai-monitoring-chart.tgz
624+
```
625+
626+
### What's included
627+
628+
- PGWatch for Postgres metrics collection
629+
- VictoriaMetrics for metrics storage
630+
- Grafana for visualization
631+
- Node exporter for system metrics
632+
- cAdvisor for container metrics
633+
- Automated reporting cronjobs
634+
635+
### Documentation
636+
637+
- [Installation guide]($CI_PROJECT_URL/-/blob/main/postgres_ai_helm/INSTALLATION_GUIDE.md)
638+
- [Helm chart README]($CI_PROJECT_URL/-/blob/main/postgres_ai_helm/README.md)
639+
- [Release process]($CI_PROJECT_URL/-/blob/main/postgres_ai_helm/RELEASE.md)
640+
assets:
641+
links:
642+
- name: "postgres-ai-monitoring-chart.tgz"
643+
url: "$CI_PROJECT_URL/-/jobs/$CI_JOB_ID/artifacts/raw/postgres-ai-monitoring-chart.tgz"
644+
link_type: package
645+
513646
cli:node:e2e:dind:
514647
stage: test
515648
image: node:20-alpine
@@ -838,4 +971,4 @@ preview:destroy:
838971
# Results appear in the Security tab of merge requests and pipelines.
839972
# https://docs.gitlab.com/ee/user/application_security/sast/
840973
sast:
841-
stage: test
974+
stage: test

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,56 @@ postgresai mon health
320320

321321
Check Grafana dashboards at http://localhost:3000 to confirm metrics are being collected.
322322

323+
## ☸️ Kubernetes deployment
324+
325+
Deploy postgres_ai monitoring to Kubernetes using helm:
326+
327+
```bash
328+
# Install from the helm chart directory
329+
helm install postgres-ai-monitoring ./postgres_ai_helm
330+
331+
# Or install from a release (replace <VERSION> with the desired release, e.g. 0.14.0)
332+
curl -LO https://gitlab.com/postgres-ai/postgresai/-/releases/helm-v<VERSION>/downloads/postgres-ai-monitoring-chart.tgz
333+
helm install postgres-ai-monitoring postgres-ai-monitoring-chart.tgz
334+
335+
# Customize installation
336+
helm install postgres-ai-monitoring ./postgres_ai_helm -f custom-values.yaml
337+
```
338+
339+
### Helm chart features
340+
341+
- Complete monitoring stack for Kubernetes
342+
- PGWatch, VictoriaMetrics, and Grafana
343+
- Automated report generation via CronJobs
344+
- Node exporter and cAdvisor for system metrics
345+
- Configurable resource limits and persistence
346+
347+
### Helm chart documentation
348+
349+
- [README](./postgres_ai_helm/README.md): Quick start and overview
350+
- [INSTALLATION_GUIDE](./postgres_ai_helm/INSTALLATION_GUIDE.md): Detailed installation instructions
351+
- [RELEASE](./postgres_ai_helm/RELEASE.md): Release process for maintainers
352+
353+
### Creating helm releases
354+
355+
For maintainers creating new helm chart releases:
356+
357+
```bash
358+
cd postgres_ai_helm
359+
360+
# Test the chart locally
361+
./test-release.sh
362+
363+
# Create a new release (e.g. 0.14.0)
364+
./release.sh <VERSION>
365+
```
366+
367+
This automatically:
368+
- Updates Chart.yaml with the new version
369+
- Creates a git tag
370+
- Triggers GitLab CI/CD to package and publish the chart
371+
- Creates a GitLab release with the packaged chart
372+
323373
## 📋 Checkup reports
324374

325375
postgres_ai monitoring generates automated health check reports based on [postgres-checkup](https://gitlab.com/postgres-ai/postgres-checkup). Each report has a unique check ID and title:
@@ -461,7 +511,7 @@ View the coverage report by opening `htmlcov/index.html` in your browser.
461511

462512
## 🤝 Contributing
463513

464-
We welcome contributions from Postgres experts! Please check our [GitLab repository](https://gitlab.com/postgres-ai/postgres_ai) for:
514+
We welcome contributions from Postgres experts! Please check our [GitLab repository](https://gitlab.com/postgres-ai/postgresai) for:
465515
- Code standards and review process
466516
- Dashboard design principles
467517
- Testing requirements for monitoring components
@@ -479,7 +529,7 @@ postgres_ai monitoring is developed by [PostgresAI](https://postgres.ai), bringi
479529
- 💬 [Get support](https://postgres.ai/contact)
480530
- 📺 [Postgres.TV (YouTube)](https://postgres.tv)
481531
- 🎙️ [Postgres FM Podcast](https://postgres.fm)
482-
- 🐛 [Report issues](https://gitlab.com/postgres-ai/postgres_ai/-/issues)
532+
- 🐛 [Report issues](https://gitlab.com/postgres-ai/postgresai/-/issues)
483533
- 📧 [Enterprise support](https://postgres.ai/consulting)
484534

485535
</div>

postgres_ai_helm/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: v2
2-
appVersion: 1.0.0
2+
appVersion: "1.0.0"
33
dependencies:
44
- condition: grafana.enabled
55
name: grafana
66
repository: https://grafana.github.io/helm-charts
7-
version: 10.1.4
7+
version: "10.1.4"
88
description: PostgresAI monitoring stack with PGWatch, VictoriaMetrics, and Grafana
99
for Kubernetes
1010
home: https://postgres.ai
@@ -22,4 +22,4 @@ name: postgres-ai-monitoring
2222
sources:
2323
- https://github.com/PostgresAI/double-pgwatch-poc
2424
type: application
25-
version: 0.12
25+
version: "0.12.0"

0 commit comments

Comments
 (0)