1. Answers
  2. Deploy the pgbouncer Helm chart on Digital Ocean Kubernetes Service

How do I deploy the pgbouncer Helm chart on Digital Ocean Kubernetes Service?

In this guide, we will deploy the pgbouncer Helm chart on a Kubernetes cluster provisioned on DigitalOcean using Pulumi. pgbouncer is a lightweight connection pooler for PostgreSQL. We will create a DigitalOcean Kubernetes cluster, configure the necessary resources, and deploy the Helm chart.

Steps:

  1. Provision a DigitalOcean Kubernetes Cluster: We will create a Kubernetes cluster on DigitalOcean.
  2. Deploy the pgbouncer Helm Chart: Using the Pulumi Kubernetes provider, we will deploy the pgbouncer Helm chart to the cluster.
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
import * as k8s from "@pulumi/kubernetes";

// Create a DigitalOcean Kubernetes cluster
const cluster = new digitalocean.KubernetesCluster("do-cluster", {
    region: digitalocean.Region.NYC3,
    version: "1.21.5-do.0",
    nodePool: {
        name: "default",
        size: digitalocean.DropletSlug.DropletS2VCPU2GB,
        nodeCount: 2,
    },
});

// Export the cluster's kubeconfig
export const kubeconfig = cluster.kubeConfigs[0].rawConfig;

// Create a Kubernetes provider instance using the kubeconfig
const k8sProvider = new k8s.Provider("k8sProvider", {
    kubeconfig: kubeconfig,
});

// Deploy the pgbouncer Helm chart
const pgbouncer = new k8s.helm.v3.Chart("pgbouncer", {
    chart: "pgbouncer",
    version: "1.15.0",
    fetchOpts: {
        repo: "https://charts.bitnami.com/bitnami",
    },
    values: {
        auth: {
            username: "admin",
            password: "password",
        },
        postgresql: {
            host: "your-postgresql-host",
            port: 5432,
            database: "your-database",
            user: "your-username",
            password: "your-password",
        },
    },
}, { provider: k8sProvider });

export const pgbouncerName = pgbouncer.getResource("v1/Service", "pgbouncer").metadata.name;

Key Points

  • DigitalOcean Kubernetes Cluster: We provisioned a Kubernetes cluster on DigitalOcean using the digitalocean.KubernetesCluster resource.
  • Kubernetes Provider: We created a Kubernetes provider instance using the cluster’s kubeconfig to interact with the cluster.
  • Helm Chart Deployment: We deployed the pgbouncer Helm chart using the k8s.helm.v3.Chart resource, specifying the chart details and configuration values.

Summary

We successfully deployed the pgbouncer Helm chart on a DigitalOcean Kubernetes cluster using Pulumi. This involved provisioning the cluster, configuring the Kubernetes provider, and deploying the Helm chart with the necessary configuration values. This setup provides a scalable and efficient way to manage PostgreSQL connections in your applications.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up