Start by copying k8s/fillmore-labs to k8s/myconfig
Edit (in your configuration) secrets.env
and set POSTGRES_PASSWORD
.
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.
K3s comes with Rancher’s Local Path Provisioner and this example uses that.
Adapt to your cloud provider.
The example deploys to an existing namespace pg
in kustomization.yaml.
Choose one existing or create it with
kubectl apply -f namespace.yaml
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:[email protected]:5432/database -l
Substituting user
, password
, pg
and database
with your values.
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