Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Tingwei
Tingwei

Posted on • Edited on

     

Setting Up CloudNativePG on KIND with pgAdmin

1. Install Prerequisites

Install Helm, KIND, kubectl, and pgAdmin4.

2. Create KIND Cluster

Runkind create cluster --name myk8s --config cluster.yaml

### cluster.yamlkind:ClusterapiVersion:kind.x-k8s.io/v1alpha4nodes:-role:control-plane-role:worker-role:worker
Enter fullscreen modeExit fullscreen mode

3. Deploy CloudNativePG Operator

helm repo add cnpg https://cloudnative-pg.github.io/chartshelm repo updatehelminstallcnpg cnpg/cloudnative-pg--namespace cnpg-system--create-namespace
Enter fullscreen modeExit fullscreen mode

4. Deploy PostgreSQL Cluster

Runkubectl apply -f postgres.yaml

## postgres.yamlapiVersion:postgresql.cnpg.io/v1kind:Clustermetadata:name:pg-clusterlabels:app:pgspec:instances:3storage:pvcTemplate:accessModes:-ReadWriteOnceresources:requests:storage:1GistorageClassName:standardvolumeMode:Filesystempostgresql:parameters:shared_buffers:256MB---# pgBouncerapiVersion:postgresql.cnpg.io/v1kind:Poolermetadata:name:pg-poolerlabels:app:pgspec:cluster:name:pg-clusterinstances:3type:rwserviceTemplate:metadata:labels:app:pgspec:type:LoadBalancerpgbouncer:poolMode:sessionparameters:max_client_conn:"1000"default_pool_size:"10"
Enter fullscreen modeExit fullscreen mode

arch

5. Install Kubernetes Cloud Provider for KIND

  • Installation
  • Control-plane nodes need to remove the label to access workloads via aLoadBalancer service.
kubectl label node myk8s-control-plane node.kubernetes.io/exclude-from-external-load-balancers-
Enter fullscreen modeExit fullscreen mode
  • Run As administrator
cloud-provider-kind
Enter fullscreen modeExit fullscreen mode

6. Connect to PostgreSQL with pgAdmin4

Open pgAdmin4, create a new server with PostgreSQL connection details

  • EXTERNAL-IP
kubectl get svc pg-pooler
Enter fullscreen modeExit fullscreen mode
kubectl get secret pg-cluster-app-o yaml## check data.passwordecho <password> |base64-d
Enter fullscreen modeExit fullscreen mode
host=<External IP>port=5432database=appuser=apppassword=<password>
Enter fullscreen modeExit fullscreen mode

References

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

A journey of self-discovery
  • Joined

More fromTingwei

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp