|
| 1 | +--- |
| 2 | +title: "Single Cluster" |
| 3 | +date: 2023-12-28T14:26:51+01:00 |
| 4 | +draft: true |
| 5 | +--- |
| 6 | + |
| 7 | +Setting up a basic Cluster is pretty easy, we just need the minimum Definiton of a cluster-manifest which can also be find in the operator-tutorials repo on github. |
| 8 | +We need the following Definitions for the basic cluster. |
| 9 | +## minimal Single Cluster |
| 10 | +``` |
| 11 | +apiVersion: cpo.opensource.cybertec.at/v1 |
| 12 | +kind: postgresql |
| 13 | +metadata: |
| 14 | + name: cluster-1 |
| 15 | +spec: |
| 16 | + dockerImage: "docker.io/cybertecpostgresql/cybertec-pg-container:postgres-16.1-6-dev" |
| 17 | + numberOfInstances: 1 |
| 18 | + postgresql: |
| 19 | + version: "16" |
| 20 | + resources: |
| 21 | + limits: |
| 22 | + cpu: 500m |
| 23 | + memory: 500Mi |
| 24 | + requests: |
| 25 | + cpu: 500m |
| 26 | + memory: 500Mi |
| 27 | + volume: |
| 28 | + size: 5Gi |
| 29 | +``` |
| 30 | +Based on this Manifest the Operator will deploy a single-Node-Cluster based on the defined dockerImage and start the included Postgres-16-Server. |
| 31 | +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. |
| 32 | + |
| 33 | +After some seconds we should see, that the operator creates our cluster based on the declared definitions. |
| 34 | +``` |
| 35 | +kubectl get pods |
| 36 | +----------------------------------------------------------------------------- |
| 37 | +NAME | READY | STATUS | RESTARTS | AGE |
| 38 | +cluster-1-0 | 1/1 | Running | 0 | 50s |
| 39 | +
|
| 40 | +``` |
| 41 | + |
| 42 | +We can now starting to modify our cluster with some more Definitons. |
| 43 | +### Use a specific Storageclass |
| 44 | +``` |
| 45 | +spec: |
| 46 | + ... |
| 47 | + volume: |
| 48 | + size: 5Gi |
| 49 | + storageClass: default-provisioner |
| 50 | + ... |
| 51 | +``` |
| 52 | +Using the storageClass-Definiton allows us to define a specific storageClass for this Cluster. Please ensure, that the storageClass exists and is usable. If a Volume cannot provide the Volume will stand in the pending-State as like the Database-Pod. |
| 53 | + |
| 54 | +### Expanding Volume |
| 55 | +The Operator allows to you expand your volume if the storage-System is able to do this. |
| 56 | +``` |
| 57 | +spec: |
| 58 | + ... |
| 59 | + volume: |
| 60 | + size: 10Gi |
| 61 | + storageClass: default-provisioner |
| 62 | + ... |
| 63 | +``` |
| 64 | +This will trigger the expand of your Cluster-Volumes. It will need some time and you can check the current state inside the pvc. |
| 65 | +``` |
| 66 | +kubectl get pvc pgdata-cluster-1-0 -o yaml |
| 67 | +------------------------------------------------------- |
| 68 | +spec: |
| 69 | + accessModes: |
| 70 | + - ReadWriteOnce |
| 71 | + resources: |
| 72 | + requests: |
| 73 | + storage: 10Gi |
| 74 | + storageClassName: crc-csi-hostpath-provisioner |
| 75 | + volumeMode: Filesystem |
| 76 | + volumeName: pvc-800d7ecc-2d5f-4ef4-af83-1cd94c766d37 |
| 77 | +status: |
| 78 | + accessModes: |
| 79 | + - ReadWriteOnce |
| 80 | + capacity: |
| 81 | + storage: 5Gi |
| 82 | + phase: Bound |
| 83 | +
|
| 84 | +``` |
| 85 | + |
| 86 | +### Creating additonal Volumes |
| 87 | +The Operator allows you to modify your cluster with additonal Volumes. |
| 88 | +``` |
| 89 | +spec: |
| 90 | + ... |
| 91 | + additionalVolumes: |
| 92 | + - name: empty |
| 93 | + mountPath: /opt/empty |
| 94 | + targetContainers: |
| 95 | + - all |
| 96 | + volumeSource: |
| 97 | + emptyDir: {} |
| 98 | +``` |
| 99 | +This example will create an emptyDir and mount it to all Containers inside the Database-Pod. |
| 100 | + |
| 101 | + |
| 102 | +### Specific Settings for aws gp3 Storage |
| 103 | +For the gp3 Storage aws you can define more informations |
| 104 | +``` |
| 105 | + volume: |
| 106 | + size: 1Gi |
| 107 | + storageClass: gp3 |
| 108 | + iops: 1000 # for EBS gp3 |
| 109 | + throughput: 250 # in MB/s for EBS gp3 |
| 110 | +
|
| 111 | +``` |
| 112 | +The defined IOPS and Throughput will include in the PersistentVolumeClaim and send to the storage-Provisioner. |
| 113 | +Please keep in Mind, that on aws there is a CoolDown-Time as a limitation defined. For new Changes you need to wait 6 hours. |
| 114 | +Please also ensure to check the default and allowed values for IOPS and Throughput [AWS docs](https://aws.amazon.com/ebs/general-purpose/). |
| 115 | + |
| 116 | +To ensure that the settings are updates properly please define the Operator-Configuration 'storage_resize_mode' from default to 'mixed' |
0 commit comments