The module lifecycle stage: Preview
Available in: EE
Module Overview
The managed-postgres module manages PostgreSQL clusters in Kubernetes clusters.
It allows users to configure and scale PostgreSQL clusters according to their needs, ensuring optimal performance and security.
Main features:
- Automatic Deployment: Deploys a Postgres instance using a simple YAML configuration
- High Availability: Supports deployment of a highly available Postgres cluster or a standalone instance of your choice.
- Configuration Management: Separate
PostgresClassresource for templating the cluster creation approach with the ability to flexibly validate user configs - User and Database Management: Declarative model for creating users and logical databases.
- Status: Informative set of states for tracking the deployed Postgres.
Enabling the Module
To enable the managed-postgres module, apply the following manifest:
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: managed-postgres
spec:
enabled: true
version: 1
After enabling the module, a cluster-wide PostgresClass resource named default will be created automatically.
Quick Start
For module usage examples, see:
Use in production environment
If the module is planned to be used in a production environment, it is recommended to configure a separate ModuleUpdatePolicy.
The example policy below uses the AutoPatch mode, which allows automatic updates of patch releases of the module (0.1.0 => 0.1.1), but waits for confirmation when updating minor (0.1.2 => 0.2.0) or major (0.1.2 => 1.0.0) versions of the module.
{% alert level=“danger” %}
The AutoPatch mode is chosen because minor/major version updates of the module involve POSSIBLE RESTART of all Postgres clusters managed by the module. And for production environment it is recommended to control this process and services that depend on the availability of Postgres databases.
{% endalert %}
Example policy:
apiVersion: deckhouse.io/v1alpha2
kind: ModuleUpdatePolicy
metadata:
name: managed-postgres-policy
spec:
releaseChannel: Stable # or RockSolid
update:
mode: AutoPatch # this is important!
# windows:
# - days:
# - Mon
# - Wed
# # time in UTC
# from: '18:30'
# to: '19:00'
Then link this policy to the module by editing ModuleConfig managed-postgres:
d8 k edit mc managed-postgres
apiVersion: deckhouse.io/v1alpha1
kind: ModuleConfig
metadata:
name: managed-postgres
spec:
enabled: true
updatePolicy: managed-postgres-policy
For manual update approval, set the annotation modules.deckhouse.io/approved="true" in the corresponding ModuleRelease resource.
Main Resources
The Managed Service Postgres module provides tools for two conditional roles: User and Administrator.
The main module objects are Postgres, PostgresClass resources and the Postgres Operator state controller.
Conditional Administrator role:
- manages the cluster wide
PostgresClassresource and creates validation templates, scheduling rules, configuration for future services deployed in DKP. - Has access to the system namespace
d8-managed-postgres, wherePostgres Operatoris deployed, to its service logs, state.
Conditional User role:
- manages the
Postgresresource and configures the service keep in mind thePostgresClasscreated by the Administrator.
Administrator Resources
PostgresClass
The PostgresClass resource allows you to restrict the creation of invalid configurations and predefine some values.
Every Postgres resource must be linked to an existing PostgresClass resource.
Before deploying the service, all configuration will be checked against the corresponding PostgresClass.
Detailed resource description
Postgres Operator
When the module is enabled, the controller (postgres operator) is deployed in the system namespace d8-managed-postgres
and reconciles the states of Postgres resources in all user namespaces.
User Resources
Postgres
The main resource that describes the state of the service. It must be created within the user namespace and serves as the source of truth for the specific deployed postgres service. Detailed resource description