Lately, it feels like every time I go to a technical conference, someone is talking about how great PostgreSQL is. I’d think it’s just me noticing, but the rankings and surveys say otherwise. PostgreSQL is simply very popular. From old-school bare metal setups to VMs, containers, and fully managed cloud databases, PostgreSQL keeps gaining ground. And […]
30
2025
The PG_TDE Extension Is Now Ready for Production
20
2023
Using Encryption-at-Rest for PostgreSQL in Kubernetes

Data-at-rest encryption is essential for compliance with regulations that require the protection of sensitive data. Encryption can help organizations comply with regulations and avoid legal consequences and fines. It is also critical for securing sensitive data and avoiding data breaches.
PostgreSQL does not natively support Transparent Data Encryption (TDE). TDE is a database encryption technique that encrypts data at the column or table level, as opposed to full-disk encryption (FDE), which encrypts the entire database.
As for FDE, there are multiple options available for PostgreSQL. In this blog post, you will learn:
- how to leverage FDE on Kubernetes with Percona Operator for PostgreSQL
- how to start using encrypted storage for already running cluster
Prepare
In most public clouds, block storage is not encrypted by default. To enable the encryption of the storage in Kubernetes, you need to modify the StorageClass resource. This will instruct Container Storage Interface (CSI) to provision encrypted storage volume on your block storage (AWS EBS, GCP Persistent Disk, Ceph, etc.).
The configuration of the storage class depends on your storage plugin. For example, in Google Kubernetes Engine (GKE), you need to create the key in Cloud Key Management Service (KMS) and set it in the StorageClass:
apiVersion: storage.k8s.io/v1beta1 kind: StorageClass metadata: name: my-enc-sc provisioner: pd.csi.storage.gke.io parameters: type: pd-standard disk-encryption-kms-key: KMS_KEY_ID
Get
KMS_KEY_ID
by following the instructions in this document.
For AWS EBS, you just need to add an encrypted field; the key in AWS KMS will be generated automatically.
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: my-enc-sc provisioner: kubernetes.io/aws-ebs parameters: encrypted: 'true' fsType: ext4 type: gp2 volumeBindingMode: WaitForFirstConsumer
Read more about storage encryption in the documentation of your cloud provider or storage project of your choice.
Try it out
Once you have the StorageClass created, it is time to use it. I will use Percona Operator for PostgreSQL v2 (currently in tech preview) in my tests, but such an approach can be used with any Percona Operator.
Deploy the operator by following our installation instructions. I will use the regular kubectl way:
kubectl apply -f deploy/bundle.yaml --server-side
Create a new cluster with encrypted storage
To create the cluster with encrypted storage, you must set the correct storage class in the Custom Resource.
spec: ... instances: - name: instance1 ... dataVolumeClaimSpec: storageClassName: my-enc-sc accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
Apply the custom resource:
kubectl apply -f deploy/cr.yaml
The cluster should be up and running, backed by encrypted storage.
Encrypt storage for existing cluster
This task boils down to switching from one StorageClass to another. With version two of the Operator, we have a notion of instance groups. They are absolutely fantastic for testing new configurations, including compute and storage.
- Start with a regular cluster with two nodes – Primary and Replica. Storage is not encrypted. (0-fde-pg.yaml)
- Add another instance group with two nodes, but this time with encrypted storage (1-fde-pg.yaml). To do that, we change the spec.instances section:
-
- name: instance2 replicas: 2 dataVolumeClaimSpec: storageClassName: my-enc-sc accessModes: - ReadWriteOnce resources: requests: storage: 1Gi
Wait for replication to complete and see the traffic hitting new nodes.
- Terminate nodes with unencrypted storage by removing the old instance group from the Custom Resource (2-fde-pg.yaml).
Now your cluster runs using encrypted storage.
Conclusion
It is quite interesting that PostgreSQL does not have built-in data-at-rest encryption. Peter Zaitsev wrote a blog post about it in the past – Why PostgreSQL Needs Transparent Database Encryption (TDE) – and why it is needed.
Storage-level encryption allows you to keep your data safe, but it has its limitations. The top limitations are:
- You can’t encrypt database objects granularly, only the whole storage.
- Also (1) does not allow you to encrypt different data with different keys, which might be the blocker for compliance and regulations.
- Physical backups, when files are copied from the disk, are not encrypted.
Even with these limitations, encrypting the data is highly recommended. Try out our operator and let us know what you think.
- Please use this forum for general discussions.
- Submit JIRA issue for bugs, and improvements of feature requests.
- For commercial support, please use our contact page.
The Percona Kubernetes Operators automate the creation, alteration, or deletion of members in your Percona Distribution for MySQL, MongoDB, or PostgreSQL environment.
23
2022
Keep Your Data Safe with Percona

