Skip to content
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

Bump db-operator appVersion to 2.0.0 #16

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9477c87
Migrate project to the `db-operator` org (#1)
allanger Apr 17, 2023
33af3a1
Create postgres databases from template (#2)
allanger Apr 18, 2023
95efee7
Keep up with k8s versions (#4)
allanger Jun 15, 2023
53209e4
fix(db-operator): Now db-instance is guarded by if condition as well …
allanger Jun 16, 2023
bce0f4d
Add an ability to set labels per dbinstance (#6)
allanger Jul 17, 2023
13c4875
Make the webhook optional (#7)
allanger Aug 8, 2023
a1ec5cf
Upgrade db operator version to 1.13.1 (#10)
allanger Aug 16, 2023
9728f48
fix: Configure the dbuser webhook with values (#12)
allanger Sep 7, 2023
93f2970
Split controller and webhook in two separate deployments (#13)
bobertrublik Sep 23, 2023
7a65868
docs: How to upgrade db-operator to 1.11.0 (#14)
allanger Sep 29, 2023
126af30
Upgrade db-operator version to v1.14.1 (#15)
allanger Sep 29, 2023
160d802
Release patches for gsql instances (#19)
allanger Oct 19, 2023
b01a5b4
Upgrade db operator to v1.15.3 (#18)
allanger Oct 27, 2023
0bf0dc7
Update db-operator to 1.16.1 (#21)
allanger Oct 31, 2023
4921bc6
Upgrade db-operator version to 1.16.3 (#22)
allanger Oct 31, 2023
15731a2
Service monitor per dbin (#25)
allanger Nov 29, 2023
fbaad01
Set PG_EXPORTER_AUTO_DISCOVERY to true for the pg_exporter (#23)
allanger Nov 29, 2023
4fbd6aa
Set the same line ending everywhere (#26)
allanger Nov 29, 2023
7bc4ab8
Upgrade the version to release the last change (#27)
allanger Nov 29, 2023
b725be9
Upgrade db-operator to v1.17.0 (#24)
allanger Dec 12, 2023
51b5789
Bump db-operator to 2.0.0
allanger Dec 15, 2023
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
59 changes: 59 additions & 0 deletions .github/workflows/db-instances-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: Test db-instances chart
on: push

env:
HELM_VERSION: "3.12.1"
PYTHON_VERSION: "3.9"

jobs:
test-chart:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: "v${{ env.HELM_VERSION }}"

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
check-latest: true

- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ "$changed" == *"db-instances"* ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --validate-maintainers=false --target-branch main --charts charts/db-instances

- name: Setup helmfile
uses: mamezou-tech/[email protected]

- name: Create kind cluster
uses: helm/[email protected]

- name: Install helm dependnencies
run: |
helmfile -f charts/db-instances/ci/helmfile.yaml -l name=prometheus-stack sync
helmfile -f charts/db-instances/ci/helmfile.yaml sync
sleep 60

- name: Run chart-testing (install)
run: ct install --target-branch main --charts charts/db-instances
# -- TODO: Enable once there is a tested version released
# - name: Run chart-testing (upgrade)
# run: ct install --target-branch main --upgrade --charts charts/db-instances
50 changes: 40 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Test

on:
Expand All @@ -7,31 +8,34 @@ on:
pull_request:
branches:
- main
env:
HELM_VERSION: 3.12.1
PYTHON_VERSION: 3.9

jobs:
get-chart:
get-chart:
runs-on: ubuntu-latest
outputs:
changed_charts: ${{ steps.get-chart.outputs.changed_charts }}
steps:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: charts
fetch-depth: 2 # to be able to obtain files changed in the latest commit

- id: get-chart
name: 'Get modified charts'
name: "Get modified charts"
run: |
cd charts
files_changed="$(git diff --name-only HEAD^ HEAD)"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "charts/[^/]*" | sed "s|charts/||g" | uniq | tr '\n' ' ' || true)"
echo "changed:${charts_dirs_changed}"
echo "::set-output name=changed_charts::${charts_dirs_changed}"
lint:
lint:
runs-on: ubuntu-latest
steps:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
Expand All @@ -49,20 +53,46 @@ jobs:
- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs helm --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --validate-maintainers=false --target-branch main

test-values:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Run the test
run: |
cd charts/db-operator
./scripts/test_values -p ./ci/unit-test

db-operator-test:
runs-on: ubuntu-latest
needs: get-chart
if: ${{ contains(needs.get-chart.outputs.changed_charts, 'db-operator') || contains(needs.get-chart.outputs.changed_charts, 'db-instances') }}
strategy:
matrix:
k8s_version: ['v1.21.6', 'v1.22.3', 'v1.23.1', 'v1.24.3']
k8s_version:
- v1.22.8
- v1.23.5
- v1.24.16
- v1.25.12
- v1.26.7
- v1.27.4
steps:
- name: Checkout
uses: actions/checkout@v3

# The existing apparmor profile for mysql needs to be removed.
# https://github.com/actions/virtual-environments/issues/181
# https://github.com/moby/moby/issues/7512#issuecomment-51845976
Expand All @@ -73,17 +103,17 @@ jobs:
sudo apt-get update -y
sudo apt-get install apparmor-profiles
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld

- name: Create k3d cluster
env:
K8S_VERSION: ${{ matrix.k8s_version }}
run: make k3d

- name: Install Cert Manager
run: make cert-manager

- name: Install Helm chart
run: make db-operator

- name: Integration test
run: ./tests/db-operator/integration.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ For triggering it, change the version of Chart.yaml in the chart directory and m

## Configuring helm client
```
$ helm repo add kloeckneri https://kloeckner-i.github.io/charts
$ helm repo add db-operator https://db-operator.github.io/charts
```
Test the helm chart repository
```
$ helm search repo kloeckneri
$ helm search repo db-operator
```
2 changes: 1 addition & 1 deletion charts/db-instances/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: Database Instances for db operator
name: db-instances
version: 1.4.0
version: 2.1.1
2 changes: 1 addition & 1 deletion charts/db-instances/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Create DB Instance resources for is DB Operator
## Installing Chart
To install the chart with the release name my-release:
```
$ helm install --name my-release kloeckneri/db-instances
$ helm install --name my-release db-operator/db-instances
```
The command deploys DB Operator on Kubernetes with default configuration.

Expand Down
5 changes: 2 additions & 3 deletions charts/db-instances/ci/ci-1-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dbinstances:
instance1:
serviceMonitor:
enabled: true
engine: postgres
monitoring:
enabled: true
Expand All @@ -13,6 +15,3 @@ dbinstances:
secrets:
adminUser: adminUser
adminPassword: adminAdmin

serviceMonitor:
enabled: true
18 changes: 18 additions & 0 deletions charts/db-instances/ci/ci-test-service-monitor-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
dbinstances:
instance1:
serviceMonitor:
enabled: true
engine: postgres
monitoring:
autodiscovery: true
enabled: true
generic:
host: postgres-instance-postgresql.postgres
port: 5432
secrets:
adminUser: postgres
adminPassword: 123123!!
tests:
serviceMonitor:
enabled: true
instance: instance1
56 changes: 56 additions & 0 deletions charts/db-instances/ci/helmfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
repositories:
- name: bitnami
url: https://charts.bitnami.com/bitnami
- name: prometheus-community
url: https://prometheus-community.github.io/helm-charts
- name: jetstack
url: https://charts.jetstack.io

charts:
- name: cert-manager
chart: jetstack/cert-manager
namespace: cert-manager
createNamespace: true
needs:
- monitoring/prometheus-stack
values:
- installCRDs: true
- name: postgres-instance
installed: true
namespace: postgres
createNamespace: true
chart: bitnami/postgresql
needs:
- monitoring/prometheus-stack
values:
- global:
postgresql:
auth:
postgresPassword: 123123!!
- name: prometheus-stack
namespace: monitoring
createNamespace: true
disableValidationOnInstall: true
chart: prometheus-community/kube-prometheus-stack
values:
- prometheus:
prometheusSpec:
enableAdminAPI: true
podMonitorNamespaceSelector:
any: true
podMonitorSelector: {}
podMonitorSelectorNilUsesHelmValues: false
ruleNamespaceSelector:
any: true
ruleSelector: {}
ruleSelectorNilUsesHelmValues: false
serviceMonitorNamespaceSelector:
any: true
serviceMonitorSelector: {}
serviceMonitorSelectorNilUsesHelmValues: false
- name: db-operator
namespace: db-operator
createNamespace: true
chart: ../../db-operator
needs:
- cert-manager/cert-manager
42 changes: 42 additions & 0 deletions charts/db-instances/files/test_service_monitor
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
# ---------------------------------------------------------------------
# -- This test should wait for the pg_exporter to be available
# -- and then try to get the metrics from Prometheus
# ---------------------------------------------------------------------
SKIP_INSTALL_DEPS="${TEST_SKIP_INSTALL_DEPS}"
SCRAPE_INTERVAL="${TEST_SCRAPE_INTERVAL:-30}"
PROM_URL="${TEST_PROM_URL:-prometheus-operated.monitoring}"
QUERY="${TEST_QUERY:-pg_up}"
ATTEMPTS_AMOUNT="${TEST_ATTEMPTS_AMOUNT:-10}"
ATTEMPTS_PAUSE="${TEST_ATTEMPTS_PAUSE:-30}"

if [ -n "${SKIP_INSTALL_DEPS+x}" ]
then
apk update && apk add jq
fi

sleep "${SCRAPE_INTERVAL}"

for x in $(seq 1 "${ATTEMPTS_AMOUNT}")
do
echo "attempt: ${x}"
QUERY_URL="http://${PROM_URL}:9090/api/v1/query?query=${QUERY}"
CURL_RES=$(curl -q "${QUERY_URL}")
STATUS=$(echo "$CURL_RES" | jq -r '.status')
if [ "$STATUS" != "success" ]
then
echo "metric doesn't have a status 'success' in the prometheus"
echo "curl output is: $CURL_RES"
fi
# -- for some reason this jq query only works with pips in the pod
METRIC_NAME=$(curl -q "${QUERY_URL}" | jq -r '.data.result | .[] | .metric.__name__')
if [ "${METRIC_NAME}" != "${QUERY}" ]
then
echo "query didn't return expected name"
echo "${METRIC_NAME}"
else
exit 0
fi
sleep "${ATTEMPTS_PAUSE}"
done

5 changes: 4 additions & 1 deletion charts/db-instances/templates/dbinstance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- if .Values.dbinstances }}
{{- range $name, $value := .Values.dbinstances }}
---
apiVersion: "kci.rocks/v1beta1"
apiVersion: "kinda.rocks/v1beta1"
kind: "DbInstance"
metadata:
name: {{ $name }}
Expand All @@ -13,6 +13,9 @@ metadata:
{{- end }}
labels:
{{- include "db-instances.labels" $ | nindent 4 }}
{{- with $value.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
engine: {{ $value.engine }}
{{- if $value.existingAdminSecret }}
Expand Down
Loading
Loading