Skip to content

Commit a012198

Browse files
authored
feat(gitea): replace Bitnami PostgreSQL and Redis with CNPG and Valkey (#102)
* feat(gitea): replace Bitnami PostgreSQL and Redis with CNPG and Valkey Remove all four Bitnami subchart dependencies (postgresql, postgresql-ha, redis-cluster, redis) from the Gitea Helm chart and replace them with: - PostgreSQL via CloudNativePG operator with an embedded Cluster CR - Valkey (Redis-compatible) via the official valkey-io/valkey-helm subchart Additional changes: - Add CNPG operator and cert-manager as Embedded Cluster extensions - Update EC version to 2.13.3+k8s-1.33, ingress-nginx to 4.14.1 - Replace bitnami/kubectl with registry.k8s.io/kubectl:v1.33.0 - Add KOTS config for Valkey cache settings - Default internal_postgres_enabled to true - Fix deprecated helm.sh/hook: test-success annotation to test - Fix Makefile .SHELLFLAGS for GNU make compatibility - Fix Makefile repo URL quoting for CI environments - Add CI workflow with lint-and-template and helm-install-test jobs - Add Python smoke tests for Gitea HTTP, PostgreSQL, and Valkey - Add Makefile test targets (test-lint, test-install, test-smoke, etc.) - Bump chart version to 11.0.0 Resolves #97 * fix(gitea): use single-quoted YAML for Valkey connection strings in KOTS chart KOTS processes files as Go templates before YAML parsing. The backslash-escaped quotes inside double-quoted YAML strings (\"valkey_password\") are invalid Go template syntax, causing "unexpected \\ in operand" errors that prevent Admin Console from rendering. Switch to single-quoted YAML strings so the inner double quotes pass through the Go template parser cleanly.
1 parent b483bbe commit a012198

16 files changed

Lines changed: 767 additions & 127 deletions

File tree

.github/workflows/gitea-ci.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Gitea CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'applications/gitea/charts/**'
7+
- 'applications/gitea/tests/**'
8+
- 'applications/gitea/Makefile'
9+
- '.github/workflows/gitea-ci.yml'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- 'applications/gitea/charts/**'
15+
- 'applications/gitea/tests/**'
16+
- 'applications/gitea/Makefile'
17+
- '.github/workflows/gitea-ci.yml'
18+
19+
jobs:
20+
lint-and-template:
21+
runs-on: ubuntu-22.04
22+
defaults:
23+
run:
24+
working-directory: applications/gitea
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Helm
30+
uses: azure/setup-helm@v4.3.0
31+
with:
32+
version: v3.13.3
33+
34+
- name: Add Helm repositories
35+
run: make add-helm-repositories
36+
37+
- name: Update dependencies
38+
run: make update-dependencies
39+
40+
- name: Helm lint
41+
run: helm lint ./charts/gitea
42+
43+
- name: Helm template (default values)
44+
run: helm template gitea ./charts/gitea > /dev/null
45+
46+
- name: Helm template (CI test values)
47+
run: helm template gitea ./charts/gitea -f tests/helm/ci-values.yaml > /dev/null
48+
49+
helm-install-test:
50+
runs-on: ubuntu-22.04
51+
needs: [lint-and-template]
52+
defaults:
53+
run:
54+
working-directory: applications/gitea
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v4
58+
59+
- name: Set up Helm
60+
uses: azure/setup-helm@v4.3.0
61+
with:
62+
version: v3.13.3
63+
64+
- name: Set up Python
65+
uses: actions/setup-python@v5
66+
with:
67+
python-version: "3.12"
68+
69+
- name: Create cluster
70+
id: create-cluster
71+
uses: replicatedhq/replicated-actions/create-cluster@v1.17.0
72+
with:
73+
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
74+
kubernetes-distribution: k3s
75+
kubernetes-version: "1.32"
76+
cluster-name: gitea-ci-${{ github.run_id }}
77+
disk: 50
78+
nodes: 1
79+
ttl: 1h
80+
export-kubeconfig: true
81+
82+
- name: Install cert-manager
83+
run: |
84+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
85+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
86+
export KUBECONFIG="$KUBECONFIG_FILE"
87+
88+
helm repo add jetstack https://charts.jetstack.io
89+
helm repo update jetstack
90+
helm install cert-manager jetstack/cert-manager \
91+
--namespace cert-manager --create-namespace \
92+
--set crds.enabled=true \
93+
--wait --timeout 5m
94+
env:
95+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
96+
97+
- name: Install CloudNativePG operator
98+
run: |
99+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
100+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
101+
export KUBECONFIG="$KUBECONFIG_FILE"
102+
103+
helm repo add cnpg https://cloudnative-pg.github.io/charts
104+
helm repo update cnpg
105+
helm install cnpg cnpg/cloudnative-pg \
106+
--namespace cnpg-system --create-namespace \
107+
--wait --timeout 5m
108+
env:
109+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
110+
111+
- name: Install Gitea chart
112+
run: |
113+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
114+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
115+
export KUBECONFIG="$KUBECONFIG_FILE"
116+
117+
make add-helm-repositories
118+
make update-dependencies
119+
helm install gitea ./charts/gitea \
120+
-f tests/helm/ci-values.yaml \
121+
--wait --timeout 10m
122+
env:
123+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
124+
125+
- name: Wait for pods
126+
run: |
127+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
128+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
129+
export KUBECONFIG="$KUBECONFIG_FILE"
130+
131+
echo "Waiting for Gitea deployment..."
132+
kubectl wait --for=condition=Available deployment -l app.kubernetes.io/name=gitea \
133+
--timeout=300s
134+
135+
echo "Waiting for CNPG postgres cluster..."
136+
kubectl wait --for=condition=Ready pod -l cnpg.io/cluster=gitea-postgres \
137+
--timeout=300s
138+
139+
echo "Waiting for Valkey..."
140+
kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey \
141+
--timeout=120s
142+
env:
143+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
144+
145+
- name: Run smoke tests
146+
run: |
147+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
148+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
149+
export KUBECONFIG="$KUBECONFIG_FILE"
150+
151+
python -m venv ./venv
152+
source ./venv/bin/activate
153+
pip install -r tests/requirements.txt
154+
python tests/smoke_test.py --release gitea --namespace default
155+
env:
156+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
157+
158+
- name: Debug output
159+
if: failure()
160+
run: |
161+
KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}"
162+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
163+
export KUBECONFIG="$KUBECONFIG_FILE"
164+
165+
echo "=== Pods ==="
166+
kubectl get pods -A
167+
echo "=== Services ==="
168+
kubectl get svc
169+
echo "=== Events ==="
170+
kubectl get events --sort-by='.lastTimestamp' | tail -40
171+
echo "=== Gitea pod logs ==="
172+
kubectl logs -l app.kubernetes.io/name=gitea --tail=50 || true
173+
echo "=== CNPG cluster status ==="
174+
kubectl get clusters.postgresql.cnpg.io -o yaml || true
175+
echo "=== Postgres pod logs ==="
176+
kubectl logs -l cnpg.io/cluster=gitea-postgres --tail=30 || true
177+
env:
178+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
179+
180+
- name: Remove cluster
181+
uses: replicatedhq/replicated-actions/remove-cluster@v1.17.0
182+
if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }}
183+
with:
184+
api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }}
185+
cluster-id: ${{ steps.create-cluster.outputs.cluster-id }}

applications/gitea/Makefile

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARGS = $(filter-out $@,$(MAKECMDGOALS))
66
@:
77

88
SHELL := /bin/bash
9-
.SHELLFLAGS = -x +u
9+
.SHELLFLAGS = -x +u -c
1010

1111
# Define the base path to your Helm charts directory
1212
HELM_CHARTS_DIR = ./charts
@@ -70,7 +70,7 @@ add-helm-repositories:
7070
@for chart_file in $(HELM_CHARTS_DIR)/*/Chart.yaml; do \
7171
echo "Processing $$chart_file"; \
7272
repo_name=$$(grep '^name:' $$chart_file | awk '{print $$2}'); \
73-
grep 'dependencies:' -A 10 $$chart_file | grep 'repository:' | awk '{print $$2}' | while read repo; do \
73+
grep 'dependencies:' -A 10 $$chart_file | grep 'repository:' | awk '{print $$2}' | tr -d '"' | while read repo; do \
7474
if ! helm repo list | grep -q "^$$repo_name[[:space:]]"; then \
7575
echo "Adding Helm repo $$repo_name from $$repo"; \
7676
helm repo add $$repo_name $$repo || true; \
@@ -85,3 +85,64 @@ release: package-and-update
8585
@chart_version=$$(eval $(call get_gitea_chart_version)); \
8686
echo "Creating a new release with Replicated using version $$chart_version"; \
8787
replicated release create --yaml-dir $(KOTS_DIR) --promote Unstable --version "$$chart_version"
88+
89+
90+
# ---------------------------------------------------------------------------
91+
# Test targets
92+
# ---------------------------------------------------------------------------
93+
94+
CI_VALUES = tests/helm/ci-values.yaml
95+
RELEASE_NAME = gitea
96+
NAMESPACE = default
97+
98+
.PHONY: test-lint
99+
test-lint: add-helm-repositories update-dependencies
100+
helm lint ./charts/gitea
101+
helm template $(RELEASE_NAME) ./charts/gitea > /dev/null
102+
helm template $(RELEASE_NAME) ./charts/gitea -f $(CI_VALUES) > /dev/null
103+
104+
.PHONY: test-install-operators
105+
test-install-operators:
106+
helm repo add jetstack https://charts.jetstack.io || true
107+
helm repo add cnpg https://cloudnative-pg.github.io/charts || true
108+
helm repo update jetstack cnpg
109+
helm install cert-manager jetstack/cert-manager \
110+
--namespace cert-manager --create-namespace \
111+
--set crds.enabled=true \
112+
--wait --timeout 5m
113+
helm install cnpg cnpg/cloudnative-pg \
114+
--namespace cnpg-system --create-namespace \
115+
--wait --timeout 5m
116+
117+
.PHONY: test-install
118+
test-install: add-helm-repositories update-dependencies
119+
helm install $(RELEASE_NAME) ./charts/gitea \
120+
-f $(CI_VALUES) \
121+
--namespace $(NAMESPACE) \
122+
--wait --timeout 10m
123+
124+
.PHONY: test-smoke
125+
test-smoke:
126+
python3 -m venv ./venv
127+
./venv/bin/pip install -r tests/requirements.txt
128+
./venv/bin/python tests/smoke_test.py \
129+
--release $(RELEASE_NAME) --namespace $(NAMESPACE)
130+
131+
.PHONY: test-all
132+
test-all: test-lint test-install-operators test-install test-smoke
133+
134+
.PHONY: help
135+
help:
136+
@echo "Build targets:"
137+
@echo " package-and-update Package charts and update KOTS versions"
138+
@echo " clean Remove build artifacts"
139+
@echo " update-dependencies Update Helm chart dependencies"
140+
@echo " add-helm-repositories Add required Helm repos"
141+
@echo " release Package and create a Replicated release"
142+
@echo ""
143+
@echo "Test targets:"
144+
@echo " test-lint Lint and template-render the chart"
145+
@echo " test-install-operators Install cert-manager and CloudNativePG"
146+
@echo " test-install Helm install Gitea with CI values"
147+
@echo " test-smoke Run Python smoke tests"
148+
@echo " test-all Full test sequence (lint -> operators -> install -> smoke)"
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
dependencies:
2-
- name: postgresql
3-
repository: oci://registry-1.docker.io/bitnamicharts
4-
version: 15.5.20
5-
- name: postgresql-ha
6-
repository: oci://registry-1.docker.io/bitnamicharts
7-
version: 14.2.16
8-
- name: redis-cluster
9-
repository: oci://registry-1.docker.io/bitnamicharts
10-
version: 10.3.0
11-
- name: redis
12-
repository: oci://registry-1.docker.io/bitnamicharts
13-
version: 19.6.4
14-
digest: sha256:a28c809273f313c482e3f803a0a002c3bb3a0d2090bf6b732d68ecc4710b4732
15-
generated: "2024-08-03T00:21:16.080925346Z"
2+
- name: valkey
3+
repository: https://valkey.io/valkey-helm/
4+
version: 0.9.3
5+
digest: sha256:7379cfb883db0b651cfdda1338ff7d2b20985c58152603784832478ed2449486
6+
generated: "2026-02-09T15:38:46.097337-05:00"

applications/gitea/charts/gitea/Chart.yaml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
apiVersion: v2
22
appVersion: 1.22.3
33
dependencies:
4-
- condition: postgresql.enabled
5-
name: postgresql
6-
repository: oci://registry-1.docker.io/bitnamicharts
7-
version: 15.5.20
8-
- condition: postgresql-ha.enabled
9-
name: postgresql-ha
10-
repository: oci://registry-1.docker.io/bitnamicharts
11-
version: 14.2.16
12-
- condition: redis-cluster.enabled
13-
name: redis-cluster
14-
repository: oci://registry-1.docker.io/bitnamicharts
15-
version: 10.3.0
16-
- condition: redis.enabled
17-
name: redis
18-
repository: oci://registry-1.docker.io/bitnamicharts
19-
version: 19.6.4
4+
- name: valkey
5+
version: "0.9.3"
6+
repository: "https://valkey.io/valkey-helm/"
7+
condition: valkey.enabled
208
description: Gitea Helm chart for Kubernetes
219
icon: https://gitea.com/assets/img/logo.svg
2210
keywords:
@@ -45,4 +33,4 @@ sources:
4533
- https://github.com/go-gitea/gitea
4634
- https://hub.docker.com/r/gitea/gitea/
4735
type: application
48-
version: 10.6.0
36+
version: 11.0.0

applications/gitea/charts/gitea/templates/_helpers.tpl

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,14 +311,24 @@ https
311311
{{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}}
312312
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}}
313313
{{- end -}}
314-
{{- /* redis queue */ -}}
314+
{{- /* redis/valkey queue */ -}}
315315
{{- if or ((index .Values "redis-cluster").enabled) ((index .Values "redis").enabled) -}}
316316
{{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}}
317317
{{- $_ := set .Values.gitea.config.queue "CONN_STR" (include "redis.dns" .) -}}
318318
{{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}}
319319
{{- $_ := set .Values.gitea.config.session "PROVIDER_CONFIG" (include "redis.dns" .) -}}
320320
{{- $_ := set .Values.gitea.config.cache "ADAPTER" "redis" -}}
321321
{{- $_ := set .Values.gitea.config.cache "HOST" (include "redis.dns" .) -}}
322+
{{- else if .Values.valkey.enabled -}}
323+
{{- $defaultUser := index .Values.valkey.auth.aclUsers "default" -}}
324+
{{- $valkeyHost := printf "%s-valkey" (include "gitea.fullname" .) -}}
325+
{{- $valkeyConnStr := printf "redis://:%s@%s:%v/0?pool_size=100&idle_timeout=180s&" $defaultUser.password $valkeyHost (int .Values.valkey.service.port) -}}
326+
{{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}}
327+
{{- $_ := set .Values.gitea.config.queue "CONN_STR" $valkeyConnStr -}}
328+
{{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}}
329+
{{- $_ := set .Values.gitea.config.session "PROVIDER_CONFIG" $valkeyConnStr -}}
330+
{{- $_ := set .Values.gitea.config.cache "ADAPTER" "redis" -}}
331+
{{- $_ := set .Values.gitea.config.cache "HOST" $valkeyConnStr -}}
322332
{{- else -}}
323333
{{- if not (get .Values.gitea.config.session "PROVIDER") -}}
324334
{{- $_ := set .Values.gitea.config.session "PROVIDER" "memory" -}}
@@ -412,6 +422,21 @@ https
412422
{{- $_ := set .Values.gitea.config.database "USER" .Values.postgresql.global.postgresql.auth.username -}}
413423
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgresql.global.postgresql.auth.password -}}
414424
{{- end -}}
425+
{{- if .Values.postgres.embedded.enabled -}}
426+
{{- $_ := set .Values.gitea.config.database "DB_TYPE" "postgres" -}}
427+
{{- if not (.Values.gitea.config.database.HOST) -}}
428+
{{- $_ := set .Values.gitea.config.database "HOST" (printf "%s-postgres-rw:5432" (include "gitea.fullname" .)) -}}
429+
{{- end -}}
430+
{{- if not (.Values.gitea.config.database.NAME) -}}
431+
{{- $_ := set .Values.gitea.config.database "NAME" .Values.postgres.embedded.initdb.database -}}
432+
{{- end -}}
433+
{{- if not (.Values.gitea.config.database.USER) -}}
434+
{{- $_ := set .Values.gitea.config.database "USER" .Values.postgres.auth.username -}}
435+
{{- end -}}
436+
{{- if not (.Values.gitea.config.database.PASSWD) -}}
437+
{{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgres.auth.password -}}
438+
{{- end -}}
439+
{{- end -}}
415440
{{- end -}}
416441

417442
{{- define "gitea.init-additional-mounts" -}}

0 commit comments

Comments
 (0)