Skip to content

fillmore-labs/k8s-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple PostgreSQL on Kubernetes

Purpose

A simple PostgreSQL instance in a Kubernetes cluster, for development.

Configuration

Start by copying k8s/fillmore-labs to k8s/myconfig

PostgreSQL Root Password

Edit (in your configuration) secrets.env and set POSTGRES_PASSWORD.

Initial User and Database

Edit (in your configuration) 01-initdb.sql and replace user with the username, SCRAM-SHA-256 with the password and database with the initial database you want to use.

For a pre-encrypted password use this project.

Storage

K3s comes with Rancher’s Local Path Provisioner and this example uses that.

Adapt to your cloud provider.

Namespace

The example deploys to an existing namespace pg in kustomization.yaml.

Choose one existing or create it with

kubectl apply -f namespace.yaml

Starting the Server

When you configured everything to your liking, start the server with

kubectl apply -k k8s/fillmore-labs

Or k8s/myconfig, if that’s what you are using.

Test the configuration with

kubectl run -i -t psql --image=docker.io/library/postgres:15-alpine \
  --rm --restart=Never -- \
  psql -d postgresql://user:password@postgres.pg.svc.cluster.local:5432/database -l

Substituting user, password, pg and database with your values.

Deletion

With

kubectl delete -k k8s/fillmore-labs

The server is deleted. The data is still kept, so you can upgrade the server.

To delete the data, look for the claim

kubectl get pvc -n pg

And delete it permanently with

kubectl delete pvc -n pg postgres-pvc-postgresql-0

Also, remove the namespace with

kubectl delete -f namespace.yaml

Releases

No releases published

Packages

No packages published