Kubernetes Operator in Go for Self-Service PostgreSQL Access

Build a Kubernetes operator in Go with Kubebuilder that gives product teams self-service PostgreSQL access: teams declare databases and users as custom resources, and the operator creates them as a non-superuser role, delivers generated credentials as Secrets, rotates them, repairs drift, refuses mistakes at admission and cleans up safely, on kind and on Amazon EKS with Amazon RDS.

Kubernetes Engineer. Advanced.

What you will build and explain

  • Explain the operator pattern and level-based reconciliation, and design custom resources with spec and status, OpenAPI and CEL validation, immutability and printer columns.
  • Write idempotent controller-runtime reconcilers that manage PostgreSQL, with finalizers, watches, field indexes, status conditions, events and metrics.
  • Build a least-privilege PostgreSQL access model with NOLOGIN owner roles, default privileges and PostgreSQL 16 CREATEROLE semantics, and generate, deliver and rotate credentials safely.
  • Add a validating admission webhook with cert-manager certificates, and restrict the operator's Kubernetes RBAC to exactly what its code uses.
  • Test an operator with unit tests, real PostgreSQL, envtest and kind, then deploy and observe it on EKS against RDS and remove every billable resource.

Before you begin

  • Reading and writing small Go programs (packages, structs, interfaces, errors, context) and running go test
  • Kubernetes Pods, Deployments, Services, Namespaces, Secrets, ServiceAccounts and basic RBAC, with kubectl get, describe, logs and apply; basic SQL and psql
  • A computer with Docker and Bash, about 8 GB of free disk; for the optional EKS milestone, the AWS CLI version 2, an AWS account where you may create EKS, VPC, RDS, ECR, S3 and IAM resources in one Region, and a spending limit

Curriculum

Learning topics (18)
  1. Understand the brief and prepare your tools

    In this project you build a Kubernetes operator in Go: a program that runs in the cluster and turns two small YAML objects into a working PostgreSQL database, login roles with exactly the right privileges, and a Secret your application can mount. You will run it on a local kind cluster against PostgreSQL 18, and, as an optional milestone, on Amazon EKS against Amazon RDS.

  2. Follow a database request from a YAML file to working credentials

    This page explains how the operator works as a whole: what each part does, what moves between the parts, and why the design looks the way it does. The technology lessons go deeper into each tool, and the source guides go file by file. This page should make sense without either.

  3. Keeping the world matched to a declaration

    A DBA at Brackwater once revoked a user's access to fix an incident and forgot to give it back. The service ran degraded for two days before anyone connected the errors to the revoke. The ticket that originally created the user said what access it should have; nothing ever compared that statement with the server again.

  4. Custom resources teams can use safely

    The first draft of this API had a single resource, DatabaseAccess, with the server address, the database name, a list of users and their passwords in one object. It was easy to write and impossible to make safe:

  5. Roles that survive their users

    The reporting team's first database user, created by hand two years ago, owned half the tables in its database. It had created them during a migration and nobody noticed. When the reporting service was retired and the user dropped, PostgreSQL refused: the role still owned objects. The DBA reassigned them to the next user, which later created more tables of its own, and the knot grew.

  6. Idempotent loops with controller-runtime

    The first version of the DatabaseUser reconciler created the role and then the Secret, and returned. It worked in every demo. In the first real test the operator restarted between the two steps. On the next pass the role already existed, CREATE ROLE failed, the reconciler returned an error, and it kept failing with backoff until someone deleted the role by hand.

  7. Passwords nobody types

    Brackwater's security review found a database password in a two-year-old chat thread. It still worked. Nobody knew which services used it, so nobody dared to change it.

  8. Cleaning up without losing data

    An engineer at Brackwater cleaned up an old test namespace with kubectl delete namespace billing-test. The namespace contained a Database for a scratch copy of the invoices data, and nothing else. The question the platform team asked afterwards was: what should have happened to the database on the server? The answer depends on what the object said. The operator has to get it right every time, including when it is restarting, when the server is down, and when two objects claim

  9. Refusing what can't work, before it is stored

    When the operator first went live, a billing engineer copied the routing team's Database manifest as a starting point and forgot to change databaseName. The object was accepted. A minute later it reported NameConflict in its status, which nobody looked at, and the billing service failed to start for an afternoon.

  10. What a stolen operator token could do

    An operator holds two kinds of credentials:

  11. Four layers, each catching different bugs

    An operator sits between Kubernetes and an external system. That makes it unusually easy to test the wrong thing:

  12. One image, two overlays, and seeing what it does

    The operator works on your computer under make run. Getting it into a cluster raises new questions:

  13. The same operator against a managed database

    On kind, everything is under your control: the cluster, the PostgreSQL server, its CA and its superuser. On AWS, the database is Amazon RDS:

  14. Upgrades, API changes and day-two tasks

    Writing the operator took weeks. Running it will take years: new Kubernetes versions, new fields teams ask for, a rotated admin password, a new server, a team that leaves. This lesson covers the tasks that come after the first deployment:

  15. Run the operator on kind, then on EKS with RDS

    This guide takes you from the downloaded source to the operator managing real PostgreSQL access in two places: first a local kind cluster with a PostgreSQL 18 server inside it, which costs nothing, and then, as an optional milestone, one small Amazon EKS cluster against Amazon RDS for PostgreSQL. The cleanup guide removes both again.

  16. Troubleshoot the operator from its own evidence

    Almost every problem with this operator first shows up as a Ready=False condition somewhere in a short chain: a user waits on its database, a database waits on its server, a server waits on its Secrets and the network. The first useful question is always: where in that chain is the first False, and what does its message say? The answer usually separates a Kubernetes problem (admission, RBAC, a Secret) from a PostgreSQL problem (TLS, a password, a privilege) before you open a

  17. Explain the operator's decisions in an interview

    An interview about this project rarely asks "what does the code do?". It asks why you chose this design over the obvious alternatives, and what happens when something fails. The question bank has twenty questions in five areas: architecture, API and reconciliation, PostgreSQL and credentials, security, and testing and operations. Each has a model answer and the talking points an interviewer listens for.

  18. Remove the lab and check for leftovers

    The project has two labs with separate cleanups. The kind lab lives only in Docker on your computer and costs nothing, but it holds several gigabytes of images. The EKS milestone costs about USD 0.26 per hour until it is gone. Remove it as soon as you have finished. Both cleanups work whether or not the deployment finished.

