Skip to content

Commit 116e114

Browse files
committed
add cloudnative PG addon
1 parent 79a720d commit 116e114

File tree

3 files changed

+195
-3
lines changed

3 files changed

+195
-3
lines changed

server/src/addons/addons.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { KuberoAddonMysql } from './plugins/kuberoaddonsMysql';
2424
import { KuberoAddonRedis } from './plugins/kuberoaddonsRedis';
2525
import { KuberoAddonRabbitmq } from './plugins/kuberoaddonsRabbitmq';
2626
import { KuberoAddonMongodb } from './plugins/kuberoaddonsMongodb';
27+
import { Cluster as CloudnativePG } from './plugins/cloudnativePG';
2728

2829
@Injectable()
2930
export class AddonsService {
@@ -63,6 +64,9 @@ export class AddonsService {
6364
const tunnel = new Tunnel(this.CRDList);
6465
this.addonsList.push(tunnel);
6566

67+
const cloudnativePG = new CloudnativePG(this.CRDList);
68+
this.addonsList.push(cloudnativePG);
69+
6670
const postgresCluster = new PostgresCluster(this.CRDList);
6771
this.addonsList.push(postgresCluster);
6872

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
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+
}

server/src/addons/plugins/postgresCluster.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ kubectl apply --server-side -k github.com/CrunchyData/postgres-operator-examples
2020
];
2121
public artifact_url =
2222
'https://artifacthub.io/api/v1/packages/olm/community-operators/postgresql';
23-
public beta: boolean = true;
23+
public beta: boolean = false;
2424

2525
public formfields: { [key: string]: IPluginFormFields } = {
2626
'PostgresCluster.metadata.name': {
2727
type: 'text',
28-
label: 'Redis Cluster Name',
28+
label: 'Postgres Cluster Name',
2929
name: 'metadata.name',
3030
required: true,
3131
default: 'pg-cluster',
32-
description: 'The name of the Redis cluster',
32+
description: 'The name of the Postgres cluster',
3333
},
3434
'PostgresCluster.spec.postgresVersion': {
3535
type: 'number',

0 commit comments

Comments
 (0)