CYBERTEC-PG-Operator
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

Single Cluster

To set up a cluster, the implementation is based on a description, as with the other Kubernetes deplyoments. To do this, the operator uses a document of type postgresql.

You can also find the basic minimum specifications for a single-node cluster in our tutorial project on Github

minimal Single-Node Cluster

apiVersion: cpo.opensource.cybertec.at/v1
kind: postgresql
metadata:
  name: cluster-1
spec:
  dockerImage: "docker.io/cybertecpostgresql/cybertec-pg-container:postgres-16.1-6-dev"
  numberOfInstances: 1
  postgresql:
    version: "16"
  resources:
    limits:
      cpu: 500m
      memory: 500Mi
    requests:
      cpu: 500m
      memory: 500Mi
  volume:
    size: 5Gi 

Based on this Manifest the Operator will deploy a single-Node-Cluster based on the defined dockerImage and start the included Postgres-16-Server. Also created is a volume based on your default-storage Class. The Ressource-Definiton means, that we reserve a half cpu and a half GB Memory for this Cluster with the same Definition as limit.

After some seconds we should see, that the operator creates our cluster based on the declared definitions.

kubectl get pods
-----------------------------------------------------------------------------
NAME                             | READY  | STATUS           | RESTARTS | AGE
cluster-1-0                      | 1/1    | Running          | 0        | 50s

HINT: Here you will find a complete overview of the available options within the cluster manifest.

minimal High-Availability Cluster

No more effort is required to create a High-Availablity cluster than for a Single-Node Cluster. Only the Cluster-Manifest needs to be modified slightly. The difference lies in the object numberOfInstances, which must be set > 1.

You can also find the basic minimum specifications for a High-Availability-Cluster cluster in our tutorial project on Github

apiVersion: cpo.opensource.cybertec.at/v1
kind: postgresql
metadata:
  name: cluster-1
spec:
  dockerImage: "docker.io/cybertecpostgresql/cybertec-pg-container:postgres-16.1-6-dev"
  numberOfInstances: 2
  postgresql:
    version: "16"
  resources:
    limits:
      cpu: 500m
      memory: 500Mi
    requests:
      cpu: 500m
      memory: 500Mi
  volume:
    size: 5Gi 

You can either create a new cluster with the document or update an existing cluster with it. This makes it possible to scale the cluster up and down during operation.

kubectl get pods
-----------------------------------------------------------------------------
NAME                             | READY  | STATUS           | RESTARTS | AGE
cluster-1-0                      | 1/1    | Running          | 0        | 2m12s
cluster-1-1                      | 1/1    | Running          | 0        | 50s