Practical build steps (7)
  1. Build the toolbox and run the checks

    Before any cluster exists, you build the container that holds every tool, and run the checks that guard every change to the operator. Nothing in this milestone costs money or needs an AWS account.

  2. Create the local cluster and database server

    You create a kind cluster with two nodes, install cert-manager, and run a PostgreSQL 18 server that accepts only TLS connections. This is the environment the operator will manage. It plays the role that Amazon RDS plays in the EKS milestone.

  3. Build and deploy the operator

    You build the operator image, load it into the cluster's nodes, and deploy it with its CRDs, RBAC, validating webhook and the webhook's certificate. At the end, one operator pod runs, holds the leader lease, and serves the webhook.

  4. Register the server and serve two teams

    You act as the platform team, registering the server and labelling which namespaces may use it, and then as two product teams asking for databases and users. Then a client pod connects with the credentials the operator delivered, and the end-to-end suite exercises everything.

  5. Create the AWS infrastructure

    You choose a prefix and a Region, sign in, and create everything the EKS milestone needs: a state bucket, a VPC, an EKS cluster with two Graviton nodes, an ECR repository and an RDS for PostgreSQL 18 instance in private subnets. This is the first step that costs money, about USD 0.26 per hour until cleanup finishes.

  6. Install and verify the operator on EKS

    You push the operator image to ECR, install cert-manager, create the operator's own role on RDS through a one-time Job, deploy two replicas with the EKS overlay, and register RDS as the PostgresServer. Then a short verification proves it works, and you can release and roll back.

  7. Remove everything and check for leftovers

    You destroy the EKS milestone in reverse order, check that nothing billable remains, delete the kind cluster, and remove the images and caches from your computer.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

AWS usage is separate from project access. The kind lab runs on your computer and costs nothing. The optional EKS milestone costs about USD 0.26 per hour in ap-south-1 at on-demand prices (an EKS control plane, two m7g.large nodes, an RDS db.t4g.micro instance, public IPv4 addresses and storage); a two-hour session costs about USD 0.55. Charges continue until cleanup finishes. This is a learning reference, not a hosted lab or a production-readiness guarantee.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components downloaded when building or running the lab, such as the Go modules in go.mod, Go, Kubebuilder, controller-gen, kind, kubectl, cert-manager, PostgreSQL, Terraform and its AWS provider, the AWS CLI, golangci-lint and govulncheck, retain their own licences; several files began as output of Kubebuilder's Apache-2.0 project templates. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy