diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index b308341..43c2bfe 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -92,10 +92,13 @@ jobs: - name: Start Minikube cluster run: just cluster-start - *install-helm-step - - *install-ct-step - *add-chart-repos-step - - name: Install and test charts - run: ct install --config ./configs/chart-testing.yaml --all + - name: Build chart dependencies + run: just build-chart-deps + - name: Install charts + run: just deploy-all + - name: Test charts + run: just test-all spell-checker: runs-on: ubuntu-latest diff --git a/Justfile b/Justfile index 3b441c3..a834775 100644 --- a/Justfile +++ b/Justfile @@ -7,6 +7,10 @@ cluster := "eaasi" # Name of the cluster namespace namespace := "eaasi" +# Defaults for database-cluster +database_cluster_name := "database-cluster" +database_cluster_ns := "database" + ### HELPERS ################################################################### # Run spell checker @@ -43,7 +47,7 @@ update-changelog chart version="" dir=(chart_dir / chart): # Add external chart repositories add-chart-repos: - # TODO: add repos! + helm repo add "cnpg" "https://cloudnative-pg.github.io/charts" # Build dependencies for all charts build-chart-deps: @@ -80,6 +84,10 @@ render chart name=chart ns=namespace *args="": helm template "{{ name }}" "{{ chart_dir / chart }}" \ --namespace "{{ ns }}" {{ args }} | less +# Test a Helm chart release +test release ns=namespace *args="": + helm test "{{ release }}" --namespace "{{ ns }}" {{ args }} + ### MINIKUBE ################################################################## # Start a Minikube cluster @@ -106,3 +114,26 @@ cluster-unpause name=cluster: # Delete a Minikube cluster cluster-delete name=cluster: minikube delete --profile "{{ name }}" + +### EAASI ##################################################################### + +# Deploy the database-operator +deploy-database-operator name="database-operator" ns="cnpg-system" *args="--wait": \ + (upgrade "database" name ns "-f" (chart_dir / "database/configs/operator.yaml") args) + +# Deploy the database-cluster +deploy-database-cluster name=database_cluster_name ns=database_cluster_ns *args="--wait": \ + (upgrade "database" name ns args) + +# Deploy all components +deploy-all: \ + (deploy-database-operator) \ + (deploy-database-cluster) \ + +# Test the database-cluster +test-database-cluster name=database_cluster_name ns=database_cluster_ns *args="": \ + (test name ns args) + +# Test all components +test-all: \ + (test-database-cluster) \ diff --git a/README.md b/README.md index 776ec01..e1259c5 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ $ helm search repo eaasi ## Charts For more details, see the documentation for each chart: +- [database](./charts/database/README.md) ## Development @@ -113,6 +114,18 @@ Next, rebuild all required chart dependencies with: $ just build-chart-deps ``` +The [database](./charts/database) operator can be deployed with: + +```console +$ just deploy-database-operator # +``` + +Then, a [database](./charts/database) cluster can be deployed with: + +```console +$ just deploy-database-cluster # +``` + ## License Helm charts for EAASI are distributed under the [Apache-2.0](./LICENSE) license. diff --git a/charts/.gitkeep b/charts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/charts/database/.helmignore b/charts/database/.helmignore new file mode 100644 index 0000000..6e75903 --- /dev/null +++ b/charts/database/.helmignore @@ -0,0 +1,26 @@ +# Patterns to ignore when building packages. + +CHANGELOG.md +.DS_Store + +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ + +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ + +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/database/CHANGELOG.md b/charts/database/CHANGELOG.md new file mode 100644 index 0000000..655bf65 --- /dev/null +++ b/charts/database/CHANGELOG.md @@ -0,0 +1,29 @@ +# Changelog + + +## 0.5.0 - *2025-08-26* + +### Features + +- Add initial operator config - ([`ec01985`](https://github.com/eaasi/helm-charts/commit/ec019857db9d8ec8d4421df9d57e51fd8fdfb62d) by @O7EG) +- Add initial cluster config - ([`21e72aa`](https://github.com/eaasi/helm-charts/commit/21e72aae7a91ec2a3f894018a359cc42b2c045c6) by @O7EG) +- Configure cluster's pod affinity - ([`0253975`](https://github.com/eaasi/helm-charts/commit/0253975bb5445897edc45eb2cda7aaeaa035c686) by @O7EG) +- Add connection pooler for the primary instance - ([`c9730a7`](https://github.com/eaasi/helm-charts/commit/c9730a7a5adc9841ad6824249b7ff0517edb4e0c) by @O7EG) + +### Continuous Integration + +- Add helper for deploying database-operators - ([`39478ba`](https://github.com/eaasi/helm-charts/commit/39478ba46fde82d5b0ea5590634c726578059b61) by @O7EG) + +### Documentation + +- Add initial README - ([`87fd8c4`](https://github.com/eaasi/helm-charts/commit/87fd8c48e4324b1b78ce2d6479552d269663e92d) by @O7EG) +- Describe a basic deployment procedure - ([`9d7d3b2`](https://github.com/eaasi/helm-charts/commit/9d7d3b2c308255e1b4f372e729aecd03edcbc26c) by @O7EG) +- Describe available configuration parameters - ([`56558e6`](https://github.com/eaasi/helm-charts/commit/56558e6cb1bda369c8e47f1cc1b55de53a8259c5) by @O7EG) + +### Miscellaneous + +- Add initial `.helmignore` - ([`f830406`](https://github.com/eaasi/helm-charts/commit/f830406e30a9325a45db7c6c0a5e64b226fa4fe9) by @O7EG) +- Add initial chart metadata - ([`631b0e6`](https://github.com/eaasi/helm-charts/commit/631b0e62c074e8552b3457ef2a7e6e0d96e138a8) by @O7EG) +- Add dependency `@cnpg/cloudnative-pg` v0.23.2 - ([`d334337`](https://github.com/eaasi/helm-charts/commit/d3343379e2255eb0b61718417e52cd2f8a71103b) by @O7EG) +- Add dependency `@cnpg/cluster` v0.2.1 - ([`84049a2`](https://github.com/eaasi/helm-charts/commit/84049a228fc9766b13e253dd364debc64ea838d5) by @O7EG) +- Fail early when operator and cluster are enabled - ([`0ffa5c5`](https://github.com/eaasi/helm-charts/commit/0ffa5c5ff5c9c4cd5276fba0dd8503632e8b9d41) by @O7EG) diff --git a/charts/database/Chart.lock b/charts/database/Chart.lock new file mode 100644 index 0000000..d0413a0 --- /dev/null +++ b/charts/database/Chart.lock @@ -0,0 +1,9 @@ +dependencies: +- name: cloudnative-pg + repository: https://cloudnative-pg.github.io/charts + version: 0.23.2 +- name: cluster + repository: https://cloudnative-pg.github.io/charts + version: 0.2.1 +digest: sha256:a08a4edc8fc4f25677834d9157b702c8eeb5c33ace93f60fd5f450f5ce393d76 +generated: "2025-03-20T17:10:37.269076118+01:00" diff --git a/charts/database/Chart.yaml b/charts/database/Chart.yaml new file mode 100644 index 0000000..37206a2 --- /dev/null +++ b/charts/database/Chart.yaml @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2025 Yale University +# SPDX-License-Identifier: Apache-2.0 + +apiVersion: v2 +name: database +version: "0.5.0" +description: EAASI Database Helm Chart +type: application +sources: + - https://github.com/eaasi/helm-charts +dependencies: + - repository: "@cnpg" + name: cloudnative-pg + version: "0.23.2" + alias: operator + condition: operator.enabled + - repository: "@cnpg" + name: cluster + version: "0.2.1" + condition: cluster.enabled diff --git a/charts/database/README.md b/charts/database/README.md new file mode 100644 index 0000000..c36ae5b --- /dev/null +++ b/charts/database/README.md @@ -0,0 +1,41 @@ +# EAASI Database Helm Chart + +This Helm chart deploys the EAASI Database on [Kubernetes](https://kubernetes.io/) using the [Helm](https://helm.sh) package manager. + +## Getting Started + +This chart depends on the [operator](https://github.com/cloudnative-pg/charts/tree/main/charts/cloudnative-pg) and the [cluster](https://github.com/cloudnative-pg/charts/tree/main/charts/cluster) charts from the [CloudNativePG](https://github.com/cloudnative-pg) project. + +### Adding the Repositories + +```console +$ helm repo add cnpg "https://cloudnative-pg.github.io/charts" +$ helm repo add eaasi "https://eaasi.github.io/helm-charts" +``` + +### Installing the Operator + +First, the *CNPG operator* must be installed, since it provides several CRDs required for setting up new database *clusters*. +Skip this step if the operator is already installed in your K8s cluster: + +```console +$ helm install database-operator eaasi/database \ + --namespace cnpg-system --create-namespace \ + -f ./configs/operator.yaml +``` + +### Creating a Cluster + +A new *CNPG cluster* can be created with the following command: + +```console +$ helm install database-cluster eaasi/database \ + --namespace database --create-namespace +``` + +## Configuration + +A minimal configuration for an operator and a cluster is provided in the default [values.yaml](./values.yaml) file. +For further details on all available parameters, please refer to the configuration files of the upstream [operator](https://github.com/cloudnative-pg/charts/tree/main/charts/cloudnative-pg) and [cluster](https://github.com/cloudnative-pg/charts/tree/main/charts/cluster) charts. + +The extensive documentation for the CloudNativePG project can be found [here](https://cloudnative-pg.io/documentation/current/). diff --git a/charts/database/configs/operator.yaml b/charts/database/configs/operator.yaml new file mode 100644 index 0000000..6ba6cd7 --- /dev/null +++ b/charts/database/configs/operator.yaml @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2025 Yale University +# SPDX-License-Identifier: Apache-2.0 + +# Override values for installing the operator + +operator: + # Enable the operator + enabled: true + +cluster: + # Disable the cluster + enabled: false diff --git a/charts/database/templates/assertions.yaml b/charts/database/templates/assertions.yaml new file mode 100644 index 0000000..549ea95 --- /dev/null +++ b/charts/database/templates/assertions.yaml @@ -0,0 +1,6 @@ +# SPDX-FileCopyrightText: 2025 Yale University +# SPDX-License-Identifier: Apache-2.0 + +{{- if and .Values.operator.enabled .Values.cluster.enabled -}} +{{- fail "Either the operator or the cluster should be enabled, not both!" -}} +{{- end -}} diff --git a/charts/database/values.yaml b/charts/database/values.yaml new file mode 100644 index 0000000..206b9c0 --- /dev/null +++ b/charts/database/values.yaml @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2025 Yale University +# SPDX-License-Identifier: Apache-2.0 + +# Default values for the EAASI Database + +# Configuration for the CNPG operator: +# https://github.com/cloudnative-pg/charts/tree/main/charts/cloudnative-pg +operator: + # -- Should the operator be enabled? + enabled: false + # -- Override operator name + fullnameOverride: cnpg-operator + # -- Override subchart name + # NOTE: The original chart name must be used here for now, because + # the upstream chart hard-codes it in multiple templates! + nameOverride: cloudnative-pg + # -- Number of replicas + replicaCount: 1 + +# Configuration for the CNPG cluster: +# https://github.com/cloudnative-pg/charts/tree/main/charts/cluster +cluster: + # -- Should the cluster be enabled? + enabled: true + # -- Override cluster name + fullnameOverride: eaasi + # -- Override subchart name + nameOverride: database-cluster + # -- Cluster mode of operation + mode: standalone + # -- Type of the CNPG database + type: postgresql + # -- Version of the CNPG database + version: + postgresql: "17.4" + # -- CNPG cluster config + cluster: + # -- Number of instances + instances: 1 + # -- Affinity rules for Pods + affinity: + enablePodAntiAffinity: true + podAntiAffinityType: preferred + topologyKey: kubernetes.io/hostname + # -- Database storage config + storage: + size: 1Gi + # -- PgBouncer poolers + poolers: + - name: rw + type: rw + instances: 1 + poolMode: transaction + parameters: + max_client_conn: "250" + default_pool_size: "20" + reserve_pool_size: "5" + min_pool_size: "5" diff --git a/configs/committed.toml b/configs/committed.toml index 39dcc37..ba8dcaf 100644 --- a/configs/committed.toml +++ b/configs/committed.toml @@ -24,3 +24,8 @@ allowed_types = [ "style", "test", ] + +# allowed commit scopes +allowed_scopes = [ + "database", +] diff --git a/configs/typos.toml b/configs/typos.toml index 8d38a84..c727fa6 100644 --- a/configs/typos.toml +++ b/configs/typos.toml @@ -6,6 +6,9 @@ extend-ignore-re = [ "(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", # ignore blocks with "spellchecker:" "(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on", + # ignore false positives triggered by "ba" surrounded by numbers + "[0-9]+ba", + "ba[0-9]+", ] [default.extend-words]