September was and is an extremely fruitful month (especially for the black-hat hackers) for news about data leaks and breaches:
- Uber suffers computer system breach, alerts authorities
- GTA 6 source code and videos leaked after Rockstar Games hack
- Revolut breach: personal and banking data exposed
In this blog post, we want to remind you how to keep your data safe when running your favorite open source databases.
Network exposure
Search engines like Shodan are an easy way to search for publicly available databases. Over 3.6 million MySQL servers found exposed on the Internet.
The best practice here is to run database servers in the isolated private network, even from the rest of your corporate network. In this case, you have a low risk of exposure even in the case of server misconfiguration.
If for some reason you run your database on the server in a public network, you still can avoid network exposure:
- Bind your server to the localhost or private IP address of the server
For example, for MySQL use bind-address option in your my.cnf:
bind-address = 192.168.0.123
- Configure your firewall to block access through a public network interface on the operating system
Users and passwords
To complement the network exposure story, ensure that your users cannot connect from just any IP address. Taking MySQL as an example, the following GRANT command allows to connect from one of the private networks only:
GRANT ALL ON db1.* TO 'perconaAdmin'@'192.168.0.0/255.255.0.0';
MySQL also has an auth_socket plugin, that controls the connection to the database through Unix sockets. Read more in this blog post: Use MySQL Without a Password (and Still be Secure).
Minimize the risk and do not use default usernames and passwords. SecList is a good example of bad choices for passwords: MySQL, PostgreSQL, and a misc list. Percona Platform provides users with Advisors (read more below) that preemptively check for misconfigured grants, weak passwords, and more.
So now we agree that a strong password is a must. Did you know that you can enforce it? This Percona post talks about Improving MySQL Password Security with Validation Plugin that performs such enforcement.
A strong password is set, great! To make your system even more resilient to security risks, it is recommended to have a password rotation policy. This policy can be manually executed, but also can be automated through various integrations, like LDAP, KMIP, HashiCorp Vault, and many more. For example, this document describes how Percona Server for MongoDB can work with LDAP.
Encryption
There are two types of encryption when you talk about databases and ideally, you’re going to use both of them:
- Transport encryption – secure the traffic between client and server and between cluster nodes
- Data-at-rest encryption (or Transparent Data Encryption – TDE) – encrypt the data on a disk to prevent unauthorized access
Transport
With an unencrypted connection between the client and the server, someone with access to the network could watch all your traffic and steal the credentials and sensitive data. We recommend enabling network encryption by default. Read the following blog posts highlighting the details:
- Enabling and Enforcing SSL/TLS for PostgreSQL Connections
- Percona Server for MySQL Encryption Options and Choices
- Network (Transport) Encryption for MongoDB
Data-at-rest
Someone can get access to the physical disk or a network block storage and read the data. To mitigate this risk, you can encrypt the data on the disk. It can be done on the file system, block storage level, and with the database storage engine itself.
Tools like fscrypt or in-built encryption in ZFS can help with file system encryption. Public clouds provide built-in encryption for their network storage solutions (ex AWS EBS, GCP). Private storage solutions, like Ceph, also come with the support of data-at-rest encryption on the block level.
Percona takes security seriously, which is why we recommend enabling data-at-rest encryption by default, especially for production workloads. Percona Server for MySQL and Percona Server for MongoDB provides you with a wide variety of options to perform TDE on the database level.
Preventive measures
Mistakes and misconfiguration can happen and it would be cool if there was a mechanism to alert you about issues before it is too late. Guess what – we have it!
Percona Monitoring and Management (PMM) comes with Advisors which are the checks that identify potential security threats, vulnerabilities, data loss or data corruption, and other issues. Advisors are the software representation of the years of Percona’s expertise in database security and performance.
By connecting PMM to Percona Platform, users can get more sophisticated Advisors for free, whereas our paid customers are getting even deeper database checks, which discover various misconfiguration or non-compliance gems.
Learn more about Percona Platform with PMM on our website and check if your databases are secured and fine-tuned right away.
If you still believe you need more help, please let us know through our Community Forums or contact the Percona team directly.