Running Crunchydata Postgres on OpenStack Flex
Crunchydata provides a Postgres Operator that simplifies the deployment and management of PostgreSQL clusters on Kubernetes. In this guide, we will walk through deploying the Postgres Operator from Crunchy Data on an OpenStack Flex instance. As operators, we will need to create a new instance, install the Postgres Operator software, and configure the service to run on the instance. The intent of this guide is to provide a simple functional example of how to deploy the Postgres Operator from Crunchy Data on an OpenStack Flex on Kubernetes.
Foundation
This guide assumes there is an operational Kubernetes cluster running on OpenStack Flex. To support this requirement, this guide will assume that the Kubernetes cluster is running following the Talos guide, which can be found here.
An assumption of this guide is that the Kubernetes cluster has a working storage provider which can be used to create PersistentVolumeClaims
. If the environment does not have a working storage provider, one will need to be deploy one before proceeding with this guide. In this guide, we will use Longhorn as our storage provider, which was deployed as part of the Talos on OpenStack Flex setup. Read more about Longhorn setup being used for this post here.
All operations will start from our Jump Host, which is a Debian instance running on OpenStack Flex adjacent to the Talos cluster. The Jump Host will be used to deploy Longhorn to our Kubernetes cluster using Helm.
Note
The jump host referenced within this guide will use the following variable, ${JUMP_PUBLIC_VIP}
, which is assumed to contain the public IP address of the node.
Prerequisites
Before we begin, we need to ensure that we have the following prerequisites in place:
- An OpenStack Flex project with a Kubernetes cluster
- A working knowledge of Kubernetes
- A working knowledge of Helm
- A working knowledge of OpenStack Flex
- At least 1GiB of storage available to
PersistentVolumeClaims
(Longhorn)
Note
This guide is using Crunchydata 5.7, and the instructions may vary for other versions. Check the Crunchydata documentation for the most up-to-date information on current releases.
Create a New Namespace
Set the namespace security policy.
kubectl label --overwrite namespace crunchy-operator-system \
pod-security.kubernetes.io/enforce=privileged \
pod-security.kubernetes.io/enforce-version=latest \
pod-security.kubernetes.io/warn=privileged \
pod-security.kubernetes.io/warn-version=latest \
pod-security.kubernetes.io/audit=privileged \
pod-security.kubernetes.io/audit-version=latest
Install the Crunchdata Postgres Operator
Before getting started, set a few environment variables that will be used throughout the guide.
export CRUNCHY_OPERATOR_NAMESPACE=crunchy-operator-system
export CRUNCHY_CLUSTER_NAMESPACE=crunchy-operator-system # This can be a different namespace
export CRUNCHY_CLUSTER_NAME=hippo
export CRUNCHY_DB_REPLICAS=3
export CRUNCHY_DB_SIZE=1Gi
Retrieve the operator helm chart and change into the directory.
Install the operator helm chart.
Create a Crunchydata Postgres Cluster
Create a helm overrides file for the database deployment. The file should contain the following information. Replace the ${CRUNCHY_DB_REPLICAS}
, ${CRUNCHY_CLUSTER_NAME}
, and ${CRUNCHY_DB_SIZE}
with the desired values for the deployment.
crunchy-db.yaml
Create a new secret for the user rhino
crunchy-rhino-secret.yaml
Run the Deployment
helm upgrade --install --namespace ${CRUNCHY_CLUSTER_NAMESPACE} hippo helm/postgres \
-f crunchy-db.yaml
Tip
Track the state of the deployment with the following
Verify the Crunchydata Postgres Cluster
kubectl --namespace ${CRUNCHY_CLUSTER_NAMESPACE} get svc --selector=postgres-operator.crunchydata.com/cluster=${CRUNCHY_CLUSTER_NAME}
Conclusion
In this guide, we have deployed the Crunchydata Postgres Operator on an OpenStack Flex Kubernetes cluster. We have also created a new Postgres cluster using the operator. This guide is intended to provide a simple functional example of how to deploy the Crunchydata Postgres Operator on an OpenStack Flex Kubernetes cluster. For more information on the Crunchydata Postgres Operator, please refer to the Crunchydata documentation.