
Today's latte, PostgreSQL., Yuko Honda, CC BY 2.0, via flickr
Talos Kubernetes - Deploy cloudnative-pg Database
Prerequisite
Talos Kubernetes - Deploy Metrics, Logging, and Alerts
Goal
Deploy a database to be used by future applications.
Instructions
- Clone my repo if you haven’t and navigate to
/kubernetes/apps
in a file explorer or terminal. - Copy the database folder into your project’s
/apps
directory. - In Bitwarden Secrets Manager, create a new secret called
cloudnative-pg
and add the values in valid json format:
{
"POSTGRES_SUPER_USER": "<pick_a_username>"`,
"POSTGRES_SUPER_PASS": "<pick_a_password>"`
}
- In
/cluster/cluster16.yaml
, modify the instances, storage size, resources, limits, and other parameters based on your needs. - In
/cluster/service.yaml
setio.cilium/lb-ipam-ips
to an unused ip address within the same network as your Kubernetes nodes. - From my repo, copy
cloudnative-pg.yaml
fromkubernetes/flux/repositories/helm/
into the same path in your project. - In the same directory, add the following line to the
kustomization.yaml
file:- ./cloudnative-pg.yaml
- Create a new feature branch and commit your changes.
- In your browser, navigate to your repo on github, and select “Compare” to compare the new branch and create a pull request. Review your changes then create a pull request if everything looks good.
- Let the checks run, if they all pass then it’s safe to accept the pull request and merge it in to main. Then, delete the feature branch you created.
- Make sure to checkout the main branch locally if you are still on the local feature branch.
- Once on main, fetch the changes from origin/main (remote branch). Then pull the changes to update your local main branch.
- Run
task kubernetes:resources
and wait until the cloudnative-pg operator becomes ready. Then wait until the operator creates the amount of pods defined in the postgreSQL cluster (cluster16.yaml). - In your browser, navigate to grafana.YOUR_DOMAIN. Sign into grafana with the username and password created in [[deploy-metrics-logging-alerts]].
- On the left hand side, select ‘Dashboards’. Then find the dashboard named ‘CloudNativePG’ and select it to open the dashboard.
- In the text entry field labelled ‘Cluster’, input the cluster name. Mine is named ‘postgres16’. Press Enter. In the top right of grafana, select the dropdown arrow next to the refresh icon, then select ‘Off’ to disable auto refresh.
- If everything is working, a snapshot of cloudnative-pg’s metrics will be displayed.