Thursday, February 1, 2024

How to Install CloudNativePG (cnpg)


In a significant development for Kubernetes users, the CloudNativePG plugin is now available, promising an enhanced deployment experience for the CloudNativePG operator. Users can easily install this plugin using the command:

kubectl krew install cnpg

This innovative plugin streamlines the deployment process by generating a comprehensive manifest file for the CloudNativePG operator, encompassing all the necessary resources. To generate these manifests, users can execute the following command:

kubectl cnpg install generate -n pg-operator --replicas 1 > pg-operator-manifests.yaml

The resulting manifest file, named pg-operator-manifests.yml, allows users to customize various aspects of the deployment. Notable configurations include specifying the number of replicas for the operator and assigning it to a dedicated namespace (pg-operator) to prevent accidental deletions.


For users seeking High Availability (HA) setups with multiple control plane/master nodes, adjusting the replica count becomes crucial. The manifest file provides the flexibility to make such decisions, aligning with the unique requirements of each Kubernetes environment.


To seamlessly integrate the CloudNativePG operator into the Kubernetes control plane, users need to consider the node deployment. By adding a toleration to the Deployment resource within the manifest file, the operator can be strategically deployed on the k8s-master node. The toleration rules guide the Kubernetes scheduler, ensuring compatibility with the specified nodes.


Here's a quick guide to adding tolerations in the manifest file:

tolerations:

- effect: NoSchedule

  key: node-role.kubernetes.io/master

  operator: Exists

- effect: NoSchedule

  key: node-role.kubernetes.io/control-plane

  operator: Exists

Following these configurations, users can deploy the manifests and verify the installation by executing the commands:

kubectl apply -f pg-operator-manifests.yaml

kubectl get pods -n pg-operator

A successful deployment should display relevant pod information, affirming the operational status of the CloudNativePG operator.


Stay tuned for more updates on groundbreaking Kubernetes tools and practices!

0 comments:

Post a Comment