This article explains how to install the Percona Distribution for PostgreSQL on Kubernetes using “context”. We will show you how to set up this distribution on Kubernetes clusters in AWS, Google Cloud, and locally with k3d. You’ll also learn how to switch between these setups to test them effectively.

In Kubernetes, a context is a profile set up in the “kubectl” configuration file that contains all the information necessary to connect to a Kubernetes cluster. Each context contains a Kubernetes cluster, a user, and a namespace. Contexts are very useful when managing multiple clusters in different environments or cloud providers.

Kubernetes context

Before starting, make sure we have these components:

  • Kubernetes (kubectl) installed and configured to communicate with my AWS, Google Cloud, and k3d clusters. 
  • Also, we need to have access to AWS and GCP to create Kubernetes clusters for testing purposes.

I already have a cluster running in GCP, AWS, and k3d. We will see how to switch between these clusters to install Percona Distribution for PostgreSQL.

List all contexts and current context

To list all the context configured in our “kubectl”, we use this command:

This command will output a table that includes the current context (marked by an asterisk *) and the details of each context. Here is what it looks like in my local environment:

Installing Percona Distribution for PostgreSQL

Percona Distribution for PostgreSQL can be installed using Helm, a package manager for Kubernetes. You’ll need to add the Percona Helm repository and then install Percona Distribution for PostgreSQL into each context.

My current context is GKE, so we will install Percona Distributon for PostgreSQL on our current cluster:

Ready! My Percona Distributon for PostgreSQL is running on a Kubernetes Cluster!

Switching contexts in kubectl

Now, I want to install Percona Distributon for PostgreSQL in Amazon EKS.

For this, we need to switch the context from GKE to EKS. I will list again all the contexts to know the name of the context in AWS.

Now, let’s switch contexts using the name of the context for EKS.

Verify that the context has been correctly switched to avoid any mix-ups with your current cluster:

Looks good!

Now, we will proceed to install Percona Distribution for PostgreSQL using the same steps we used in the section ‘Installing Percona Distribution for PostgreSQL’ with the only difference of changing the namespace to “aws-pg”

After completing those steps, let’s check if the PostgreSQL distribution is installed correctly.

 We have Percona Distribution for PostgreSQL ready on EKS!

Now, it is time to install it in k3d. For this, we need to switch the context from EKS to k3d

I repeated the same installation steps for Percona Distribution for PostgreSQL.

We have three different clusters with the same distribution for Percona Distribion for PostgreSQL.

Okay, but why do I need the same distribution on different platforms?

Testing the Percona Distribution for PostgreSQL across various Kubernetes clusters in AWS, GCP, and k3d allows you to evaluate a variety of aspects under different conditions. For example, we can run performance tests, scalability tests, data recovery, backup and restore, and operational testing, as well as cross-platform compatibility tests, which are crucial for deployment in diverse environments.

Visit our website for more information about our Kubernetes Percona Operators. You can also join Percona Squad to get exclusive news about Kubernetes in Databases!

For detailed insights, check out our blog post on Backing Up and Restoring to AWS S3 with Percona Kubernetes Operators.

Percona Distribution for PostgreSQL provides the best and most critical enterprise components from the open-source community in a single distribution, designed and tested to work together. Run PostgreSQL in your production and mission-critical environments and easily deploy and orchestrate reliable PostgreSQL in Kubernetes.

 

Download Percona Distribution for PostgreSQL Today!

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments