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
3. Deploy CloudNativePG Operator
helm repo add cnpg https://cloudnative-pg.github.io/chartshelm repo updatehelminstallcnpg cnpg/cloudnative-pg--namespace cnpg-system--create-namespace
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"
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-
- Run As administrator
cloud-provider-kind
6. Connect to PostgreSQL with pgAdmin4
Open pgAdmin4, create a new server with PostgreSQL connection details
- EXTERNAL-IP
kubectl get svc pg-pooler
- Password (pg-cluster-app)
kubectl get secret pg-cluster-app-o yaml## check data.passwordecho <password> |base64-d
host=<External IP>port=5432database=appuser=apppassword=<password>
References
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse