-
Notifications
You must be signed in to change notification settings - Fork 5
feat(gitea): replace Bitnami PostgreSQL and Redis with CNPG and Valkey #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| name: Gitea CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'applications/gitea/charts/**' | ||
| - 'applications/gitea/tests/**' | ||
| - 'applications/gitea/Makefile' | ||
| - '.github/workflows/gitea-ci.yml' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'applications/gitea/charts/**' | ||
| - 'applications/gitea/tests/**' | ||
| - 'applications/gitea/Makefile' | ||
| - '.github/workflows/gitea-ci.yml' | ||
|
|
||
| jobs: | ||
| lint-and-template: | ||
| runs-on: ubuntu-22.04 | ||
| defaults: | ||
| run: | ||
| working-directory: applications/gitea | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@v4.3.0 | ||
| with: | ||
| version: v3.13.3 | ||
|
|
||
| - name: Add Helm repositories | ||
| run: make add-helm-repositories | ||
|
|
||
| - name: Update dependencies | ||
| run: make update-dependencies | ||
|
|
||
| - name: Helm lint | ||
| run: helm lint ./charts/gitea | ||
|
|
||
| - name: Helm template (default values) | ||
| run: helm template gitea ./charts/gitea > /dev/null | ||
|
|
||
| - name: Helm template (CI test values) | ||
| run: helm template gitea ./charts/gitea -f tests/helm/ci-values.yaml > /dev/null | ||
|
|
||
| helm-install-test: | ||
| runs-on: ubuntu-22.04 | ||
| needs: [lint-and-template] | ||
| defaults: | ||
| run: | ||
| working-directory: applications/gitea | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Helm | ||
| uses: azure/setup-helm@v4.3.0 | ||
| with: | ||
| version: v3.13.3 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Create cluster | ||
| id: create-cluster | ||
| uses: replicatedhq/replicated-actions/create-cluster@v1.17.0 | ||
| with: | ||
| api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} | ||
| kubernetes-distribution: k3s | ||
| kubernetes-version: "1.32" | ||
| cluster-name: gitea-ci-${{ github.run_id }} | ||
| disk: 50 | ||
| nodes: 1 | ||
| ttl: 1h | ||
| export-kubeconfig: true | ||
|
|
||
| - name: Install cert-manager | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| helm repo add jetstack https://charts.jetstack.io | ||
| helm repo update jetstack | ||
| helm install cert-manager jetstack/cert-manager \ | ||
| --namespace cert-manager --create-namespace \ | ||
| --set crds.enabled=true \ | ||
| --wait --timeout 5m | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Install CloudNativePG operator | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| helm repo add cnpg https://cloudnative-pg.github.io/charts | ||
| helm repo update cnpg | ||
| helm install cnpg cnpg/cloudnative-pg \ | ||
| --namespace cnpg-system --create-namespace \ | ||
| --wait --timeout 5m | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Install Gitea chart | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| make add-helm-repositories | ||
| make update-dependencies | ||
| helm install gitea ./charts/gitea \ | ||
| -f tests/helm/ci-values.yaml \ | ||
| --wait --timeout 10m | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Wait for pods | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| echo "Waiting for Gitea deployment..." | ||
| kubectl wait --for=condition=Available deployment -l app.kubernetes.io/name=gitea \ | ||
| --timeout=300s | ||
|
|
||
| echo "Waiting for CNPG postgres cluster..." | ||
| kubectl wait --for=condition=Ready pod -l cnpg.io/cluster=gitea-postgres \ | ||
| --timeout=300s | ||
|
|
||
| echo "Waiting for Valkey..." | ||
| kubectl wait --for=condition=Ready pod -l app.kubernetes.io/name=valkey \ | ||
| --timeout=120s | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Run smoke tests | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| python -m venv ./venv | ||
| source ./venv/bin/activate | ||
| pip install -r tests/requirements.txt | ||
| python tests/smoke_test.py --release gitea --namespace default | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Debug output | ||
| if: failure() | ||
| run: | | ||
| KUBECONFIG_FILE="/tmp/kubeconfig-${{ github.run_id }}" | ||
| echo "$KUBECONFIG" > "$KUBECONFIG_FILE" | ||
| export KUBECONFIG="$KUBECONFIG_FILE" | ||
|
|
||
| echo "=== Pods ===" | ||
| kubectl get pods -A | ||
| echo "=== Services ===" | ||
| kubectl get svc | ||
| echo "=== Events ===" | ||
| kubectl get events --sort-by='.lastTimestamp' | tail -40 | ||
| echo "=== Gitea pod logs ===" | ||
| kubectl logs -l app.kubernetes.io/name=gitea --tail=50 || true | ||
| echo "=== CNPG cluster status ===" | ||
| kubectl get clusters.postgresql.cnpg.io -o yaml || true | ||
| echo "=== Postgres pod logs ===" | ||
| kubectl logs -l cnpg.io/cluster=gitea-postgres --tail=30 || true | ||
| env: | ||
| KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }} | ||
|
|
||
| - name: Remove cluster | ||
| uses: replicatedhq/replicated-actions/remove-cluster@v1.17.0 | ||
| if: ${{ always() && steps.create-cluster.outputs.cluster-id != '' }} | ||
| with: | ||
| api-token: ${{ secrets.REPLICATED_PLATFORM_EXAMPLES_TOKEN }} | ||
| cluster-id: ${{ steps.create-cluster.outputs.cluster-id }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,6 @@ | ||
| dependencies: | ||
| - name: postgresql | ||
| repository: oci://registry-1.docker.io/bitnamicharts | ||
| version: 15.5.20 | ||
| - name: postgresql-ha | ||
| repository: oci://registry-1.docker.io/bitnamicharts | ||
| version: 14.2.16 | ||
| - name: redis-cluster | ||
| repository: oci://registry-1.docker.io/bitnamicharts | ||
| version: 10.3.0 | ||
| - name: redis | ||
| repository: oci://registry-1.docker.io/bitnamicharts | ||
| version: 19.6.4 | ||
| digest: sha256:a28c809273f313c482e3f803a0a002c3bb3a0d2090bf6b732d68ecc4710b4732 | ||
| generated: "2024-08-03T00:21:16.080925346Z" | ||
| - name: valkey | ||
| repository: https://valkey.io/valkey-helm/ | ||
| version: 0.9.3 | ||
| digest: sha256:7379cfb883db0b651cfdda1338ff7d2b20985c58152603784832478ed2449486 | ||
| generated: "2026-02-09T15:38:46.097337-05:00" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -311,14 +311,24 @@ https | |
| {{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}} | ||
| {{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}} | ||
| {{- end -}} | ||
| {{- /* redis queue */ -}} | ||
| {{- /* redis/valkey queue */ -}} | ||
| {{- if or ((index .Values "redis-cluster").enabled) ((index .Values "redis").enabled) -}} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we've removed redis, should we remove this stanza?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the stanza is for upstream compatibility since we're vendoring the Gitea chart; if we completely remove the redis stanza we'll have to keep removing it on every rebase from upstream — since both |
||
| {{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.queue "CONN_STR" (include "redis.dns" .) -}} | ||
| {{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.session "PROVIDER_CONFIG" (include "redis.dns" .) -}} | ||
| {{- $_ := set .Values.gitea.config.cache "ADAPTER" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.cache "HOST" (include "redis.dns" .) -}} | ||
| {{- else if .Values.valkey.enabled -}} | ||
| {{- $defaultUser := index .Values.valkey.auth.aclUsers "default" -}} | ||
| {{- $valkeyHost := printf "%s-valkey" (include "gitea.fullname" .) -}} | ||
| {{- $valkeyConnStr := printf "redis://:%s@%s:%v/0?pool_size=100&idle_timeout=180s&" $defaultUser.password $valkeyHost (int .Values.valkey.service.port) -}} | ||
| {{- $_ := set .Values.gitea.config.queue "TYPE" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.queue "CONN_STR" $valkeyConnStr -}} | ||
| {{- $_ := set .Values.gitea.config.session "PROVIDER" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.session "PROVIDER_CONFIG" $valkeyConnStr -}} | ||
| {{- $_ := set .Values.gitea.config.cache "ADAPTER" "redis" -}} | ||
| {{- $_ := set .Values.gitea.config.cache "HOST" $valkeyConnStr -}} | ||
| {{- else -}} | ||
| {{- if not (get .Values.gitea.config.session "PROVIDER") -}} | ||
| {{- $_ := set .Values.gitea.config.session "PROVIDER" "memory" -}} | ||
|
|
@@ -412,6 +422,21 @@ https | |
| {{- $_ := set .Values.gitea.config.database "USER" .Values.postgresql.global.postgresql.auth.username -}} | ||
| {{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgresql.global.postgresql.auth.password -}} | ||
| {{- end -}} | ||
| {{- if .Values.postgres.embedded.enabled -}} | ||
| {{- $_ := set .Values.gitea.config.database "DB_TYPE" "postgres" -}} | ||
| {{- if not (.Values.gitea.config.database.HOST) -}} | ||
| {{- $_ := set .Values.gitea.config.database "HOST" (printf "%s-postgres-rw:5432" (include "gitea.fullname" .)) -}} | ||
| {{- end -}} | ||
| {{- if not (.Values.gitea.config.database.NAME) -}} | ||
| {{- $_ := set .Values.gitea.config.database "NAME" .Values.postgres.embedded.initdb.database -}} | ||
| {{- end -}} | ||
| {{- if not (.Values.gitea.config.database.USER) -}} | ||
| {{- $_ := set .Values.gitea.config.database "USER" .Values.postgres.auth.username -}} | ||
| {{- end -}} | ||
| {{- if not (.Values.gitea.config.database.PASSWD) -}} | ||
| {{- $_ := set .Values.gitea.config.database "PASSWD" .Values.postgres.auth.password -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- define "gitea.init-additional-mounts" -}} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.