![]() This config is stored in a telegraf-config configMap in the same namespace as my database. Sqlquery="SELECT CASE WHEN pg_last_wal_receive_lsn() = pg_last_wal_replay_lsn() THEN 0 ELSE EXTRACT (EPOCH FROM now() - pg_last_xact_replay_timestamp()) END AS replication_lag"įiles = Ĭsv_column_names = Sqlquery="SELECT t.tablename, pg_total_relation_size('\"' || t.schemaname || '\".\"' || t.tablename || '\"') AS table_total_disc_size FROM pg_tables t WHERE t.schemaname = 'public' ORDER BY pg_total_relation_size('\"' || t.schemaname || '\".\"' || t.tablename || '\"') DESC LIMIT 10" Sqlquery="SELECT pg_database_size('$DATABASE_NAME') as db_size" ![]() Sqlquery="select setting as shared_buffers from pg_settings where name='shared_buffers'" Sqlquery="select setting as max_connections from pg_settings where name='max_connections'" Sqlquery="SELECT usename, count(*) as nb_connections FROM pg_stat_activity GROUP BY usename" Sqlquery="SELECT * FROM pg_stat_bgwriter" Sqlquery="SELECT * FROM pg_stat_database where datname" Ignore_fs = Īddress = "host=127.0.0.1 user=telegraf dbname=$DATABASE_NAME sslmode=require password=$TELEGRAF_PASSWORD" I’ve also configured an additional volume to mount the telegraf config in the telegraf sidecar container. I’ve also added a sidecar container with telegraf image which is used to expose postgresql metrics on /metrics with the prometheus format. This way you can have a high available postgresql instance with Point In Time recovery □ Monitoring You can tell Spilo (the postgresql + Patroni docker bundle) to continuously stream you wall file to a remote S3 compatible storage and periodically take a physical base backup of your database. One other cool stuff of the zalando postgres operator is the backup and restore feature. Zalando operator can also prepare database for you with existing schema and pre-installed extensions. (You can also create secrets in different namespaces). So you can directly tell your application to use this secret to connect to postgresql without exporting it to external secret manager. Each user will have a kubernetes secret with the name. The operator will also manager postgres user and database for me. The operator will manage the replication between the 2 instances and the failover if the primary pod restart. With this manifest, I tell the postgres operator to create a 2 instance cluster (1 primary and 1 standby). Here is a simple example to have a postgresql primary + replica instance with a telegraf sidecar for the monitoring : apiVersion: "/v1" The zalando team provide a full example of Postgresql manifests. Now we have a Postgresql operator deployed in our Kubernetes cluster, we can manage Postgresql instances. Then apply it to your cluster wth kubectl kubectl apply -k postgres-operator Configuration Create a file postgres-operator/kustomize.yml with the content : apiVersion: /v1beta1 You can use kustomize to deploy this operator. ![]() It is powered by Patroni (also from zalando), a tool to high available Postgresql instances with auto failover and replication between instances. Then those CRDs will be managed by an operator which run inside your cluster.įor example, you can manage postgresql database resources with the zalando-postgresql-operator ! You can manage containers with « pod » resource, lifecycle with « deployment » resource, network with « service » and « ingress » resources, etc.Īnd if you want, you can extends the list of resources that kubernetes can handle with custom resources definitions. Kubernetes is a very powerful tool to manage containerized applications.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |