-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcnpg.yaml
651 lines (593 loc) · 25.3 KB
/
cnpg.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
blocks:
- name: deploy_pgadmin_application_blk
content:
targetRevision: 1.23.3
destinationNamespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
repoURL: "https://helm.runix.net"
chart: pgadmin4
values:
existingSecret: "pgadmin-login-password-secret"
env:
email: "{{ $cndi.get_prompt_response(pgadmin_login_email) }}"
persistentVolume:
enabled: true
size: 1Gi
serverDefinitions:
enabled: true
servers:
cndiServer:
Name: "My CNDI Server"
Group: "Servers"
Port: 5432
SSLMode: "prefer"
Username: "{{ $cndi.get_prompt_response(postgresql_user) }}"
Host: "{{ $cndi.get_prompt_response(postgresql_cluster_name) }}-rw"
MaintenanceDB: "{{ $cndi.get_prompt_response(postgresql_database_name) }}"
- name: deploy_jupyter_notebook_ingress_blk
content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jupyter-notebook-ingress
namespace: "jupyter-notebook"
annotations:
cert-manager.io/cluster-issuer: cluster-issuer
kubernetes.io/tls-acme: "true"
external-dns.alpha.kubernetes.io/hostname: "{{ $cndi.get_prompt_response(jupyter_notebook_hostname) }}"
spec:
ingressClassName: public
tls:
- hosts:
- "{{ $cndi.get_prompt_response(jupyter_notebook_hostname) }}"
secretName: cluster-issuer-private-key-jupyter
rules:
- host: "{{ $cndi.get_prompt_response(jupyter_notebook_hostname) }}"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: notebook
port:
number: 8888
- name: deploy_jupyter_notebook_namespace_blk
content:
apiVersion: v1
kind: Namespace
metadata:
name: jupyter-notebook
- name: deploy_jupyter_notebook_deployment_blk
content:
apiVersion: apps/v1
kind: Deployment
metadata:
name: notebook
namespace: jupyter-notebook
labels:
app: jupyter-notebook
spec:
selector:
matchLabels:
app: jupyter-notebook
template:
metadata:
labels:
app: jupyter-notebook
spec:
containers:
- name: jupyter
image: tensorflow/tensorflow:2.15.0-jupyter
resources:
requests:
memory: "4500Mi"
cpu: "1"
limits:
memory: "4500Mi"
cpu: "1"
ports:
- containerPort: 8888
env:
- name: POSTGRESQL_DB
valueFrom:
secretKeyRef:
name: postgresql-db-credentials
key: dbname
- name: POSTGRESQL_HOST
valueFrom:
secretKeyRef:
name: postgresql-db-credentials
key: host
- name: POSTGRESQL_FQDN
valueFrom:
secretKeyRef:
name: postgresql-db-credentials
key: fqdn
- name: POSTGRESQL_USER_PASSWORD
valueFrom:
secretKeyRef:
name: postgresql-db-credentials
key: password
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
name: postgresql-db-credentials
key: username
- name: JUPYTER_PASSWORD
valueFrom:
secretKeyRef:
name: jupyter-notebook-login-secret
key: jupyter-password
- name: JUPYTER_TOKEN
valueFrom:
secretKeyRef:
name: jupyter-notebook-login-secret
key: jupyter-token
volumeMounts:
- mountPath: /etc/jupyter
name: jupyter-config
- mountPath: /home/jovyan/work
name: jupyter-storage
command: [
"sh",
"-c",
"echo \"c.NotebookApp.token = '${JUPYTER_PASSWORD}'\" > /etc/jupyter/jupyter_notebook_config.py && echo \"c.NotebookApp.password = '${JUPYTER_PASSWORD}'\" >> /etc/jupyter/jupyter_notebook_config.py && echo \"c.NotebookApp.allow_password_change = False\" >> /etc/jupyter/jupyter_notebook_config.py && jupyter notebook --config=/etc/jupyter/jupyter_notebook_config.py --ip=0.0.0.0 --port=8888 --no-browser --allow-root",
]
volumes:
- name: jupyter-config
emptyDir: {}
- name: jupyter-storage
emptyDir: {}
- name: deploy_jupyter_notebook_service_blk
content:
apiVersion: v1
kind: Service
metadata:
namespace: jupyter-notebook
labels:
app: jupyter-notebook
name: notebook
spec:
ports:
- port: 8888
targetPort: 8888
selector:
app: jupyter-notebook
type: ClusterIP
- name: deploy_jupyter_notebook_postgresql_db_credentials_blk
content:
apiVersion: v1
kind: Secret
metadata:
name: postgresql-db-credentials
namespace: jupyter-notebook
type: kubernetes.io/basic-auth
stringData:
username: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_USER)
password: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_USER_PASSWORD)
dbname: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_DB)
host: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_HOST)
fqdn: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_FQDN)
- name: deploy_jupyter_notebook_login_secret_blk
content:
apiVersion: v1
kind: Secret
metadata:
name: jupyter-notebook-login-secret
namespace: jupyter-notebook
type: Opaque
stringData:
jupyter-password: $cndi_on_ow.seal_secret_from_env_var(JUPYTER_PASSWORD)
jupyter-token: $cndi_on_ow.seal_secret_from_env_var(JUPYTER_TOKEN)
- name: deploy_pgadmin_ingress_blk
content:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: pgadmin-ingress
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
annotations:
cert-manager.io/cluster-issuer: cluster-issuer
kubernetes.io/tls-acme: "true"
external-dns.alpha.kubernetes.io/hostname: "{{ $cndi.get_prompt_response(pgadmin_hostname) }}"
# if you are using an unmanaged Kubernetes distribution, you can uncomment the following line and replace the value with your load balancer hostname
# external-dns.alpha.kubernetes.io/target: my-loadbalancer.us-east-1.elb.amazonaws.com
spec:
ingressClassName: public
tls:
- hosts:
- "{{ $cndi.get_prompt_response(pgadmin_hostname) }}"
secretName: cluster-issuer-private-key-pgadmin
rules:
- host: "{{ $cndi.get_prompt_response(pgadmin_hostname) }}"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: pgadmin-pgadmin4
port:
number: 80
- name: pgadmin_login_password_secret_blk
content:
apiVersion: v1
kind: Secret
metadata:
name: pgadmin-login-password-secret
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
type: Opaque
stringData:
password: $cndi_on_ow.seal_secret_from_env_var(PGADMIN_LOGIN_PASSWORD)
prompts:
- $cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/core-prompts.yaml):
{}
- $cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/core-prompts.yaml):
{}
- name: deploy_pgadmin_application
default: true
message: >-
Do you want to install PgAdmin, a web-based database management tool?
type: Confirm
- name: deploy_pgadmin_ingress
default: true
message: >-
Do you want to expose PgAdmin to the web?
type: Confirm
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_application) }}"
- ==
- true
- name: pgadmin_hostname
default: pgadmin.example.com
message: >-
What hostname should PGAdmin be accessible at?
type: Input
validators:
- hostname # FQDN
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_ingress) }}"
- ==
- true
- name: pgadmin_login_email
default: [email protected]
message: >-
What email do you want to use for your PgAdmin login?
type: Input
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_application) }}"
- ==
- true
- name: pgadmin_login_password
default: "{{ $cndi.get_random_string(12) }}"
message: >-
What password do you want to use for your PgAdmin login ?
type: Secret
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_application) }}"
- ==
- true
- name: deploy_postgresql_ingress
default: true
message: >-
Do you want to expose your PostgreSQL database to the web?
type: Confirm
- name: postgresql_hostname
default: postgres.example.com
message: >-
What hostname should your PostgreSQL database be accessible at?
type: Input
validators:
- hostname # FQDN
- min_length: 3
condition:
- "{{ $cndi.get_prompt_response(deploy_postgresql_ingress) }}"
- ==
- true
- name: postgresql_user
default: mypostgresuser
message: >-
What username should be used for your PostgreSQL admin user?
type: Input
- name: postgresql_user_password
default: "{{ $cndi.get_random_string(12) }}"
message: >-
What will be your default password for your PostgreSQL admin user?
type: Secret
- name: postgresql_database_name
default: mypostgresdb
message: >-
What will be the name for your PostgreSQL database?
type: Input
- name: postgresql_namespace
default: postgres
message: >-
What namespace should PostgreSQL be deployed in?
type: Input
- name: postgresql_cluster_name
default: postgres-cluster
message: >-
What will be the name for your PostgreSQL cluster?
type: Input
- name: deploy_jupyter_notebook_manifests
default: true
message: >-
Do you want to install jupyterhub, a web-based data analytics tool?
type: Confirm
- name: jupyter_notebook_login_password
default: "{{ $cndi.get_random_string(12) }}"
message: >-
What will be your password for your Jupyter notebook instance?
type: Secret
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
- name: deploy_jupyter_notebook_ingress
default: true
message: >-
Do you want to expose your Jupyter notebook instance database to the web?
type: Confirm
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
- name: jupyter_notebook_hostname
default: jupyter.example.com
message: >-
What hostname should your jupyter notebook be accessible at?
type: Input
validators:
- hostname # FQDN
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_ingress) }}"
- ==
- true
outputs:
cndi_config:
cndi_version: v2
project_name: "{{ $cndi.get_prompt_response(project_name) }}"
provider: "{{ $cndi.get_prompt_response(deployment_target_provider) }}"
distribution: "{{ $cndi.get_prompt_response(deployment_target_distribution) }}"
# this is a Template comment
infrastructure:
cndi:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/observability-config.yaml):
condition:
- "{{ $cndi.get_prompt_response(deploy_grafana_ingress) }}"
- ==
- true
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/argocd-config.yaml):
condition:
- "{{ $cndi.get_prompt_response(deploy_argocd_ingress) }}"
- ==
- true
external_dns:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/external-dns/config/{{ $cndi.get_prompt_response(dns_provider) }}.yaml):
condition:
- "{{ $cndi.get_prompt_response(enable_external_dns) }}"
- ==
- true
cert_manager:
email: "{{ $cndi.get_prompt_response(cert_manager_email) }}"
nodes:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/basic-node-pool.yaml):
{}
open_ports:
- name: postgres
number: 5432
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
service: "{{ $cndi.get_prompt_response(postgresql_cluster_name) }}-rw"
cluster_manifests:
external-dns-secret:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/external-dns/secret/{{ $cndi.get_prompt_response(dns_provider) }}.yaml):
condition:
- "{{ $cndi.get_prompt_response(enable_external_dns) }}"
- ==
- true
cnpg-namespace:
apiVersion: v1
kind: Namespace
metadata:
name: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
$cndi.comment(postgres-cluster): Configure your CNPG Cluster here
cnpg-cluster:
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: "{{ $cndi.get_prompt_response(postgresql_cluster_name) }}"
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
annotations:
$cndi.comment(why_propagation_policy): PrunePropagationPolicy=background should prevent PDBs from blocking cluster destruction
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true,PrunePropagationPolicy=background
spec:
imageName: "ghcr.io/cloudnative-pg/postgresql:16"
instances: 3
storage:
size: 1Gi
replicationSlots:
highAvailability:
enabled: true
postgresql:
pg_hba:
- >-
hostssl {{ $cndi.get_prompt_response(postgresql_database_name) }} {{
$cndi.get_prompt_response(postgresql_user) }} all password
bootstrap:
initdb:
database: "{{ $cndi.get_prompt_response(postgresql_database_name) }}"
owner: "{{ $cndi.get_prompt_response(postgresql_user) }}"
secret:
name: cnpg-database-user-auth-secret
postInitApplicationSQL:
- CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA public;
superuserSecret:
name: cnpg-cluster-superuser-auth-secret
$cndi.comment(postgres-auth-secret): PostgresqlCredentials
cnpg-cluster-superuser-auth-secret:
apiVersion: v1
kind: Secret
metadata:
name: cnpg-cluster-superuser-auth-secret
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
type: kubernetes.io/basic-auth
stringData:
username: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_CLUSTER_SUPERUSER)
password: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_CLUSTER_SUPERUSER_PASSWORD)
cnpg-cluster-user-auth-secret:
apiVersion: v1
kind: Secret
metadata:
name: cnpg-database-user-auth-secret
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
type: kubernetes.io/basic-auth
stringData:
username: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_USER)
password: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_USER_PASSWORD)
cnpg-connection-string-secret:
apiVersion: v1
kind: Secret
metadata:
name: cnpg-connection-string-secret
namespace: "{{ $cndi.get_prompt_response(postgresql_namespace) }}"
type: Opaque
stringData:
connection: $cndi_on_ow.seal_secret_from_env_var(POSTGRESQL_CONNECTION_STRING)
pgadmin-login-password-secret:
$cndi.get_block(pgadmin_login_password_secret_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_application) }}"
- ==
- true
postgres-ingress:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/default-ingress.yaml):
args:
ingress_name: postgres-cluster-ingress
ingress_class_name: public
hostname: "{{ $cndi.get_prompt_response(postgresql_hostname) }}"
service_name: "{{ $cndi.get_prompt_response(postgresql_cluster_name) }}-rw"
service_port: 5432
namespace: postgres
condition:
- "{{ $cndi.get_prompt_response(deploy_postgresql_ingress) }}"
- ==
- true
pgadmin-ingress:
$cndi.get_block(deploy_pgadmin_ingress_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_ingress) }}"
- ==
- true
$cndi.comment(jupyter-notebook): Here are your jupyter-notebook resources
jupyter-notebook-ingress:
$cndi.get_block(deploy_jupyter_notebook_ingress_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_ingress) }}"
- ==
- true
jupyter-notebook-jupyter-notebook-namespace:
$cndi.get_block(deploy_jupyter_notebook_namespace_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
jupyter-notebook-jupyter-notebook-login-secret:
$cndi.get_block(deploy_jupyter_notebook_login_secret_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
jupyter-notebook-postgresql-db-credentials-secret:
$cndi.get_block(deploy_jupyter_notebook_postgresql_db_credentials_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
jupyter-notebook-service:
$cndi.get_block(deploy_jupyter_notebook_service_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
jupyter-notebook-deployment:
$cndi.get_block(deploy_jupyter_notebook_deployment_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_jupyter_notebook_manifests) }}"
- ==
- true
applications:
cnpg:
targetRevision: 0.23.0
destinationNamespace: cnpg-system
repoURL: "https://cloudnative-pg.github.io/charts"
chart: cloudnative-pg
syncPolicy:
syncOptions:
- ServerSideApply=true
pgadmin:
$cndi.get_block(deploy_pgadmin_application_blk):
condition:
- "{{ $cndi.get_prompt_response(deploy_pgadmin_application) }}"
- ==
- true
env:
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/git-credentials-{{ $cndi.get_prompt_response(git_credentials_mode) }}-env.yaml):
{}
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/env.yaml):
{}
$cndi.get_block(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/env.yaml):
{}
$cndi.comment(Postgres-heading): Postgresql Connection Parameters
POSTGRESQL_DB: "{{ $cndi.get_prompt_response(postgresql_database_name) }}"
POSTGRESQL_USER: "{{ $cndi.get_prompt_response(postgresql_user) }}"
POSTGRESQL_USER_PASSWORD: "{{ $cndi.get_prompt_response(postgresql_user_password) }}"
POSTGRESQL_PORT: "5432"
POSTGRESQL_HOST: "{{ $cndi.get_prompt_response(postgresql_hostname) }}"
POSTGRESQL_CONNECTION_STRING: "postgresql://{{ $cndi.get_prompt_response(postgresql_user) }}:{{ $cndi.get_prompt_response(postgresql_user_password) }}@{{ $cndi.get_prompt_response(postgresql_hostname) }}:5432/{{ $cndi.get_prompt_response(postgresql_database_name) }}"
POSTGRESQL_CLUSTER_SUPERUSER: postgres
POSTGRESQL_CLUSTER_SUPERUSER_PASSWORD: "{{ $cndi.get_random_string(24) }}"
PSQL_CONNECTION_COMMAND: "psql -h {{ $cndi.get_prompt_response(postgresql_hostname) }} -p 5432 -U {{ $cndi.get_prompt_response(postgresql_user) }} -d {{ $cndi.get_prompt_response(postgresql_database_name) }}"
$cndi.comment(fqdn-postgresql-connection-string-heading): FQDN Connection Parameters
FQDN_POSTGRESQL_CONNECTION_STRING: "postgresql://{{ $cndi.get_prompt_response(postgresql_user) }}:{{ $cndi.get_prompt_response(postgresql_user_password) }}@{{ $cndi.get_prompt_response(postgresql_cluster_name) }}-rw:5432/{{ $cndi.get_prompt_response(postgresql_database_name) }}"
POSTGRESQL_FQDN: "{{ $cndi.get_prompt_response(postgresql_cluster_name) }}-rw.{{ $cndi.get_prompt_response(postgresql_namespace) }}.svc.cluster.local"
$cndi.comment(cnpg-heading): PgAdmin Login Parameters
PGADMIN_LOGIN_PASSWORD: "{{ $cndi.get_prompt_response(pgadmin_login_password) }}"
PGADMIN_LOGIN_EMAIL: "{{ $cndi.get_prompt_response(pgadmin_login_email) }}"
$cndi.comment(jupyter-notebook-heading): Jupyter Notebook Login Parameters
JUPYTER_PASSWORD: "{{ $cndi.get_prompt_response(jupyter_notebook_login_password) }}"
JUPYTER_TOKEN: "{{ $cndi.get_random_string(24) }}"
readme:
project_name: "# {{ $cndi.get_prompt_response(project_name) }}"
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/common/cluster/core-readme.md):
{}
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/core.md):
{}
$cndi.get_string(https://raw.githubusercontent.com/polyseam/cndi/main/blocks/{{ $cndi.get_prompt_response(deployment_target_provider) }}/{{ $cndi.get_prompt_response(deployment_target_distribution) }}.md):
{}
cnpg: |
# CloudNativePG Deployment Guide
This Template deploys a standalone production-ready PostgreSQL database using the CloudNativePG operator on a Kubernetes cluster.
CloudNativePG, an open-source Kubernetes Operator for PostgreSQL, is designed to leverage the Kubernetes API to manage PostgreSQL instances in a cloud-native manner.
## Configuration
Customizing your CloudNativePG application is straightforward with the Helm chart's extensive configuration options, adjustable in the `cndi_config.yaml` file under `cluster_manifests.cnpg-cluster.spec`. Key areas of configuration include:
- **instances:** To adjust the number of PostgreSQL instances for scalability or redundancy, modify the `instances` value.
- **storage:** Customize the persistent volume size and specify the storage class to meet your storage requirements.
- **replicationSlots.highAvailability:** Enable high availability settings to ensure your database remains accessible in the event of a failure.
For comprehensive details on all configurable Cluster manifest properties, please refer to the [Cluster Section in the API Reference](https://cloudnative-pg.io/documentation/1.22/cloudnative-pg.v1) or the [Official CNPG Guide](https://cloudnative-pg.io/docs).
## Testing Your PostgreSQL Connection
Ensure CloudNativePG is properly accessible through your chosen domain after deploying and configuring external access.
### Using `psql` Command Line Tool
`psql` is a powerful PostgreSQL command-line interface. To test your connection:
#### Install `psql`
Ensure you have `psql` installed, included in PostgreSQL client packages.
#### Connect to the Database
Execute the command below, replacing placeholders with your postgresql host, user and database name. You'll be prompted for the password.
```bash
psql -h <hostname> -p 5432 -U <username> -d <database>
```
The POSTGRESQL_CONNECTION_STRING and PSQL_CONNECTION_COMMAND can be found in the .env file.
### Using PgAdmin
PgAdmin offers a GUI for managing your PostgreSQL databases. To connect:
**Launch PgAdmin** and navigate to the dashboard.
Enter the login and email credentials. The `PGADMIN_LOGIN_PASSWORD`, and `PGADMIN_LOGIN_EMAIL` can be found in the `.env` file.
Through a connection file, your database details are made automatically available, allowing you to simply click on your server entry in PgAdmin's browser panel to connect to your database.