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

Draft: feat(cluster): KUTTL Test Suite #224

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1e40b28
feat(cluster): Exposed backup.barmanObjectStore.wal and backup.barman…
itay-grudev Mar 17, 2024
1ea4720
non-functional KUTTL test suite prototype
itay-grudev Mar 19, 2024
849010d
Bug Fix: MinIO certificates
itay-grudev Mar 20, 2024
6568cf5
KUTTL Workflow
itay-grudev Mar 20, 2024
7b9ce59
Bug Fix: Typo in GitHub Workflow
itay-grudev Mar 20, 2024
32aca18
Making sure krew is available for the KUTTL install step
itay-grudev Mar 20, 2024
dd41ae8
Updated documentation and schema
itay-grudev Mar 20, 2024
816e587
Bug Fix: GitHub Action output dependency syntax
itay-grudev Mar 20, 2024
84844b8
Attempt with correct binary names
itay-grudev Mar 20, 2024
da2ff1a
Exporting the new kubectl-krew path
itay-grudev Mar 20, 2024
ea26439
Experiment with workflows based on path filters
itay-grudev Mar 20, 2024
dc467cd
Improved test speed and increased timeout
itay-grudev Mar 20, 2024
a64897a
Bug Fix: postgresql parameter failing init
itay-grudev Mar 20, 2024
59003b7
Typo: KUTTL action dewscription
itay-grudev Mar 21, 2024
1d67bb7
Added file filters for the operator-test job
itay-grudev Mar 21, 2024
d1ec567
Documentation fixes
itay-grudev Mar 21, 2024
af5ab64
Merge branch 'main' into kuttl
itay-grudev Mar 26, 2024
0e26b38
Merge branch 'main' into kuttl
itay-grudev Mar 28, 2024
442c7e2
Lint fix: duplicate endpointCA after merge
itay-grudev Mar 28, 2024
f5e64d6
Attempt to improve backup performance.
itay-grudev Mar 28, 2024
f5499aa
3 stage attempt with checkpoint and pg_switch_wal()
itay-grudev Mar 28, 2024
c2c6282
Bug Fix: Switched assertions from scheduled backup to manual backup
itay-grudev Mar 28, 2024
e12ff6d
Reordered pg_switch_wal(); CHECKPOINT
itay-grudev Mar 28, 2024
f3f4754
Removed initdb section
itay-grudev Mar 28, 2024
84bab8a
Increased timeout
itay-grudev Mar 29, 2024
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
35 changes: 35 additions & 0 deletions .github/actions/setup-kuttl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Setup KUTTL
description: Installs Krew and KUTTL
outputs:
kubectl-krew-path:
description: The path to the kubectl-krew binary
value: ${{ steps.krew.outputs.path }}
kubectl-kuttl-path:
description: The path to the kubectl-kuttl binary
value: ${{ steps.kuttl.outputs.path }}
runs:
using: composite
steps:
- id: krew
name: Install Krew
shell: bash
run: |
set -x; cd "$(mktemp -d)"
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')"
KREW="krew-${OS}_${ARCH}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"
./"${KREW}" install krew
echo "${KREW_ROOT:-$HOME/.krew}/bin/" >> $GITHUB_PATH
echo "path=${KREW_ROOT:-$HOME/.krew}/bin/kubectl-krew" >> "$GITHUB_OUTPUT"

- id: kuttl
name: Install KUTTL
shell: bash
env:
KREW_PATH: ${{steps.krew.outputs.path}}
run: |
export PATH="$(dirname $KREW_PATH):$PATH"
kubectl krew install kuttl
echo "path=$(which kubectl-kuttl)" >> "$GITHUB_OUTPUT"
24 changes: 11 additions & 13 deletions .github/workflows/tests-cluster-standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
pull_request:
branches-ignore:
- 'gh-pages'
paths:
- .github/
- charts/cluster/
- tests/cluster/
- tests/minio.yaml
- kuttl-test.yaml

jobs:
test-cluster-standalone:
Expand All @@ -20,20 +26,12 @@ jobs:
- name: Deploy the operator
uses: ./.github/actions/deploy-operator

- name: Deploy a standalone cluster
run: |
helm upgrade --install \
--values charts/cluster/examples/basic.yaml \
--namespace database \
--create-namespace \
--wait \
database ./charts/cluster
- name: Install KUTTL
uses: ./.github/actions/setup-kuttl

- name: Verify that the cluster is ready
uses: ./.github/actions/verify-cluster-ready
with:
cluster-name: database-cluster
ready-instances: 1
- name: Run KUTTL tests
run: |
kubectl kuttl test

test-cluster-pgbouncer:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests-operator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
pull_request:
branches-ignore:
- 'gh-pages'
paths:
- .github/
- charts/cloudnative-pg/

jobs:
deploy_operator:
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ helm upgrade --install database \

Refer to the [Cluster Chart documentation](charts/cluster/README.md) for advanced configuration options.

## Provenance

The charts support Helm Provenance and Integrity.
Here is a link to the [PGP key](provenance.gpg) used by GitHub Actions to sign the charts.

## Contributing

Please read the [code of conduct](CODE-OF-CONDUCT.md) and the
Expand Down
11 changes: 4 additions & 7 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,8 @@ In order to create a new release of the `cloudnative-pg` chart, follow these ste
10. Wait for all the checks to pass
11. Two approvals are required in order to merge the PR, if you are a maintainer approve the PR yourself and ask for
another approval, otherwise ask for two approvals directly.
12. Merge the PR squashing all commits and **taking care to keep the commit message to be
`Release cloudnative-pg-vX.Y.Z`**
13. A release `cloudnative-pg-vX.Y.Z` should be automatically created by an action, which will then trigger the release
action. Verify they both are successful.
12. Merge the PR squashing all commits and **taking care to keep the commit message to be `Release cloudnative-pg-vX.Y.Z`**
13. A release `cloudnative-pg-vX.Y.Z` should be automatically created.
14. Once done you should be able to run:
```bash
helm repo add cnpg https://cloudnative-pg.github.io/charts
Expand Down Expand Up @@ -137,9 +135,8 @@ In order to create a new release of the `cluster` chart, follow these steps:
10. Two approvals are required in order to merge the PR, if you are a
maintainer approve the PR yourself and ask for another approval, otherwise
ask for two approvals directly.
11. Merge the PR squashing all commits and **taking care to keep the commit
message to be `Release cluster-vX.Y.Z`**
12. A release `cluster-vX.Y.Z` should be automatically created by an action, which will ten trigger the release action.
11. Merge the PR squashing all commits and **taking care to keep the commit message to be `Release cluster-vX.Y.Z`**
12. A release `cluster-vX.Y.Z` should be automatically created.
Verify they both are successful.
13. Once done you should be able to run:
```bash
Expand Down
2 changes: 2 additions & 0 deletions charts/cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ refer to the [CloudNativePG Documentation](https://cloudnative-pg.io/documentat
| cluster.annotations | object | `{}` | |
| cluster.certificates | string | `nil` | The configuration for the CA and related certificates. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-CertificatesConfiguration |
| cluster.enableSuperuserAccess | bool | `true` | When this option is enabled, the operator will use the SuperuserSecret to update the postgres user password. If the secret is not present, the operator will automatically create one. When this option is disabled, the operator will ignore the SuperuserSecret content, delete it when automatically created, and then blank the password of the postgres user by setting it to NULL. |
| cluster.env | list | `[]` | Env follows the Env format to pass environment variables to the pods created in the cluster |
| cluster.envFrom | list | `[]` | EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env |
| cluster.imageName | string | `""` | Name of the container image, supporting both tags (<image>:<tag>) and digests for deterministic and repeatable deployments: <image>:<tag>@sha256:<digestValue> |
| cluster.imagePullPolicy | string | `"IfNotPresent"` | Image pull policy. One of Always, Never or IfNotPresent. If not defined, it defaults to IfNotPresent. Cannot be updated. More info: https://kubernetes.io/docs/concepts/containers/images#updating-images |
| cluster.imagePullSecrets | list | `[]` | The list of pull secrets to be used to pull the images. See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-LocalObjectReference |
Expand Down
3 changes: 1 addition & 2 deletions charts/cluster/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Alternatively a ticket and a PR if you have found that something needs a change
TODO
----
* IAM Role for S3 Service Account
* Automatic provisioning of a Alert Manager configuration

* Replica Cluster

{{ template "helm-docs.versionFooter" . }}
8 changes: 6 additions & 2 deletions charts/cluster/templates/_barman_object_store.tpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- define "cluster.barmanObjectStoreConfig" -}}

{{- if .scope.endpointURL }}
endpointURL: {{ .scope.endpointURL }}
{{- with .scope.endpointURL }}
endpointURL: {{ . }}
{{- end }}

{{- if or (.scope.endpointCA.create) (.scope.endpointCA.name) }}
Expand All @@ -14,6 +14,10 @@
destinationPath: {{ .scope.destinationPath }}
{{- end }}

{{- with .scope.destinationPath }}
destinationPath: {{ . }}
{{- end }}

{{- if eq .scope.provider "s3" }}
{{- if empty .scope.endpointURL }}
endpointURL: "https://s3.{{ required "You need to specify S3 region if endpointURL is not specified." .scope.s3.region }}.amazonaws.com"
Expand Down
7 changes: 7 additions & 0 deletions charts/cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,12 @@ spec:
- name: {{ include "cluster.fullname" . }}-monitoring
key: custom-queries
{{- end }}

env:
{{- toYaml .Values.cluster.env | nindent 4 }}

envFrom:
{{- toYaml .Values.cluster.envFrom | nindent 4 }}

{{ include "cluster.bootstrap" . | nindent 2 }}
{{ include "cluster.backup" . | nindent 2 }}
6 changes: 6 additions & 0 deletions charts/cluster/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@
"enableSuperuserAccess": {
"type": "boolean"
},
"env": {
"type": "array"
},
"envFrom": {
"type": "array"
},
"imageName": {
"type": "string"
},
Expand Down
11 changes: 9 additions & 2 deletions charts/cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ cluster:
# -- Configuration of the PostgreSQL server.
# See: https://cloudnative-pg.io/documentation/current/cloudnative-pg.v1/#postgresql-cnpg-io-v1-PostgresConfiguration
postgresql: {}
# max_connections: 300
# max_connections: "300"

# -- BootstrapInitDB is the configuration of the bootstrap process when initdb is used.
# See: https://cloudnative-pg.io/documentation/current/bootstrap/
Expand All @@ -186,6 +186,11 @@ cluster:
additionalLabels: {}
annotations: {}

# -- Env follows the Env format to pass environment variables to the pods created in the cluster
env: []

# -- EnvFrom follows the EnvFrom format to pass environment variables sources to the pods to be used by Env
envFrom: []

backups:
# -- You need to configure backups manually, so backups are disabled by default.
Expand All @@ -194,7 +199,9 @@ backups:
# -- Overrides the provider specific default endpoint. Defaults to:
# S3: https://s3.<region>.amazonaws.com"
endpointURL: "" # Leave empty if using the default S3 endpoint
# -- Specifies a CA bundle to validate a privately signed certificate.

# -- Specify a secret containing the CA bundle of the barman endpoint. Useful when using self-signed certificates to
# avoid errors with certificate issuer and barman-cloud-wal-archive
endpointCA:
# -- Creates a secret with the given value if true, otherwise uses an existing secret.
create: false
Expand Down
17 changes: 17 additions & 0 deletions kubeconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
clusters:
- cluster:
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJME1ESXhOREl3TURJMU1Gb1hEVE0wTURJeE1USXdNREkxTUZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTVRYClJuQWlqOC9jRlUzRUhkMGQ0dlVHNDJsYUYzdm9rVEJaWTZZWTAyaVBUSVBiV3BTRlpFbmEycnEvclgxQVNKN0EKN1VIc3c0SzlRYzc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0FURS0tLS0tCg==
server: https://127.0.0.1:44771
name: cluster
contexts:
- context:
cluster: cluster
user: user
name: cluster
current-context: cluster
preferences: {}
users:
- name: user
user:
client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURJVENDQWdtZ0F3SUJBZ0lJWU94aHVNQW5FU0F3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TkRBeU1UUXlNREF5TlRCYUZ3MHlOVEF5TVRNeU1EQXlOVEJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQW9oV0xUUTJ1MUgrTDVnbGMKOFAwU0lLWWJRUUVvSDJXU3lQaVNMeUdUekY0VXNsMzh2RVRRVk1NaUswdnZTWkVBUkV6bGdpL3pSaHlPVklZNgp3Lzh3bjFtRStpa1NDVEdqaDBVSU94c0czODJJNk9aa0RZb1hSQmxKQ3ZTWHBFY2E2RjJLcVZuOVYyYzduYzFOCnRPRURqVzRoRXR4N2NyWHZiUkE3V2tPK2t4RHhQNTFvMHQxdUpTUHpCOTE0Y3NkYlp1OVloaEhsWkJqOGpNQ2kKbGZGdkxlV0x6bHZyN0NaT242eEV3VmlvV1NsMWtEZjlqVDhxNVFlcFNkekZTeTJpLzNvTjgwZ0M4QnJDM2VOYgoreWtSWTVJd253eEV1VXp6YVlLUkNaa3I5akhhVmZMQkQzcEZHYWhRVk1Ea1BoUkcwVjJBSUkraDRrNTF4UmhICmFnWWtod0lEQVFBQm8xWXdWREFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVUgKQXdJd0RBWURWUjBUQVFIL0JBSXdBREFmQmdOVkhTTUVHREFXZ0J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RGK2NEWmd6b1g3Y2FmLzlGbFA3aURtNFZtNVE3MXd0UHZsSVkyUzBSZjFWVSthOURBRAp4MEpZM2xjWU1OTzdCUFIwN1k2aEtKbU5IeUtNS0Nrc21sc2ZOUWduVzhxWnZVV1dTdTN1d0ZkRUxPVzNNQXhwCmUyRTEwTE5seDlYMWNNQVdwNVh6QVFLQmdRQzFRODBFbWRSZ2NTMVRrYm1vTWpVdUFCcnNxam1OTCtZWmlWNmYKK0VGWWpsZEZZODZzVDJrRkFxT2pNeXFIQ1hQR2YxVERRK0pDMUZjbXh4RTd6NmVIeWIrMnRpdkd1WGYwbmNKYwo0VDRNenVOWGRHUWRxVTZVWlp1Tmw0a2ZVeTY1WVJ2K3p3RG1lWHFxSUxLeUtMUlVqV2V3eEZnMDhYY0J6S0c1Ck1hWlM5d0tCZ0ZCWWthU3pHdW5HaXMyWXFPTmtpRUF1ZU1nWVUreEhkUVJMZkZnWkJ6NzVPR2tVbkU0Tk9MQk0KTmNNRTJEaHNZa20yZnVTaE5NR1lEZEx6VXJJK1QwbXVWVkVTWGY1em5CUWllRHU4UEZCNGR5OTRpZGZ1ZE0vdwpad2NrektINDUyU3NmWk5YSVZyMDd0em84OUVPWjIzQzRzMDV4Y3hJc2l0WEVVeGRTemxlCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg==
29 changes: 29 additions & 0 deletions kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
commands:
- command:
helm upgrade
--install
--namespace cnpg-system
--create-namespace
--wait
cnpg ./charts/cloudnative-pg
- command:
helm repo add minio-operator https://operator.min.io
- command:
helm upgrade
--install
--namespace minio-system
--create-namespace
--wait
operator minio-operator/operator
- command:
helm upgrade
--install
--namespace minio
--create-namespace
--wait
--values ./tests/minio.yaml
tenant minio-operator/tenant
testDirs:
- ./tests
10 changes: 10 additions & 0 deletions tests/cluster/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 120
---
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: standalone-cluster
status:
readyInstances: 2
11 changes: 11 additions & 0 deletions tests/cluster/00-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: kubectl -n $NAMESPACE create secret generic kube-root-ca.crt --from-literal=ca.crt="$(kubectl -n kube-system get configmaps kube-root-ca.crt -o jsonpath='{.data.ca\.crt}')" --dry-run=client -o yaml | kubectl apply -f -
- namespaced: true
command:
helm upgrade
--install
--values ./standalone.yaml
--wait
standalone ../../charts/cluster
14 changes: 14 additions & 0 deletions tests/cluster/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 60
---
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
cluster:
name: standalone-cluster
method: barmanObjectStore
status:
phase: running
8 changes: 8 additions & 0 deletions tests/cluster/01-backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
method: barmanObjectStore
cluster:
name: standalone-cluster
14 changes: 14 additions & 0 deletions tests/cluster/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 180
---
apiVersion: postgresql.cnpg.io/v1
kind: Backup
metadata:
name: post-init-backup
spec:
cluster:
name: standalone-cluster
method: barmanObjectStore
status:
phase: completed
27 changes: 27 additions & 0 deletions tests/cluster/02-backup-checkpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: batch/v1
kind: Job
metadata:
name: backup-checkpoint
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: create-checkpoint
env:
- name: DB_URI
valueFrom:
secretKeyRef:
name: standalone-cluster-superuser
key: uri
image: alpine:3.19
command: ['sh', '-c']
args:
- |
apk --no-cache add postgresql-client
DB_URI=$(echo $DB_URI | sed "s|/\*|/|" )
END_TIME=$(( $(date +%s) + 60 ))
while [ $(date +%s) -lt $END_TIME ]; do
psql "$DB_URI" -c "SELECT pg_switch_wal();CHECKPOINT;"
sleep 10
done
24 changes: 24 additions & 0 deletions tests/cluster/standalone.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
mode: standalone
cluster:
instances: 2
storage:
size: 256Mi
backups:
enabled: true
provider: s3
endpointURL: "https://minio.minio.svc.cluster.local"
endpointCA:
name: kube-root-ca.crt
key: ca.crt
wal:
encryption: ""
data:
encryption: ""
s3:
bucket: "mybucket"
path: "/v1"
accessKey: "minio"
secretKey: "minio123"
region: "local"
scheduledBackups: []
retentionPolicy: "30d"
9 changes: 9 additions & 0 deletions tests/minio.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
tenant:
pools:
- servers: 1
name: pool0
volumesPerServer: 1
size: 1Gi
buckets:
- name: mybucket
region: local
Loading