-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
574a1ec
commit 9c4c452
Showing
382 changed files
with
15,625 additions
and
1,307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
171 changes: 171 additions & 0 deletions
171
doc/content/en/06-crd-reference/12-sgshardedcluster/_index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
--- | ||
title: SGShardedCluster | ||
weight: 12 | ||
url: reference/crd/sgshardedcluster | ||
description: Details about SGShardedCluster | ||
showToc: true | ||
--- | ||
|
||
StackGres PostgreSQL sharded clusters are created using the `SGShardedCluster` custom resource. | ||
|
||
___ | ||
|
||
**Kind:** SGShardedCluster | ||
|
||
**listKind:** SGShardedClusterList | ||
|
||
**plural:** sgshardedclusters | ||
|
||
**singular:** sgshardedcluster | ||
___ | ||
|
||
**Spec** | ||
|
||
| <div style="width:12rem">Property</div> | Required | Updatable | <div style="width:5rem">Type</div> | Default | Description | | ||
|:-------------------------------------------------------------------------------------------|----------|-----------|:-----------------------------------|:------------------|:-------------------------------------------------------------------| | ||
| type | ✓ | ✓ | string | | {{< crd-field-description SGShardedCluster.spec.type >}} | | ||
| database | ✓ | ✓ | string | | {{< crd-field-description SGShardedCluster.spec.database >}} | | ||
| [postgres](#postgres) | | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.postgres >}} | | ||
| [coordinator](#coordinator) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.coordinator >}} | | ||
| [shards](#shards) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.shards >}} | | ||
| prometheusAutobind | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.prometheusAutobind >}} | | ||
| [nonProductionOptions](#non-production-options) | | ✓ | array | | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions >}} | | ||
|
||
Example: | ||
|
||
```yaml | ||
apiVersion: stackgres.io/v1alpha1 | ||
kind: SGShardedCluster | ||
metadata: | ||
name: stackgres | ||
spec: | ||
postgres: | ||
version: 'latest' | ||
coordinator: | ||
instances: 1 | ||
pods: | ||
persistentVolume: | ||
size: '5Gi' | ||
shards: | ||
clusters: 2 | ||
instancesPerCluster: 1 | ||
pods: | ||
persistentVolume: | ||
size: '5Gi' | ||
``` | ||
## Postgres | ||
| <div style="width:6rem">Property</div> | Required | Updatable | <div style="width:4rem">Type</div> | Default | Description | | ||
|:---------------------------------------|----------|-----------|:-----------------------------------|:---------|:-----------------------------------------------------------------| | ||
| version | ✓ | ✓ | string | | {{< crd-field-description SGShardedCluster.spec.postgres.version >}} | | ||
## Coordinator | ||
| <div style="width:12rem">Property</div> | Required | Updatable | <div style="width:5rem">Type</div> | Default | Description | | ||
|:-------------------------------------------------------------------------------------------|----------|-----------|:-----------------------------------|:------------------|:-------------------------------------------------------------------| | ||
| instances | ✓ | ✓ | integer | | {{< crd-field-description SGShardedCluster.spec.coordinator.instances >}} | | ||
| [sgInstanceProfile]({{% relref "/06-crd-reference/02-sginstanceprofile" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.coordinator.sgInstanceProfile >}} | | ||
| [pods](#pods) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.coordinator.pods >}} | | ||
| [configurations](#configurations) | | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.coordinator.configurations >}} | | ||
## Coordinator Pods | ||
Cluster's pod configuration | ||
| <div style="width:14rem">Property</div> | Required | Updatable | <div style="width:5rem">Type</div> | <div style="width:4rem">Default</div> | Description | | ||
|:----------------------------------------|----------|-----------|:-----------------------------------|:--------------------------------------|:------------| | ||
| [persistentVolume](#shards-persistent-volume) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.coordinator.pods.persistentVolume >}} | | ||
### SCoordinatorhards Persistent Volume | ||
Configuration of the persistent volumes that the cluster pods are going to use. | ||
| <div style="width:7rem">Property</div> | Required | Updatable | <div style="width:4rem">Type</div> | <div style="width:11rem">Default</div> | Description | | ||
|:---------------------------------------|----------|-----------|:-----------------------------------|:---------------------------------------|:------------| | ||
| size | ✓ | ✓ | string | | {{< crd-field-description SGShardedCluster.spec.coordinator.pods.persistentVolume.size >}} | | ||
| storageClass | | ✓ | string | default storage class | {{< crd-field-description SGShardedCluster.spec.coordinator.pods.persistentVolume.storageClass >}} | | ||
```yaml | ||
apiVersion: stackgres.io/v1alpha1 | ||
kind: SGShardedCluster | ||
metadata: | ||
name: stackgres | ||
spec: | ||
pods: | ||
persistentVolume: | ||
size: '5Gi' | ||
storageClass: default | ||
``` | ||
## Coordinator Configurations | ||
Custom Postgres configuration. | ||
| <div style="width:9rem">Property</div> | Required | Updatable | <div style="width:4rem">Type</div> | Default | Description | | ||
|:--------------------------------------------------------------------------|----------|-----------|:-----------------------------------|:------------------|:------------| | ||
| [sgPostgresConfig]({{% relref "06-crd-reference/03-sgpostgresconfig" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.coordinator.configurations.sgPostgresConfig >}} | | ||
| [sgPoolingConfig]({{% relref "06-crd-reference/04-sgpoolingconfig" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.coordinator.configurations.sgPoolingConfig >}} | | ||
## Shards | ||
| <div style="width:12rem">Property</div> | Required | Updatable | <div style="width:5rem">Type</div> | Default | Description | | ||
|:-------------------------------------------------------------------------------------------|----------|-----------|:-----------------------------------|:------------------|:-------------------------------------------------------------------| | ||
| clusters | ✓ | ✓ | integer | | {{< crd-field-description SGShardedCluster.spec.shards.clusters >}} | | ||
| instancesPerCluster | ✓ | ✓ | integer | | {{< crd-field-description SGShardedCluster.spec.shards.instancesPerCluster >}} | | ||
| [sgInstanceProfile]({{% relref "/06-crd-reference/02-sginstanceprofile" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.shards.sgInstanceProfile >}} | | ||
| [pods](#shards-pods) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.shards.pods >}} | | ||
| [configurations](#shards-configurations) | | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.shards.configurations >}} | | ||
## Shards Pods | ||
Cluster's pod configuration | ||
| <div style="width:14rem">Property</div> | Required | Updatable | <div style="width:5rem">Type</div> | <div style="width:4rem">Default</div> | Description | | ||
|:----------------------------------------|----------|-----------|:-----------------------------------|:--------------------------------------|:------------| | ||
| [persistentVolume](#shards-persistent-volume) | ✓ | ✓ | object | | {{< crd-field-description SGShardedCluster.spec.shards.pods.persistentVolume >}} | | ||
### Shards Persistent Volume | ||
Configuration of the persistent volumes that the cluster pods are going to use. | ||
| <div style="width:7rem">Property</div> | Required | Updatable | <div style="width:4rem">Type</div> | <div style="width:11rem">Default</div> | Description | | ||
|:---------------------------------------|----------|-----------|:-----------------------------------|:---------------------------------------|:------------| | ||
| size | ✓ | ✓ | string | | {{< crd-field-description SGShardedCluster.spec.shards.pods.persistentVolume.size >}} | | ||
| storageClass | | ✓ | string | default storage class | {{< crd-field-description SGShardedCluster.spec.shards.pods.persistentVolume.storageClass >}} | | ||
```yaml | ||
apiVersion: stackgres.io/v1alpha1 | ||
kind: SGShardedCluster | ||
metadata: | ||
name: stackgres | ||
spec: | ||
pods: | ||
persistentVolume: | ||
size: '5Gi' | ||
storageClass: default | ||
``` | ||
## Shards Configurations | ||
Custom Postgres configuration. | ||
| <div style="width:9rem">Property</div> | Required | Updatable | <div style="width:4rem">Type</div> | Default | Description | | ||
|:--------------------------------------------------------------------------|----------|-----------|:-----------------------------------|:------------------|:------------| | ||
| [sgPostgresConfig]({{% relref "06-crd-reference/03-sgpostgresconfig" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.shards.configurations.sgPostgresConfig >}} | | ||
| [sgPoolingConfig]({{% relref "06-crd-reference/04-sgpoolingconfig" %}}) | | ✓ | string | will be generated | {{< crd-field-description SGShardedCluster.spec.shards.configurations.sgPoolingConfig >}} | | ||
## Non Production Options | ||
The following options should NOT be enabled in a production environment. | ||
| <div style="width:19rem">Property</div> | Re­quired | Up­datable | <div style="width:5rem">Type</div> | <div style="width:4rem">Default</div> | Description | | ||
|:----------------------------------------|---------------|----------------|:-----------------------------------|:--------------------------------------|:------------| | ||
| disableClusterPodAntiAffinity | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.disableClusterPodAntiAffinity >}} | | ||
| disablePatroniResourceRequirements | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.disablePatroniResourceRequirements >}} | | ||
| disableClusterResourceRequirements | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.disableClusterResourceRequirements >}} | | ||
| enableSetPatroniCpuRequests | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.enableSetPatroniCpuRequests >}} | | ||
| enableSetClusterCpuRequests | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.enableSetClusterCpuRequests >}} | | ||
| enableSetPatroniMemoryRequests | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.enableSetPatroniMemoryRequests >}} | | ||
| enableSetClusterMemoryRequests | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.enableSetClusterMemoryRequests >}} | | ||
| enabledFeatureGates | | ✓ | boolean | false | {{< crd-field-description SGShardedCluster.spec.nonProductionOptions.enabledFeatureGates >}} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/sh | ||
|
||
. "$SPEC_PATH/abstract/patroni" | ||
|
||
e2e_test_extra_hash() { | ||
"$SHELL" "$PROJECT_PATH/stackgres-k8s/ci/build/build-functions.sh" path_hash \ | ||
"$(realpath --relative-to "$PROJECT_PATH" "$SPEC_PATH/abstract/patroni")" | ||
} | ||
|
||
e2e_test_install() { | ||
create_or_replace_sharded_cluster "$CLUSTER_NAME" "$CLUSTER_NAMESPACE" "3" "2" | ||
|
||
deploy_curl_pod "$CLUSTER_NAMESPACE" | ||
|
||
wait_pods_running "$CLUSTER_NAMESPACE" 7 | ||
wait_sharded_cluster "$CLUSTER_NAME" "$CLUSTER_NAMESPACE" | ||
} | ||
|
||
e2e_test() { | ||
run_test "Checking that is possible to connect using services is working" service_check | ||
|
||
run_test "Checking that sharded technology is working is working" sharded_check | ||
|
||
run_test "Check that pgbouncer database is accesible using the service" pgbouncer_database_check | ||
} | ||
|
||
service_check() { | ||
RESPONSE_PRIMARY="$(run_query -c "$CLUSTER_NAME-0" -h "$CLUSTER_NAME" -i 1 -p 5432)" | ||
|
||
if [ "$RESPONSE_PRIMARY" = "1" ] | ||
then | ||
echo "SUCCESS: Connections are possible using services" | ||
else | ||
echo "FAIL: Cannot connect to primary db using a kubernetes service" | ||
return 1 | ||
fi | ||
} | ||
|
||
sharded_check() { | ||
local RESULT EXIT_CODE | ||
try_function wait_until eval 'run_query -c "$CLUSTER_NAME-0" -h "$CLUSTER_NAME" -i 1 -p 5432 \ | ||
-d citus -q "SELECT COUNT(*) FROM master_get_active_worker_nodes()" | grep -xF 2' | ||
|
||
if [ "$EXIT_CODE" = 0 ] | ||
then | ||
echo "SUCCESS: Sharding is working" | ||
else | ||
echo "FAIL: Sharding is not working" | ||
return 1 | ||
fi | ||
} | ||
|
||
pgbouncer_database_check() { | ||
if kubectl exec -n "$CLUSTER_NAMESPACE" "${CLUSTER_NAME}-0-0" -c "postgres-util" -- env \ | ||
PGPASSWORD="$(kubectl -n "$CLUSTER_NAMESPACE" get secrets "$CLUSTER_NAME-0" \ | ||
-o jsonpath='{.data.pgbouncer-admin-password}' | base64 -d)" \ | ||
PGCONNECT_TIMEOUT="$((5 + E2E_TIMEOUT / 10))" \ | ||
psql -t -A -U pgbouncer_admin -d pgbouncer -h "$CLUSTER_NAME" -c "SHOW FDS" >/dev/null | ||
then | ||
echo "SUCCESS: psql could connect to the pgbouncer database with pgobuncer_admin using service" | ||
else | ||
echo "FAIL: psql could not connect to the pgbouncer database with pgobuncer_admin using service" | ||
return 1 | ||
fi | ||
|
||
if kubectl exec -n "$CLUSTER_NAMESPACE" "${CLUSTER_NAME}-0-0" -c "postgres-util" -- env \ | ||
PGPASSWORD="$(kubectl -n "$CLUSTER_NAMESPACE" get secrets "$CLUSTER_NAME-0" \ | ||
-o jsonpath='{.data.pgbouncer-stats-password}' | base64 -d)" \ | ||
PGCONNECT_TIMEOUT="$((5 + E2E_TIMEOUT / 10))" \ | ||
psql -t -A -U pgbouncer_stats -d pgbouncer -h "$CLUSTER_NAME" -c "SHOW VERSION" >/dev/null | ||
then | ||
echo "SUCCESS: psql could connect to the pgbouncer database with pgobuncer_stats using service" | ||
else | ||
echo "FAIL: psql could not connect to the pgbouncer database with pgobuncer_stats using service" | ||
return 1 | ||
fi | ||
} |
Oops, something went wrong.