|
| 1 | += Create a Customer-Managed VNet on Azure |
| 2 | +:description: Connect Redpanda Cloud to your existing VNet for additional security. |
| 3 | + |
| 4 | +include::shared:partial$feature-flag.adoc[] |
| 5 | + |
| 6 | +With a standard BYOC cluster, Redpanda manages the networking lifecycle. For additional security, you can deploy the Redpanda glossterm:data plane[] into your existing virtual network (VNet) and manage the lifecycle yourself. When you create a customer-managed VNet cluster, you specify your VNet and managed identities. The Redpanda Cloud agent doesn't create any new resources or alter any settings in your account. With a *customer-managed* VNet: |
| 7 | + |
| 8 | +* You provide your own VNet in your Azure account. |
| 9 | +* You maintain more control over your account, because Redpanda requires fewer permissions than standard BYOC clusters. |
| 10 | +* You control your security resources and policies, including subnets, user-assigned identities, IAM roles and assignments, security groups, storage accounts, and key vaults. |
| 11 | +
|
| 12 | +The https://github.com/redpanda-data/cloud-examples/tree/main/customer-managed/azure[Redpanda repository^] contains the code that deploys the resources you must create for a customer-managed Azure cluster. You create these resources in advance and provide them to Redpanda during cluster creation. The code is provided in https://developer.hashicorp.com/terraform[Terraform^]. There may be resources in the repository that already exist in your environment that you don't want to create (for example, the VNet). Variables are provided for this purpose. |
| 13 | + |
| 14 | +See the code for the complete list of resources required to create and deploy Redpanda cluster. Customer-managed resources can be broken down into the following groups: |
| 15 | + |
| 16 | +* Resource group resources |
| 17 | +* User-assigned identities |
| 18 | +* IAM roles and assignments |
| 19 | +* Network |
| 20 | +* Storage |
| 21 | +* Key vaults |
| 22 | +
|
| 23 | +== Prerequisites |
| 24 | + |
| 25 | +* Access to an Azure subscription where you want to create your cluster |
| 26 | +* Knowledge of your internal VNet and subnet configuration |
| 27 | +* Permission to call the xref:manage:api/cloud-api-overview.adoc[Redpanda Cloud API] |
| 28 | +* Permission to create, modify, and delete the resources described by Terraform |
| 29 | +* https://developer.hashicorp.com/terraform/install[Terraform version 1.8.5 or later^] |
| 30 | + |
| 31 | +== Limitations |
| 32 | + |
| 33 | +* You cannot move existing clusters to a customer-managed VNet. |
| 34 | +* You cannot change to a different VNet after creating a cluster with a customer-managed VNet. |
| 35 | + |
| 36 | +== Deploy customer-managed resources With Terraform |
| 37 | + |
| 38 | +You may want to configure https://developer.hashicorp.com/terraform/language/state/remote[remote state^] for this Terraform. For simplicity, these instructions assume local state. |
| 39 | + |
| 40 | +=== Configure the variables |
| 41 | + |
| 42 | +Create a JSON file called `byovnet.auto.tfvars.json` inside the Terraform directory to configure variables for your specific needs: |
| 43 | + |
| 44 | +``` |
| 45 | +{ |
| 46 | + "azure_tenant_id": "", |
| 47 | + "azure_subscription_id": "", |
| 48 | + "region": "", |
| 49 | + "resource_name_prefix": "", |
| 50 | + "tags": {}, |
| 51 | + "redpanda_resource_group_name": "", |
| 52 | + "redpanda_storage_resource_group_name": "", |
| 53 | + "redpanda_network_resource_group_name": "", |
| 54 | + "redpanda_iam_resource_group_name": "", |
| 55 | + "redpanda_agent_identity_name": "", |
| 56 | + "redpanda_external_dns_identity_name": "", |
| 57 | + "redpanda_cluster_identity_name": "", |
| 58 | + "redpanda_cert_manager_identity_name": "", |
| 59 | + "aks_identity_name": "", |
| 60 | + "redpanda_console_identity_name": "", |
| 61 | + "kafka_connect_identity_name": "", |
| 62 | + "redpanda_management_storage_account_name": "", |
| 63 | + "redpanda_management_storage_container_name": "", |
| 64 | + "redpanda_tiered_storage_account_name": "", |
| 65 | + "redpanda_tiered_storage_container_name": "", |
| 66 | + "redpanda_management_key_vault_name": "", |
| 67 | + "redpanda_console_key_vault_name": "", |
| 68 | + "vnet_name": "", |
| 69 | + "vnet_addresses": "10.0.0.0/20", |
| 70 | + "private_subnets": {}, |
| 71 | + "egress_subnets": {}, |
| 72 | + "reserved_subnet_cidrs": {}, |
| 73 | + "redpanda_security_group_name": "" |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +The https://github.com/redpanda-data/cloud-examples/blob/main/customer-managed/azure/terraform/README.md[Terraform Readme] has more information about the variable files: |
| 78 | + |
| 79 | +* `vars.azure.tf`: Contains the variables related to Azure credentials. |
| 80 | +* `vars.condition.tf`: Contains the conditional variables; for example, on whether to create NAT. |
| 81 | +* `vars.customer_input.tf`: Contains the variables needed to create a cluster with the Cloud API. |
| 82 | +* `vars.iam.tf`: Contains the variables related to IAM roles. |
| 83 | +* `vars.misc.tf`: Contains the variables, regions, zones, tags, and resource name prefix. |
| 84 | + |
| 85 | +=== Initialize Terraform |
| 86 | + |
| 87 | +Initialize the working directory containing Terraform configuration files: |
| 88 | + |
| 89 | +``` |
| 90 | +terraform init |
| 91 | +``` |
| 92 | + |
| 93 | +=== Apply Terraform |
| 94 | + |
| 95 | +``` |
| 96 | +terraform apply |
| 97 | +``` |
| 98 | + |
| 99 | +The output of `terraform apply` displays output values. Note these values, because they are needed in subsequent steps. To continue with cluster creation, see https://github.com/redpanda-data/cloud-examples/tree/main/customer-managed/azure#create-azure-byo-vnet-redpanda-cluster[Create Azure VNet Redpanda Cluster^]. |
| 100 | + |
| 101 | +You can also get these values by running `terraform output`. For example: |
| 102 | + |
| 103 | +``` |
| 104 | +agent_private_subnet_name = "my-snet-agent-private" |
| 105 | +agent_user_assigned_identity_name = "my-agent-uai" |
| 106 | +aks_user_assigned_identity_name = "my-aks-uai" |
| 107 | +cert_manager_user_assigned_identity_name = "my-cert-manager-uai" |
| 108 | +cluster_user_assigned_identity_name = "my-cluster-uai" |
| 109 | +console_key_vault_name = "my-consolevault" |
| 110 | +console_user_assigned_identity_name = "my-console-uai" |
| 111 | +egress_subnet_name = "my-snet-agent-public" |
| 112 | +external_dns_user_assigned_identity_name = "my-external-dns-uai" |
| 113 | +iam_resource_group_name = "my-iam-rg" |
| 114 | +kafka_connect_pods_subnet_name = "my-snet-kafka-connect-pods" |
| 115 | +kafka_connect_user_assigned_identity_name = "my-kafka-connect-uai" |
| 116 | +kafka_connect_vnet_subnet_name = "my-snet-kafka-connect-vnet" |
| 117 | +management_bucket_storage_account_name = "mymanagement" |
| 118 | +management_bucket_storage_container_name = "mymanagement" |
| 119 | +management_key_vault_name = "my-redpandavault" |
| 120 | +network_resource_group_name = "my-network-rg" |
| 121 | +...... |
| 122 | +redpanda_resource_group_name = "my-redpanda-rg" |
| 123 | +redpanda_security_group_name = "my-redpanda-nsg" |
| 124 | +...... |
| 125 | +rp_0_pods_subnet_name = "my-snet-rp-0-pods" |
| 126 | +rp_0_vnet_subnet_name = "my-snet-rp-0-vnet" |
| 127 | +rp_1_pods_subnet_name = "my-snet-rp-1-pods" |
| 128 | +rp_1_vnet_subnet_name = "my-snet-rp-1-vnet" |
| 129 | +rp_2_pods_subnet_name = "my-snet-rp-2-pods" |
| 130 | +rp_2_vnet_subnet_name = "my-snet-rp-2-vnet" |
| 131 | +rp_connect_pods_subnet_name = "my-snet-connect-pods" |
| 132 | +rp_connect_vnet_subnet_name = "my-snet-connect-vnet" |
| 133 | +...... |
| 134 | +storage_resource_group_name = "my-storage-rg" |
| 135 | +system_pods_subnet_name = "my-snet-system-pods" |
| 136 | +system_vnet_subnet_name = "my-snet-system-vnet" |
| 137 | +tiered_storage_account_name = "mytieredstorage" |
| 138 | +tiered_storage_container_name = "mytieredstorage" |
| 139 | +...... |
| 140 | +vnet_name = "my-rp-vnet" |
| 141 | +``` |
| 142 | + |
| 143 | +== Create a network with the Cloud API |
| 144 | + |
| 145 | +. Create a network with the POST body, and replace the variables with your actual values. To create a resource group and bearer token, follow the xref:manage:api/cloud-api-quickstart.adoc#try-the-cloud-api[Cloud API Quickstart]. |
| 146 | ++ |
| 147 | +``` |
| 148 | +network_post_body=`cat << EOF |
| 149 | +{ |
| 150 | + "cloud_provider": "CLOUD_PROVIDER_AZURE", |
| 151 | + "cluster_type": "TYPE_BYOC", |
| 152 | + "name": "$rp_cluster_name", |
| 153 | + "resource_group_id": "$resource_group_id", |
| 154 | + "region": "$region", |
| 155 | + "customer_managed_resources": { |
| 156 | + "azure" : { |
| 157 | + "management_bucket" : { |
| 158 | + "storage_account_name": "$redpanda_management_storage_account_name", |
| 159 | + "storage_container_name": "$redpanda_management_storage_container_name", |
| 160 | + "resource_group" : { "name" : "$redpanda_resource_group_name" } |
| 161 | + }, |
| 162 | + "vnet" : { |
| 163 | + "name" : "$vnet_name", |
| 164 | + "resource_group" : { "name" : "$redpanda_network_resource_group_name" } |
| 165 | + }, |
| 166 | + "subnets" : { |
| 167 | + "rp_0_pods" : { "name" : "$rp_0_pods_subnet_name" }, |
| 168 | + "rp_0_vnet" : { "name" : "$rp_0_vnet_subnet_name" }, |
| 169 | + "rp_1_pods" : { "name" : "$rp_1_pods_subnet_name" }, |
| 170 | + "rp_1_vnet" : { "name" : "$rp_2_vnet_subnet_name" }, |
| 171 | + "rp_2_pods" : { "name" : "$rp_2_pods_subnet_name" }, |
| 172 | + "rp_2_vnet" : { "name" : "$rp_2_vnet_subnet_name" }, |
| 173 | + "rp_connect_pods" : { "name" : "$rp_connect_pods_subnet_name" }, |
| 174 | + "rp_connect_vnet" : { "name" : "$rp_connect_vnet_subnet_name" }, |
| 175 | + "kafka_connect_pods" : { "name" : "$kafka_connect_pods_subnet_name" }, |
| 176 | + "kafka_connect_vnet" : { "name" : "$kafka_connect_vnet_subnet_name" }, |
| 177 | + "sys_pods" : { "name" : "$system_pods_subnet_name" }, |
| 178 | + "sys_vnet" : { "name" : "$system_vnet_subnet_name" }, |
| 179 | + "rp_agent" : { "name" : "$rp_agent_subnet_name" }, |
| 180 | + "rp_egress_vnet" : { "name" : "$rp_egress_subnet_name" } |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | +} |
| 185 | +EOF` |
| 186 | +``` |
| 187 | + |
| 188 | +. Make a Cloud API call to create a Redpanda network and get the network ID from the response in JSON `.operation.metadata.network_id`. |
| 189 | ++ |
| 190 | +``` |
| 191 | +curl -vv -X POST \ |
| 192 | + -H "Content-Type: application/json" \ |
| 193 | + -H "Authorization: Bearer $token" \ |
| 194 | + -d "$network_post_body" $PUBLIC_API_ENDPOINT/v1beta2/networks |
| 195 | +``` |
| 196 | + |
| 197 | +== Create a cluster with the Cloud API |
| 198 | + |
| 199 | +. A network ID is required to create a Redpanda cluster. Replace the variables with your actual values. To create a resource group and bearer token, follow the xref:manage:api/cloud-api-quickstart.adoc#try-the-cloud-api[Cloud API Quickstart]. |
| 200 | ++ |
| 201 | +``` |
| 202 | +cluster_post_body=`cat << EOF |
| 203 | +{ |
| 204 | + "cloud_provider": "CLOUD_PROVIDER_AZURE", |
| 205 | + "connection_type": "CONNECTION_TYPE_PRIVATE", |
| 206 | + "name": "$cluster_name", |
| 207 | + "resource_group_id": "$namespace_id", |
| 208 | + "network_id": "$network_id", |
| 209 | + "region": "$region", |
| 210 | + "zones": [ $zones ], |
| 211 | + "throughput_tier": "$tier", |
| 212 | + "type": "TYPE_BYOC", |
| 213 | + "customer_managed_resources" : { |
| 214 | + "azure" : { |
| 215 | + "cidrs" : { |
| 216 | + "aks_service_cidr" : "$aks_subnet_cidr" |
| 217 | + }, |
| 218 | + "key_vaults": { |
| 219 | + "console_vault": { "name": "$redpanda_console_key_vault_name" }, |
| 220 | + "management_vault": { "name": "$redpanda_management_key_vault_name" } |
| 221 | + }, |
| 222 | + "resource_groups" : { |
| 223 | + "iam_resource_group" : { "name": "$redpanda_iam_resource_group_name" }, |
| 224 | + "redpanda_resource_group" : { "name": "$redpanda_resource_group_name" }, |
| 225 | + "storage_resource_group" : { "name": "$redpanda_storage_resource_group_name" } |
| 226 | + }, |
| 227 | + "security_groups" : { |
| 228 | + "redpanda_security_group" : { "name": "$redpanda_security_group_name" } |
| 229 | + }, |
| 230 | + "tiered_cloud_storage" : { |
| 231 | + "storage_account_name": "$redpanda_tiered_storage_account_name", |
| 232 | + "storage_container_name": "$redpanda_tiered_storage_container_name" |
| 233 | + }, |
| 234 | + "user_assigned_identities" : { |
| 235 | + "agent_user_assigned_identity": { "name" : "$agent_user_assigned_identity_name" }, |
| 236 | + "aks_user_assigned_identity": { "name" : "$aks_user_assigned_identity_name" }, |
| 237 | + "cert_manager_assigned_identity": { "name" : "$cert_manager_assigned_identity_name" }, |
| 238 | + "external_dns_assigned_identity": { "name" : "$external_dns_assigned_identity_name" }, |
| 239 | + "redpanda_cluster_assigned_identity": { "name" : "$redpanda_cluster_assigned_identity_name" }, |
| 240 | + "redpanda_console_assigned_identity": { "name" : "$redpanda_console_assigned_identity_name" }, |
| 241 | + "kafka_connect_assigned_identity": { "name" : "$kafka_connect_assigned_identity_name" } |
| 242 | + } |
| 243 | + } |
| 244 | + } |
| 245 | +} |
| 246 | +EOF` |
| 247 | +``` |
| 248 | + |
| 249 | +. Make a Cloud API call to create a Redpanda network and get the network ID from the response in JSON `.operation.metadata.network_id`. |
| 250 | ++ |
| 251 | +``` |
| 252 | +curl -vv -X POST \ |
| 253 | + -H "Content-Type: application/json" \ |
| 254 | + -H "Authorization: Bearer $token" \ |
| 255 | + -d "$cluster_post_body" $PUBLIC_API_ENDPOINT/v1beta2/clusters |
| 256 | +``` |
| 257 | + |
| 258 | +== Deploy the cluster |
| 259 | + |
| 260 | +After getting a Redpanda cluster ID, deploy the cluster with `rpk`, replacing `$rp_id` and `$subscription_id` with your values: |
| 261 | + |
| 262 | +``` |
| 263 | +rpk cloud byoc azure apply --redpanda-id='$rp_id' --subscription-id='$subscription_id' |
| 264 | +``` |
| 265 | + |
| 266 | +== Check cluster status |
| 267 | + |
| 268 | +You can check the cluster status with the Cloud API or the Redpanda Cloud UI. |
| 269 | + |
| 270 | +Example using the returned `operation_id`: |
| 271 | + |
| 272 | +```bash |
| 273 | +curl -X GET "https://api.redpanda.com/v1beta2/operations/<operation_id of operation from previous step>" \ |
| 274 | + -H "accept: application/json"\ |
| 275 | + -H "content-type: application/json" \ |
| 276 | + -H "authorization: Bearer $YOUR_TOKEN" |
| 277 | +``` |
| 278 | + |
| 279 | +Example retrieving cluster: |
| 280 | + |
| 281 | +```bash |
| 282 | +curl -X GET "https://api.redpanda.com/v1beta2/clusters/<resource_id of cluster from previous step>" \ |
| 283 | + -H "accept: application/json"\ |
| 284 | + -H "content-type: application/json" \ |
| 285 | + -H "authorization: Bearer $YOUR_TOKEN" |
| 286 | +``` |
0 commit comments