|
| 1 | +--- |
| 2 | +title: 'Overview of deploying a highly available PostgreSQL database on AKS with Azure CLI' |
| 3 | +description: Learn how to deploy a highly available PostgreSQL database on AKS using the CloudNativePG operator. |
| 4 | +ms.topic: overview |
| 5 | +ms.date: 06/07/2024 |
| 6 | +author: kenkilty |
| 7 | +ms.author: kkilty |
| 8 | +ms.custom: innovation-engine, aks-related-content |
| 9 | +#Customer intent: As a developer or cluster operator, I want to deploy a highly available PostgreSQL database on AKS so I can see how to run a stateful database workload using the managed Kubernetes service in Azure. |
| 10 | +--- |
| 11 | +# Deploy a highly available PostgreSQL database on AKS with Azure CLI |
| 12 | + |
| 13 | +In this guide, you deploy a highly available PostgreSQL cluster that spans multiple Azure availability zones on AKS with Azure CLI. |
| 14 | + |
| 15 | +This article walks through the prerequisites for setting up a PostgreSQL cluster on [Azure Kubernetes Service (AKS)][what-is-aks] and provides an overview of the full deployment process and architecture. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +* This guide assumes a basic understanding of [core Kubernetes concepts][core-kubernetes-concepts] and [PostgreSQL][postgresql]. |
| 20 | +* You need the **Owner** or **User Access Administrator** and the **Contributor** [Azure built-in roles][azure-roles] on a subscription in your Azure account. |
| 21 | + |
| 22 | +[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)] |
| 23 | + |
| 24 | +* You also need the following resources installed: |
| 25 | + |
| 26 | + * [Azure CLI](/cli/azure/install-azure-cli) version 2.56 or later. |
| 27 | + * [Azure Kubernetes Service (AKS) preview extension][aks-preview]. |
| 28 | + * [jq][jq], version 1.5 or later. |
| 29 | + * [kubectl][install-kubectl] version 1.21.0 or later. |
| 30 | + * [Helm][install-helm] version 3.0.0 or later. |
| 31 | + * [openssl][install-openssl] version 3.3.0 or later. |
| 32 | + * [Visual Studio Code][install-vscode] or equivalent. |
| 33 | + * [Krew][install-krew] version 0.4.4 or later. |
| 34 | + * [kubectl CloudNativePG (CNPG) Plugin][cnpg-plugin]. |
| 35 | + |
| 36 | +## Deployment process |
| 37 | + |
| 38 | +In this guide, you learn how to: |
| 39 | + |
| 40 | +* Use Azure CLI to create a multi-zone AKS cluster. |
| 41 | +* Deploy a highly available PostgreSQL cluster and database using the [CNPG operator][cnpg-plugin]. |
| 42 | +* Set up monitoring for PostgreSQL using Prometheus and Grafana. |
| 43 | +* Deploy a sample dataset to a PostgreSQL database. |
| 44 | +* Perform PostgreSQL and AKS cluster upgrades. |
| 45 | +* Simulate a cluster interruption and PostgreSQL replica failover. |
| 46 | +* Perform backup and restore of a PostgreSQL database. |
| 47 | + |
| 48 | +## Deployment architecture |
| 49 | + |
| 50 | +This diagram illustrates a PostgreSQL cluster setup with one primary replica and two read replicas managed by the [CloudNativePG (CNPG)](https://cloudnative-pg.io/) operator. The architecture provides a highly available PostgreSQL running on an AKS cluster that can withstand a zone outage by failing over across replicas. |
| 51 | + |
| 52 | +Backups are stored on [Azure Blob Storage](/azure/storage/blobs/), providing another way to restore the database in the event of an issue with streaming replication from the primary replica. |
| 53 | + |
| 54 | +:::image source="./media/postgresql-ha-overview/architecture-diagram.png" alt-text="Diagram of CNPG architecture." lightbox="./media/postgresql-ha-overview/architecture-diagram.png"::: |
| 55 | + |
| 56 | +> [!NOTE] |
| 57 | +> The CNPG operator supports only *one database per cluster*. Plan accordingly for applications that require data separation at the database level. |
| 58 | +
|
| 59 | +## Next steps |
| 60 | + |
| 61 | +> [!div class="nextstepaction"] |
| 62 | +> [Create the infrastructure to deploy a highly available PostgreSQL database on AKS using the CNPG operator][create-infrastructure] |
| 63 | +
|
| 64 | +## Contributors |
| 65 | + |
| 66 | +*This article is maintained by Microsoft. It was originally written by the following contributors*: |
| 67 | + |
| 68 | +* Ken Kilty | Principal TPM |
| 69 | +* Russell de Pina | Principal TPM |
| 70 | +* Adrian Joian | Senior Customer Engineer |
| 71 | +* Jenny Hayes | Senior Content Developer |
| 72 | +* Carol Smith | Senior Content Developer |
| 73 | +* Erin Schaffer | Content Developer 2 |
| 74 | +* Adam Sharif | Customer Engineer 2 |
| 75 | + |
| 76 | +<!-- LINKS --> |
| 77 | +[what-is-aks]: ./what-is-aks.md |
| 78 | +[postgresql]: https://www.postgresql.org/ |
| 79 | +[core-kubernetes-concepts]: ./concepts-clusters-workloads.md |
| 80 | +[azure-roles]: ../role-based-access-control/built-in-roles.md |
| 81 | +[aks-preview]: ./draft.md#install-the-aks-preview-azure-cli-extension |
| 82 | +[jq]: https://jqlang.github.io/jq/ |
| 83 | +[install-kubectl]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ |
| 84 | +[install-helm]: https://helm.sh/docs/intro/install/ |
| 85 | +[install-openssl]: https://www.openssl.org/ |
| 86 | +[install-vscode]: https://code.visualstudio.com/Download |
| 87 | +[install-krew]: https://krew.sigs.k8s.io/ |
| 88 | +[cnpg-plugin]: https://cloudnative-pg.io/documentation/current/kubectl-plugin/#using-krew |
| 89 | +[create-infrastructure]: ./create-postgresql-ha.md |
0 commit comments