|
| 1 | +import { Plugin, } from './plugin'; |
| 2 | +import { IPlugin, IPluginFormFields } from './plugin.interface'; |
| 3 | + |
| 4 | + |
| 5 | +// Classname must be same as the CRD's Name |
| 6 | +export class Cluster extends Plugin implements IPlugin { |
| 7 | + public id: string = 'Cluster'; //same as operator name |
| 8 | + public displayName = 'PostgreSQL (CloudNativePG)'; |
| 9 | + public description: string = |
| 10 | + 'CloudNativePG is the Kubernetes operator that covers the full lifecycle of a highly available PostgreSQL database cluster with a primary/standby architecture, using native streaming replication.'; |
| 11 | + public icon = '/img/addons/pgsql.svg'; |
| 12 | + public install: string = 'kubectl apply -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.27/releases/cnpg-1.27.0.yaml'; |
| 13 | + public url = |
| 14 | + 'https://artifacthub.io/packages/olm/community-operators/kubero-operator'; |
| 15 | + public docs = [ |
| 16 | + { |
| 17 | + title: 'Kubero Docs', |
| 18 | + url: '', |
| 19 | + }, |
| 20 | + ]; |
| 21 | + public artifact_url = |
| 22 | + 'https://artifacthub.io/api/v1/packages/olm/kubero/kubero-operator'; |
| 23 | + public beta: boolean = false; |
| 24 | + public deprecated: boolean = false; |
| 25 | + |
| 26 | + public formfields: { [key: string]: IPluginFormFields } = { |
| 27 | + 'CloudnativePG.metadata.name': { |
| 28 | + type: 'text', |
| 29 | + label: 'PostgreSQL Instance Name', |
| 30 | + name: 'metadata.name', |
| 31 | + required: true, |
| 32 | + default: 'postgresql', |
| 33 | + description: 'The name of the PostgreSQL instance', |
| 34 | + }, |
| 35 | + 'CloudnativePG.spec.image.tag': { |
| 36 | + type: 'combobox', |
| 37 | + label: 'Version/Tag', |
| 38 | + options: ['ghcr.io/cloudnative-pg/postgresql:17-minimal-bookworm', 'ghcr.io/cloudnative-pg/postgresql:16-minimal-bookworm', 'ghcr.io/cloudnative-pg/postgresql:15-minimal-bookworm'], // TODO - load this dynamically |
| 39 | + name: 'spec.image.tag', |
| 40 | + required: true, |
| 41 | + default: 'ghcr.io/cloudnative-pg/postgresql:17-minimal-bookworm', |
| 42 | + description: 'Version of the PostgreSQL version to use', |
| 43 | + }, |
| 44 | + 'superuserSecret.stringData.username': { |
| 45 | + type: 'text', |
| 46 | + label: 'PostgreSQL RootUser*', |
| 47 | + name: 'superuserSecret.stringData.username', |
| 48 | + default: 'postgres', |
| 49 | + required: true, |
| 50 | + description: 'Username for the root user', |
| 51 | + }, |
| 52 | + |
| 53 | + 'superuserSecret.stringData.password': { |
| 54 | + type: 'text', |
| 55 | + label: 'PostgreSQL Root Password*', |
| 56 | + name: 'superuserSecret.stringData.password', |
| 57 | + default: '', |
| 58 | + required: true, |
| 59 | + description: 'Password for the root user', |
| 60 | + }, |
| 61 | + 'appUserSecret.stringData.username': { |
| 62 | + type: 'text', |
| 63 | + label: 'Username*', |
| 64 | + name: 'appUserSecret.stringData.username', |
| 65 | + default: '', |
| 66 | + required: true, |
| 67 | + description: 'Username for an additional user to create', |
| 68 | + }, |
| 69 | + 'appUserSecret.stringData.password': { |
| 70 | + type: 'text', |
| 71 | + label: 'User Password*', |
| 72 | + name: 'appUserSecret.stringData.password', |
| 73 | + default: '', |
| 74 | + required: true, |
| 75 | + description: 'Password for an additional user to create', |
| 76 | + }, |
| 77 | + 'CloudnativePG.spec.instances': { |
| 78 | + type: 'number', |
| 79 | + label: 'Instances', |
| 80 | + name: 'spec.instances', |
| 81 | + default: 1, |
| 82 | + required: true, |
| 83 | + description: 'Number of PostgreSQL instances to create', |
| 84 | + }, |
| 85 | + 'CloudnativePG.spec.storage.className': { |
| 86 | + type: 'select-storageclass', |
| 87 | + label: 'Storage Class', |
| 88 | + // options: ['default', 'local-path', 'nfs-client', 'rook-ceph-block'], |
| 89 | + name: 'spec.storage.className', |
| 90 | + default: 'default', |
| 91 | + required: true, |
| 92 | + }, |
| 93 | + 'CloudnativePG.spec.storage.size': { |
| 94 | + type: 'text', |
| 95 | + label: 'Storage Size*', |
| 96 | + name: 'spec.storage.size', |
| 97 | + default: '1Gi', |
| 98 | + required: true, |
| 99 | + description: 'Size of the storage', |
| 100 | + }, |
| 101 | + }; |
| 102 | + |
| 103 | + public env: any[] = []; |
| 104 | + |
| 105 | + public resourceDefinitions: object = { |
| 106 | + CloudnativePG: { |
| 107 | + apiVersion: "postgresql.cnpg.io/v1", |
| 108 | + kind: "Cluster", |
| 109 | + metadata: { |
| 110 | + name: "cluster-example-full" |
| 111 | + }, |
| 112 | + spec: { |
| 113 | + description: "Kubero generated postgresql cluster", |
| 114 | + imageName: "ghcr.io/cloudnative-pg/postgresql:17.5", |
| 115 | + instances: 3, |
| 116 | + startDelay: 300, |
| 117 | + stopDelay: 300, |
| 118 | + primaryUpdateStrategy: "unsupervised", |
| 119 | + /* |
| 120 | + postgresql: { |
| 121 | + parameters: { |
| 122 | + shared_buffers: "256MB", |
| 123 | + pg_stat_statements: { |
| 124 | + max: "10000", |
| 125 | + track: "all" |
| 126 | + }, |
| 127 | + auto_explain: { |
| 128 | + log_min_duration: "10s" |
| 129 | + } |
| 130 | + }, |
| 131 | + pg_hba: [ |
| 132 | + "host all all 10.244.0.0/16 md5" |
| 133 | + ] |
| 134 | + }, |
| 135 | + */ |
| 136 | + bootstrap: { |
| 137 | + initdb: { |
| 138 | + database: "app", |
| 139 | + owner: "app", |
| 140 | + secret: { |
| 141 | + name: "cluster-app-user" |
| 142 | + } |
| 143 | + } |
| 144 | + }, |
| 145 | + enableSuperuserAccess: true, |
| 146 | + superuserSecret: { |
| 147 | + name: "cluster-superuser" |
| 148 | + }, |
| 149 | + storage: { |
| 150 | + storageClass: "standard", |
| 151 | + size: "1Gi" |
| 152 | + }, |
| 153 | + backup: null |
| 154 | + } |
| 155 | + }, |
| 156 | + superuserSecret: { |
| 157 | + apiVersion: 'v1', |
| 158 | + kind: 'Secret', |
| 159 | + metadata: { |
| 160 | + name: 'cluster-superuser', |
| 161 | + }, |
| 162 | + type: 'Opaque', |
| 163 | + stringData: { |
| 164 | + 'username': 'postgres', |
| 165 | + 'password': 'changeme', |
| 166 | + }, |
| 167 | + }, |
| 168 | + appUserSecret: { |
| 169 | + apiVersion: 'v1', |
| 170 | + kind: 'Secret', |
| 171 | + metadata: { |
| 172 | + name: 'cluster-app-user', |
| 173 | + }, |
| 174 | + type: 'Opaque', |
| 175 | + stringData: { |
| 176 | + 'username': 'app', |
| 177 | + 'password': 'app', |
| 178 | + }, |
| 179 | + }, |
| 180 | + } |
| 181 | + |
| 182 | + protected additionalResourceDefinitions: object = {}; |
| 183 | + |
| 184 | + constructor(availableOperators: any) { |
| 185 | + super(); |
| 186 | + super.init(availableOperators); |
| 187 | + } |
| 188 | +} |
0 commit comments