Install Postgres using Helm#

In this lab you’ll install postgres using the Bitnami Helm Chart. Helm charts make it easy to install whole applications that are ready to go. Bitnami packages applications with a lot of useful functionality. The postgres Helm chart has built in replication and autoscaling, making it perfect for large or small applications.

Introduction#

This process has three important steps:

  1. Find the configuration values you need in the README file on GitHub and put them into the deployment/values-postgres.yaml file.

  2. Install the postgres Helm chart.

  3. Install the phpMyAdmin Helm chart to m

postgres Configuration#

Helm charts are configured by YAML files. The exact values depend on the Helm chart. This configuration is sufficient to get postgres working in your cluster:

# Configuration for postgres
auth:
  rootPassword: test
  database: django 
  username: test
  password: test

# GKE Autopilot requires requests and limits.
primary:
  resources:
    requests:
      memory: "512Mi"
      cpu: "500m"
      ephemeral-storage: "100Mi"
    limits:
      memory: "512Mi"
      cpu: "500m"
      ephemeral-storage: "100Mi"

Install postgres#

Start by checking out how Helm works:

$ helm repo add bitnami https://charts.bitnami.com/bitnami
$ helm install helm-postgres bitnami/postgres --values deployment/values-postgres.yaml --debug --dry-run

The last command generated the YAML files that will be applied to Kubernetes. You can see how much YAML you get for a small amount of configuration. Now install postgres:

$ helm install helm-postgres bitnami/postgresql --values deployment/values-postgres.yaml 

Watch the resources come up:

$ kubectl get all 

Notice that a PVC is created:

$ kubectl get pvc 

Install phpMyAdmin#

How can you check on and administer postgres? The phpMyAdmin chart makes it possible to connect to and look at tables in your postgres database. This is an admin tool that should never be exposed to the Internet so we have to make sure that we don’t ask for a load balancer. Check the GitHub page for the default service type. What is it?

$ helm install myadmin bitnami/phpmyadmin

Once the phpMyAdmin pod is running use port forwarding to make it possible to connect to your local machine:

$ kubectl port-forward service/myadmin-phpmyadmin 8000:80

Preview the application on port 8000

You should see a login prompt. Login with the values:

  • Server: The service name of MaraDB

  • User: root

  • Password: test

Remove Resources#

These resources cost money! You may want to keep postgres for your project but you shouldn’t leave phpMyAdmin running when you’re not using it. If you want to reconfigure postgres with a different password you should remove and re-install it. For now let’s remove both:

$ helm uninstall helm-postgres
$ helm uninstall myadmin

Warning

Helm does not remove the data! That’s precious. If you try to re-install postgres with a different password the old data will cause a failure.

Remove the DB by deleting the PVC:

$ kubectl delete pvc/data-helm-postgres-0