{"id":3665,"date":"2023-07-28T10:55:17","date_gmt":"2023-07-28T07:55:17","guid":{"rendered":"https:\/\/www.virtono.com\/community\/?p=3665"},"modified":"2023-07-26T12:47:39","modified_gmt":"2023-07-26T09:47:39","slug":"how-to-deploy-postgres-high-availability-on-kubernetes","status":"publish","type":"post","link":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/","title":{"rendered":"How to Deploy Postgres High Availability on Kubernetes"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" data-attachment-id=\"3674\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/how-to-deploy-postgres-ha-on-kubernetes\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"How-to-Deploy-Postgres-HA-on-Kubernetes\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?fit=750%2C422&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?resize=750%2C422&#038;ssl=1\" alt=\"How to Deploy Postgres High Availability on Kubernetes\" class=\"wp-image-3674\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-Postgres-HA-on-Kubernetes.png?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>We will cover the deployment of Postgres High Availability (HA) on K3s in great detail in this article. We&#8217;ll go over the requirements, detailed instructions, and troubleshooting advice. You&#8217;ll have a reliable, scalable, and highly available Postgres setup on your K3s cluster by the end of this guide.<\/p>\n\n\n\n<p>PostgreSQL, also referred to as Postgres, is a significant player in the world of open-source, object-relational database management systems (ORDBMS). It is well known for its ability to handle a wide range of workloads, from single machines to data warehouses or web services with many concurrent users, as well as its extensibility, standards compliance, and capacity.<\/p>\n\n\n\n<p>On the other hand, K3s is a certified, lightweight Kubernetes distribution designed specifically for IoT, Edge, and ARM computing. It is simple to use, utilizes only half the memory, and has a binary size of less than 100MB.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_73 counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/#Prerequisites\" title=\"Prerequisites\">Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/#Deploying_the_Postgres_High_Availability\" title=\"Deploying the Postgres High Availability\">Deploying the Postgres High Availability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/#Verifying_the_Deployment\" title=\"Verifying the Deployment\">Verifying the Deployment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/#Connecting_to_Your_Postgres_High_Availability\" title=\"Connecting to Your Postgres High Availability\">Connecting to Your Postgres High Availability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/#Final_Thoughts\" title=\"Final Thoughts\">Final Thoughts<\/a><\/li><\/ul><\/nav><\/div>\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>You should have a fundamental understanding of Kubernetes and PostgreSQL because we&#8217;ll be working with these two technologies a lot.<\/li>\n\n\n\n<li><strong>A Running K3s Cluster<\/strong>: A functioning <a href=\"https:\/\/virtono.com\/cloud-vps\" target=\"_blank\" rel=\"noopener\">K3s cluster<\/a> is a must. If you don&#8217;t have one, follow our <a href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-redis-on-kubernetes\/\">K3s installation guide<\/a>.<\/li>\n\n\n\n<li><strong>Helm Installed<\/strong>: Helm is a Kubernetes package manager, that makes it easier to deploy apps on the container-based platform. Here is a <a href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-redis-on-kubernetes\/\">tutorial on how to install Helm<\/a>.<\/li>\n\n\n\n<li><strong>Access to a Command Line Interface (CLI)<\/strong>: A CLI is necessary to execute the required commands. This can be your local terminal or a CLI provided by a cloud service.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><span class=\"ez-toc-section\" id=\"Deploying_the_Postgres_High_Availability\"><\/span>Deploying the Postgres High Availability<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>With your K3s cluster and Helm ready, you can now <a href=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgresql-on-k3s\/\">deploy your Postgres<\/a> HA. For this, we&#8217;ll use a Helm chart.<\/p>\n\n\n\n<p>Packages of pre-configured Kubernetes resources are known as helm charts. They&#8217;re a great way to distribute applications because they&#8217;re so simple to deploy and distribute.<\/p>\n\n\n\n<p>Although there are several Helm charts for Postgres, we&#8217;ll use the Bitnami Postgres High Availability chart for this tutorial. With separate primary and standby nodes, this chart deploys a Highly Available PostgreSQL cluster.<\/p>\n\n\n\n<p>First, add the Bitnami repository to your Helm repos before deploying the Postgres High Availability:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>helm repo add bitnami https:\/\/charts.bitnami.com\/bitnami<\/code><\/pre>\n\n\n\n<p>Next, update your Helm repos:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>helm repo update<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-25-at-13.40.34.png?resize=745%2C206&#038;ssl=1\" alt=\"How to Deploy Postgres High Availability on Kubernetes \" width=\"745\" height=\"206\"\/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Now you can deploy the Postgres High Availability using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>helm install my-postgres bitnami\/postgresql-ha<\/code><\/pre>\n\n\n\n<p>This command deploys your Postgres High Availability with the default configuration. If you want to customize your deployment, you can create a custom yaml file and pass it to the helm install command.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"328\" data-attachment-id=\"3666\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/screenshot-2023-07-26-at-10-14-50\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?fit=2830%2C1238&amp;ssl=1\" data-orig-size=\"2830,1238\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-07-26-at-10.14.50\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?fit=750%2C328&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=750%2C328&#038;ssl=1\" alt=\"deploy Postgres High Availability\" class=\"wp-image-3666\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=1024%2C448&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=300%2C131&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=768%2C336&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=1536%2C672&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?resize=2048%2C896&amp;ssl=1 2048w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.14.50.png?w=2250&amp;ssl=1 2250w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><span class=\"ez-toc-section\" id=\"Verifying_the_Deployment\"><\/span>Verifying the Deployment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When the deployment is done, you can verify it by looking at the status of your pods. The simplest and smallest units that you can create or deploy in the Kubernetes object model are called pods.<\/p>\n\n\n\n<p>To find out the status of your pods, enter the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>kubectl get pods<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"190\" data-attachment-id=\"3667\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/screenshot-2023-07-26-at-10-18-38\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?fit=1748%2C442&amp;ssl=1\" data-orig-size=\"1748,442\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-07-26-at-10.18.38\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?fit=750%2C190&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?resize=750%2C190&#038;ssl=1\" alt=\"Postgres High Availability pods\" class=\"wp-image-3667\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?resize=1024%2C259&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?resize=300%2C76&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?resize=768%2C194&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?resize=1536%2C388&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.18.38.png?w=1748&amp;ssl=1 1748w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>You should see your Postgres pods running. You can examine the logs for any mistakes if they are not running. Use the kubectl logs &lt;pod-name&gt; command will give you access to a pod&#8217;s logs.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"410\" data-attachment-id=\"3668\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/screenshot-2023-07-26-at-10-22-12\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?fit=1994%2C1090&amp;ssl=1\" data-orig-size=\"1994,1090\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-07-26-at-10.22.12\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?fit=750%2C410&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?resize=750%2C410&#038;ssl=1\" alt=\"Postgres High Availability logs\" class=\"wp-image-3668\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?resize=1024%2C560&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?resize=300%2C164&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?resize=768%2C420&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?resize=1536%2C840&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.22.12.png?w=1994&amp;ssl=1 1994w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><span class=\"ez-toc-section\" id=\"Connecting_to_Your_Postgres_High_Availability\"><\/span>Connecting to Your Postgres High Availability<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>You can establish a connection to your Postgres HA once it has been operationally tested. To begin, you must obtain the Postgres password. The following command can be used to retrieve it:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>kubectl get secret my-postgres-postgresql-ha-postgresql --namespace default -o json<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"377\" data-attachment-id=\"3669\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/screenshot-2023-07-26-at-10-24-50\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?fit=1852%2C932&amp;ssl=1\" data-orig-size=\"1852,932\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-07-26-at-10.24.50\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?fit=750%2C377&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?resize=750%2C377&#038;ssl=1\" alt=\"find Postgres High Availability password secret\" class=\"wp-image-3669\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?resize=1024%2C515&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?resize=300%2C151&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?resize=768%2C386&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?resize=1536%2C773&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.24.50.png?w=1852&amp;ssl=1 1852w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>This command will return the base64 encoded password.<\/p>\n\n\n\n<p><strong>Decode the Password<\/strong>: The password is stored in base64 format, so you&#8217;ll need to decode it. You can do this with the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>echo \"Ym5BNU40SnZvaw==\" | base64 --decode\nbnA5N4Jvok<\/code><\/pre>\n\n\n\n<p>Next, you can connect to your Postgres High Availability database using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background\"><code>kubectl run my-postgres-postgresql-client --rm --tty -i --restart='Never' --namespace default --image docker.io\/bitnami\/postgresql:11.7.0-debian-10-r9 --env=\"PGPASSWORD=bnA5N4Jvok\" --command -- psql --host my-postgres-postgresql-ha-postgresql -U postgres -d postgres -p 5432<\/code><\/pre>\n\n\n\n<p>Make sure to change PGPASSWORD= with your values.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"134\" data-attachment-id=\"3670\" data-permalink=\"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgres-high-availability-on-kubernetes\/attachment\/screenshot-2023-07-26-at-10-28-42\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?fit=2830%2C506&amp;ssl=1\" data-orig-size=\"2830,506\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screenshot-2023-07-26-at-10.28.42\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?fit=750%2C134&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=750%2C134&#038;ssl=1\" alt=\"Connecting to Your Postgres HA\" class=\"wp-image-3670\" srcset=\"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=1024%2C183&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=300%2C54&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=768%2C137&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=1536%2C275&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?resize=2048%2C366&amp;ssl=1 2048w, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Screenshot-2023-07-26-at-10.28.42.png?w=2250&amp;ssl=1 2250w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading has-accent-color has-text-color\"><span class=\"ez-toc-section\" id=\"Final_Thoughts\"><\/span>Final Thoughts<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If you&#8217;re unfamiliar with Kubernetes or databases, setting up a Postgres HA on K3s may seem like a daunting task. However, it can be made simple with the right resources and advice. Starting with setting up your K3s cluster and ending with connecting to your Postgres HA, this guide has walked you through every step of the procedure.<\/p>\n\n\n\n<p>Remember that knowing what each tool does and how they work together is the key to a successful deployment. If you have any questions or would like to learn more, don&#8217;t be afraid to look through the official documentation of each tool.<\/p>\n\n\n\n<p>You can deploy a highly available Postgres database that can act as the foundation for your applications by utilizing the strength of K3s and Helm, giving you a solid, scalable, and dependable data storage solution. K3s and Postgres offer a powerful combination that can meet your needs, whether you&#8217;re a developer looking to deploy your applications or a business looking for a dependable data storage solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will cover the deployment of Postgres High Availability (HA) on K3s in great detail in this article. We&#8217;ll go over the requirements, detailed instructions, and troubleshooting advice. You&#8217;ll have a reliable, scalable, and highly available Postgres setup on your K3s cluster by the end of this guide. PostgreSQL, also<\/p>\n","protected":false},"author":8,"featured_media":3673,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[571,573,574,569,570,568,572],"class_list":["post-3665","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial-how-to","tag-deploy-postgres-ha","tag-deploy-postgres-high-availability","tag-how-to-deploy-postgres-ha","tag-postgres-ha","tag-postgres-ha-on-kubernetes","tag-postgres-high-availability","tag-postgres-high-availability-on-kubernetes"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/Deploy-Postgres-HA-on-Kubernetes.png?fit=360%2C240&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7ISfL-X7","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3655,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-deploy-postgresql-on-k3s\/","url_meta":{"origin":3665,"position":0},"title":"How to Deploy PostgreSQL on K3s","author":"George B.","date":"July 26, 2023","format":false,"excerpt":"This guide will provide a detailed walkthrough on how to deploy PostgreSQL on K3s cluster. Everything will be covered, from the necessary steps to the deployment procedure, testing, and connection to the PostgreSQL database. K3s is a certified, lightweight Kubernetes distribution designed for the Internet of Things and edge computing.\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/07\/How-to-Deploy-PostgreSQL-on-K3s.png?fit=360%2C240&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1787,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-postgresql-on-centos-7\/","url_meta":{"origin":3665,"position":1},"title":"How to Install PostgreSQL on CentOS 7","author":"Shreyash Sharma","date":"July 30, 2020","format":false,"excerpt":"In my experience I have found that Postgres has proved to the be most reliable relational database platform. This is largely based on the fact that is open source and the community is huge. It is scalable across platforms and is a widely used and well-loved tool. In this tutorial,\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/1_PY24xlr4TpOkXW04HUoqrQ.jpeg?fit=800%2C400&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/1_PY24xlr4TpOkXW04HUoqrQ.jpeg?fit=800%2C400&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/1_PY24xlr4TpOkXW04HUoqrQ.jpeg?fit=800%2C400&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2020\/07\/1_PY24xlr4TpOkXW04HUoqrQ.jpeg?fit=800%2C400&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2319,"url":"https:\/\/www.virtono.com\/community\/knowledgebase\/overview-of-docker-commands-part-1\/","url_meta":{"origin":3665,"position":2},"title":"Overview of Docker Commands Part &#8211; 1","author":"Shreyash Sharma","date":"March 10, 2021","format":false,"excerpt":"I suggest you get machine to follow along this part. So here's a little plug of our own: Cloud VPS, for as little as \u20ac2.95 a month. This article is a part of our complete series of articles on Docker. Click here to access the Free Series. Back to the\u2026","rel":"","context":"In &quot;Knowledgebase&quot;","block_context":{"text":"Knowledgebase","link":"https:\/\/www.virtono.com\/community\/category\/knowledgebase\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2021\/03\/1_HS1OsFO7ayf_ZUzPus1FCQ.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2021\/03\/1_HS1OsFO7ayf_ZUzPus1FCQ.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2021\/03\/1_HS1OsFO7ayf_ZUzPus1FCQ.jpeg?fit=1200%2C675&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2021\/03\/1_HS1OsFO7ayf_ZUzPus1FCQ.jpeg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2021\/03\/1_HS1OsFO7ayf_ZUzPus1FCQ.jpeg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3752,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-postgresql-on-ubuntu-22-04\/","url_meta":{"origin":3665,"position":3},"title":"How to install PostgreSQL on Ubuntu 22.04","author":"George B.","date":"August 21, 2023","format":false,"excerpt":"This tutorial will take you step-by-step through the installation of PostgreSQL on Ubuntu 22.04, explaining all necessary setup steps along the way. It will also show you how to create and manage your first PostgreSQL database. PostgreSQL, also known as Postgres, is an open-source relational database management system (RDBMS) that\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/08\/How-to-install-PostgreSQL-on-Ubuntu-22.04.png?fit=360%2C240&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1124,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/installing-zabbix-3-0-on-ubuntu-16-04-with-postgresql\/","url_meta":{"origin":3665,"position":4},"title":"Installing zabbix 3.0 on Ubuntu 16.04 with PostgreSQL","author":"Shreyash Sharma","date":"October 15, 2017","format":false,"excerpt":"A few days ago I installed Zabbix 3.0 under Ubuntu 16.04.\u00a0Since I would like to deal with PostgreSQL, I decided to use it as a database. installation The first release of Zabbix's release package is the following: 1 wget http:\/\/repo.zabbix.com\/zabbix\/3.0\/ubuntu\/pool\/main\/z\/zabbix-release\/zabbix-release_3.0-1+xenial_all.deb which is then installed 1 dpkg -i zabbix-release_3.0-1+xenial_all.deb So now\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3432,"url":"https:\/\/www.virtono.com\/community\/tutorial-how-to\/how-to-install-django-on-linux\/","url_meta":{"origin":3665,"position":5},"title":"How to Install Django on Linux","author":"George B.","date":"May 31, 2023","format":false,"excerpt":"If you're a Linux user and want to dive into Django development, this step-by-step guide will walk you through the installation of Django on Linux process. Django is a powerful and popular web framework for building robust and scalable web applications. By the end, you'll have Django up and running\u2026","rel":"","context":"In &quot;Tutorials&quot;","block_context":{"text":"Tutorials","link":"https:\/\/www.virtono.com\/community\/category\/tutorial-how-to\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.virtono.com\/community\/wp-content\/uploads\/2023\/05\/How-to-Install-Django-on-Linux.png?fit=600%2C330&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/3665","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/comments?post=3665"}],"version-history":[{"count":3,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/3665\/revisions"}],"predecessor-version":[{"id":3676,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/posts\/3665\/revisions\/3676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media\/3673"}],"wp:attachment":[{"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/media?parent=3665"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/categories?post=3665"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.virtono.com\/community\/wp-json\/wp\/v2\/tags?post=3665"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}