Allow us to introduce the PostgreSQL Operator, a tool designed to transform your database management experience.
Pramodh Ayyappan
July 27, 2023
table of contents
SHARE
In our Kubernetes-centric world, certain tasks still fall outside the scope of Kubernetes, leading to a disjointed experience. Traditional methods often lack the automation and consistency that we have come to expect. One such task that highlights this challenge is managing database credentials. As we delved deeper into this challenge, we realized that database credentials need to be a part of the K8s fold. Allow us to introduce the PostgreSQL Operator, a tool designed to transform your database management experience.
How does it work?
The PostgreSQL Operator introduces two Custom Resource Definitions (CRDs) - Role and Grant. The Role CRD is used to define a database user while the Grant CRD is used to specify the privileges and permissions granted to the user on database. The operator then automates the creation and management of these roles and grants in the PostgreSQL database. By leveraging the power of Kubernetes reconciliation loops, the operator ensures that the actual state of the system always matches the desired state, providing a reliable and consistent database user management experience.
Advantages
The PostgreSQL Operator brings two significant advantages to the table - it empowers developers and abstracts complex PostgreSQL tasks.
Developer empowerment
Traditionally, managing database credentials and permissions has often required a central team acting as gatekeepers, resulting in slow and inefficient processes that create bottlenecks in the workflow. The PostgreSQL Operator revolutionizes this process by granting developers the autonomy to define roles and permissions using the Role and Grant CRDs. This reversal of control means that instead of a central team managing the database, developers can write a manifest, get it approved, and seamlessly move it along a CI pipeline to create users. This democratization of the process significantly speeds up workflows and enhances overall efficiency.
Simplifies PostgreSQL tasks
On the other hand, the PostgreSQL Operator also simplifies complex PostgreSQL tasks. Take managing users and teams for instance, each may require varying levels of access to various tables within PostgreSQL schema. It is a complex task involving intricate SQL queries to setup and maintain fine-grained access control.
With the PostgreSQL Operator, you can easily define such permissions in a Grant CRD, which the operator then translates into the appropriate SQL commands. This abstraction of complex tasks ensures that permissions are always up-to-date, thanks to the power of Kubernetes reconciliation loops.
In essence, the PostgreSQL Operator not only empowers developers by democratizing the process of managing database credentials but also simplifies complex PostgreSQL tasks, making the management of PostgreSQL databases more efficient and inclusive.
Installation
1. Pre-requisite: A Kubernetes secret that contains base64 encrypted PostgreSQL Database details, such as username, password, endpoint, port, database and role_password .
3. Create CRDs for Roles and Grants:Once the Helm chart is successfully installed, you need to create a Custom Resource to define the desired roles and grants for PostgreSQL. The PostgreSQL Operator repository provides examples for creating custom resources. Here are a couple of examples:
You can explore more examples under the examples directory in the PostgreSQL Operator repository.
4. Check Role and Grant Status
After creating custom resources, you can verify the status of the roles and grants using kubectl commands. Run the following commands:
a. To check the status of roles:
kubectl get roles.postgresql.facets.cloud -o wide
This command provides an overview of the defined roles and their current status within the PostgreSQL cluster.
b. To check the status of grants:
kubectl get grants.postgresql.facets.cloud -o wide
This command provides an overview of the defined grants and their current status within the PostgreSQL cluster.
By checking the role and grant status, you can ensure that the desired state specified in the CRDs is being applied correctly within the PostgreSQL cluster.
Demo
A quick demo on deployment of PostgreSQL Operator, creation of Role and Grant
Before you go
Give the PostgreSQL Operator a try today and experience the revolution in database management. We welcome contributions, so join us in enhancing this tool and shaping the future of PostgreSQL management.
"With Facets, our staging environments look identical to production environments. So in case of production issues, we can be sure there are no infra drifts."
Kadam Jeet Jain, Co-Founder & CTO, Treebo Hotels and Hotel Superhero.
GGX switched from AWS to GCP in 2 weeks
"Facets has radically changed our DevOps for the better. They did all the heavy lifting and saved us precious time and resources in our when we switched from AWS to GCP."
Kaustubh Bhoyar, Head of engineering, GGX
Trusted by companies to run production at scale
Request a Quote
Let us know if you have any additional queries, we'll get back to you soon.
Capillary reduced ops tickets by 95%
“Our releases are fast. And with less developer time needed our teams can focus on building exciting features. We’ve saved countless hours and costs.”
"With Facets, our staging environments look identical to production environments. So in case of production issues, we can be sure there are no infra drifts."
Kadam Jeet Jain, Co-Founder & CTO, Treebo Hotels and Hotel Superhero.
GGX switched from AWS to GCP in 2 weeks
"Facets has radically changed our DevOps for the better. They did all the heavy lifting and saved us precious time and resources in our when we switched from AWS to GCP."
Kaustubh Bhoyar, Head of engineering, GGX
Trusted by companies to run production at scale
Get in touch with us
Tell us your queries and we’ll get back to you
Prefer email? Reach out to us at info@facets.cloud