You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `aks-preview`, `k8s-extension` and `amg` extensions provide more functionality for managing Kubernetes clusters and querying Azure resources. Install these extensions using the following [`az extension add`][az-extension-add] commands:
49
49
50
-
```azurecli-interactive
50
+
```bash
51
51
az extension add --upgrade --name aks-preview --yes --allow-preview true
52
52
az extension add --upgrade --name k8s-extension --yes --allow-preview false
53
53
az extension add --upgrade --name amg --yes --allow-preview false
54
54
```
55
55
56
56
As a prerequisite for utilizing kubectl, it is essential to first install [Krew][install-krew], followed by the installation of the [CNPG plugin][cnpg-plugin]. This will enable the management of the PostgreSQL operator using the subsequent commands.
57
57
58
-
```azurecli
58
+
```bash
59
59
(
60
60
set -x;cd"$(mktemp -d)"&&
61
61
OS="$(uname | tr '[:upper:]''[:lower:]')"&&
@@ -75,7 +75,7 @@ kubectl krew install cnpg
75
75
76
76
Create a resource group to hold the resources you create in this guide using the [`az group create`][az-group-create] command.
77
77
78
-
```azurecli-interactive
78
+
```bash
79
79
az group create \
80
80
--name $RESOURCE_GROUP_NAME \
81
81
--location $PRIMARY_CLUSTER_REGION \
@@ -90,7 +90,7 @@ In this section, you create a user-assigned managed identity (UAMI) to allow the
90
90
91
91
1. Create a user-assigned managed identity using the [`az identity create`][az-identity-create] command.
92
92
93
-
```azurecli-interactive
93
+
```bash
94
94
AKS_UAMI_WI_IDENTITY=$(az identity create \
95
95
--name $AKS_UAMI_CLUSTER_IDENTITY_NAME \
96
96
--resource-group $RESOURCE_GROUP_NAME \
@@ -100,7 +100,7 @@ In this section, you create a user-assigned managed identity (UAMI) to allow the
100
100
101
101
1. Enable AKS workload identity and generate a service account to use later in this guide using the following commands:
@@ -121,7 +121,7 @@ The CNPG operator automatically generates a service account called *postgres* th
121
121
122
122
1. Create an object storage account to store PostgreSQL backups in the primary region using the [`az storage account create`][az-storage-account-create] command.
123
123
124
-
```azurecli-interactive
124
+
```bash
125
125
az storage account create \
126
126
--name $PG_PRIMARY_STORAGE_ACCOUNT_NAME \
127
127
--resource-group $RESOURCE_GROUP_NAME \
@@ -134,7 +134,7 @@ The CNPG operator automatically generates a service account called *postgres* th
134
134
135
135
1. Create the storage container to store the Write Ahead Logs (WAL) and regular PostgreSQL on-demand and scheduled backups using the [`az storage container create`][az-storage-container-create] command.
136
136
137
-
```azurecli-interactive
137
+
```bash
138
138
az storage container create \
139
139
--name $PG_STORAGE_BACKUP_CONTAINER_NAME \
140
140
--account-name $PG_PRIMARY_STORAGE_ACCOUNT_NAME \
@@ -144,7 +144,7 @@ The CNPG operator automatically generates a service account called *postgres* th
144
144
> [!NOTE]
145
145
> If you encounter the error message: `The request may be blocked by network rules of storage account. Please check network rule set using 'az storage account show -n accountname --query networkRuleSet'. If you want to change the default action to apply when no rule matches, please use 'az storage account update'`. Please verify user permissions for Azure Blob Storage and, if**necessary**, elevate your role to `Storage Blob Data Owner` using the commands provided below.
146
146
147
-
```azurecli-interactive
147
+
```bash
148
148
az role assignment list --scope $STORAGE_ACCOUNT_PRIMARY_RESOURCE_ID --output table
149
149
150
150
export USER_ID=$(az ad signed-in-user show --query id --output tsv)
@@ -168,7 +168,7 @@ To enable backups, the PostgreSQL cluster needs to read and write to an object s
168
168
169
169
1. Get the primary resource ID for the storage account using the [`az storage account show`][az-storage-account-show] command.
170
170
171
-
```azurecli-interactive
171
+
```bash
172
172
export STORAGE_ACCOUNT_PRIMARY_RESOURCE_ID=$(az storage account show \
173
173
--name $PG_PRIMARY_STORAGE_ACCOUNT_NAME \
174
174
--resource-group $RESOURCE_GROUP_NAME \
@@ -180,7 +180,7 @@ To enable backups, the PostgreSQL cluster needs to read and write to an object s
180
180
181
181
1. Assign the "Storage Blob Data Contributor" Azure built-in role to the object ID with the storage account resource ID scope for the UAMI associated with the managed identity for each AKS cluster using the [`az role assignment create`][az-role-assignment-create] command.
@@ -253,7 +253,7 @@ You also add a user node pool to the AKS cluster to host the PostgreSQL cluster.
253
253
254
254
1. Create an AKS cluster using the [`az aks create`][az-aks-create] command.
255
255
256
-
```azurecli-interactive
256
+
```bash
257
257
export SYSTEM_NODE_POOL_VMSKU="standard_d2s_v3"
258
258
export USER_NODE_POOL_NAME="postgres"
259
259
export USER_NODE_POOL_VMSKU="standard_d4s_v3"
@@ -289,7 +289,7 @@ You also add a user node pool to the AKS cluster to host the PostgreSQL cluster.
289
289
290
290
2. Add a user node pool to the AKS cluster using the [`az aks nodepool add`][az-aks-node-pool-add] command.
291
291
292
-
```azurecli-interactive
292
+
```bash
293
293
az aks nodepool add \
294
294
--resource-group $RESOURCE_GROUP_NAME \
295
295
--cluster-name $AKS_PRIMARY_CLUSTER_NAME \
@@ -312,7 +312,7 @@ In this section, you get the AKS cluster credentials, which serve as the keys th
312
312
313
313
1. Get the AKS cluster credentials using the [`az aks get-credentials`][az-aks-get-credentials] command.
314
314
315
-
```azurecli-interactive
315
+
```bash
316
316
az aks get-credentials \
317
317
--resource-group $RESOURCE_GROUP_NAME \
318
318
--name $AKS_PRIMARY_CLUSTER_NAME \
@@ -321,7 +321,7 @@ In this section, you get the AKS cluster credentials, which serve as the keys th
321
321
322
322
2. Create the namespace for the CNPG controller manager services, the PostgreSQL cluster, and its related services by using the [`kubectl create namespace`][kubectl-create-namespace] command.
@@ -332,7 +332,7 @@ The Azure Monitor workspace for Managed Prometheus and Azure Managed Grafana are
332
332
333
333
1. Enable Container insights monitoring on the AKS cluster using the [`az aks enable-addons`][az-aks-enable-addons] command.
334
334
335
-
```azurecli-interactive
335
+
```bash
336
336
az aks enable-addons \
337
337
--addon monitoring \
338
338
--name $AKS_PRIMARY_CLUSTER_NAME \
@@ -343,7 +343,7 @@ The Azure Monitor workspace for Managed Prometheus and Azure Managed Grafana are
343
343
344
344
2. Validate that Managed Prometheus is scraping metrics and Container insights is ingesting logs from the AKS cluster by inspecting the DaemonSet using the [`kubectl get`][kubectl-get] command and the [`az aks show`][az-aks-show] command.
345
345
346
-
```azurecli-interactive
346
+
```bash
347
347
kubectl get ds ama-metrics-node \
348
348
--context $AKS_PRIMARY_CLUSTER_NAME \
349
349
--namespace=kube-system
@@ -385,7 +385,7 @@ To validate deployment of the PostgreSQL cluster and use client PostgreSQL tooli
385
385
386
386
1. Get the name of the AKS cluster node resource group using the [`az aks show`][az-aks-show] command.
387
387
388
-
```azurecli-interactive
388
+
```bash
389
389
export AKS_PRIMARY_CLUSTER_NODERG_NAME=$(az aks show \
390
390
--name $AKS_PRIMARY_CLUSTER_NAME \
391
391
--resource-group $RESOURCE_GROUP_NAME \
@@ -397,7 +397,7 @@ To validate deployment of the PostgreSQL cluster and use client PostgreSQL tooli
397
397
398
398
2. Create the public IP address using the [`az network public-ip create`][az-network-public-ip-create] command.
@@ -424,7 +424,7 @@ To validate deployment of the PostgreSQL cluster and use client PostgreSQL tooli
424
424
425
425
4. Get the resource ID of the node resource group using the [`az group show`][az-group-show] command.
426
426
427
-
```azurecli-interactive
427
+
```bash
428
428
export AKS_PRIMARY_CLUSTER_NODERG_NAME_SCOPE=$(az group show --name \
429
429
$AKS_PRIMARY_CLUSTER_NODERG_NAME \
430
430
--query id \
@@ -435,7 +435,7 @@ To validate deployment of the PostgreSQL cluster and use client PostgreSQL tooli
435
435
436
436
5. Assign the "Network Contributor" role to the UAMI object ID using the node resource group scope using the [`az role assignment create`][az-role-assignment-create] command.
0 commit comments