Reconfiguring a network connection when recreating a Yandex Data Processing cluster
You may need to recreate a cluster to install software updates, transfer the load across clusters, move clusters from one availability zone to another, or perform other operations.
This tutorial describes how to set up DNS to quickly switch network traffic over to new host FQDNs when recreating a Yandex Data Processing cluster. For the current name of the cluster master host, a network alias (CNAME record) is created in Yandex Cloud DNS. When you recreate the cluster, the CNAME record changes to the master host's new name.
To set up DNS for your Yandex Data Processing cluster:
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can create or select a folder for your infrastructure on the cloud page
Learn more about clouds and folders here.
Required paid resources
- Yandex Data Processing cluster: use of computing resources with a Yandex Data Processing markup, use of network drives, retrieval and storage of logs, amount of outgoing traffic (see Yandex Data Processing pricing).
- Public IP addresses if public access is enabled for cluster hosts (see Yandex Virtual Private Cloud pricing).
- NAT gateway: hourly use of the gateway and its outgoing traffic (see Virtual Private Cloud pricing).
- Yandex Object Storage bucket: use of storage, data operations (see Object Storage pricing).
Set up your infrastructure
-
Create a network named
data-proc-networkwith the Create subnets option disabled. -
In
data-proc-network, create a subnet with the following settings:- Name:
data-proc-subnet-a - Availability zone:
ru-central1-a - CIDR:
192.168.1.0/24
- Name:
-
Create a NAT gateway and a route table named
data-proc-route-tableindata-proc-network. Associate the table withdata-proc-subnet-a. -
In
data-proc-network, create a security group nameddata-proc-security-groupwith the following rules:-
One rule for incoming and another one for outgoing service traffic:
- Port range:
0-65535 - Protocol:
Any - Source/Destination name:
Security group - Security group:
Current
- Port range:
-
Rule for outgoing HTTPS traffic:
- Port range:
443 - Protocol:
TCP - Destination name:
Address range - IPv4 CIDR:
0.0.0.0/0
- Port range:
-
-
Create a service account named
data-proc-sawith the following roles: -
Create a Yandex Object Storage bucket with restricted access.
-
Create a Yandex Data Processing cluster in any suitable configuration with the following settings:
- Environment:
PRODUCTION. - Service account:
data-proc-sa. - Bucket ID format:
List. - Bucket name: Select the bucket you created earlier.
- Network:
data-proc-network. - Security groups:
data-proc-security-group.
- Environment:
-
If you do not have Terraform yet, set up and configure it.
-
Download the file with provider settings
. Place it in a separate working directory and specify the parameter values. -
Download the data-proc-dns-connect.tf
configuration file to the same working directory.This file describes:
- Network.
- Subnet.
- DNS zone and CNAME record for the cluster master host.
- NAT gateway and route table.
- Security groups.
- Service account for operations with cloud resources.
- Service account for bucket management.
- Static access key required to grant the service account permissions for the bucket.
- Bucket to store job dependencies and results.
- Yandex Data Processing cluster.
-
In the
data-proc-dns-connect.tffile, specify the following variables:folder_id: Folder ID.path_to_ssh_public_key: Path to the public SSH key.os_sa_name: Name of the service account for bucket management.bucket: Bucket name.
-
Run the
terraform initcommand in the working directory with the configuration files. This command initializes the provider specified in the configuration files and enables you to use its resources and data sources. -
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console
. -
Create a DNS zone and CNAME record
Create the resources:
-
Create an internal DNS zone with the following settings:
- Zone:
data-proc-test-user.org.. - Networks: Select
data-proc-network. - Name:
dp-private-zone.
- Zone:
-
Create a DNS record of the CNAME type with the following settings:
- Name:
data-proc-test-user.org.. - Data: FQDN of the Yandex Data Processing cluster master host.
- Name:
-
Get the FQDN of the Yandex Data Processing cluster master host.
-
In the
data-proc-dns-connect.tffile, specify this variable:dataproc_fqdn: FQDN of the Yandex Data Processing cluster master host.
-
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create the required infrastructure:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Test network access to the cluster by the CNAME record:
dig data-proc-test-user.org.
<...>
;; ANSWER SECTION:
data-proc-test-user.org. 600 IN CNAME rc1a-dataproc-m-6ijqng07vul2mu8j.mdb.yandexcloud.net.
rc1a-dataproc-m-6ijqng07vul2mu8j.mdb.yandexcloud.net. 600 IN A 192.168.1.8
Delete the cluster and recreate it
- Delete the Yandex Data Processing cluster and create a new one with identical settings.
- Change the DNS record you created earlier and specify the FQDN of the master host of the new cluster in the Data parameter.
-
Delete the
yandex_dataproc_clustersection indata-proc-dns-connect.tf. -
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Apply the changes:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
-
Add the
yandex_dataproc_clustersection todata-proc-dns-connect.tf, with the same contents as in the source file, to create a new Yandex Data Processing cluster. -
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Create a cluster:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
-
Get the FQDN of the master host of the new Yandex Data Processing cluster.
-
In the
data-proc-dns-connect.tffile, specify this variable:dataproc_fqdn: FQDN of the cluster master host.
-
Make sure the Terraform configuration files are correct using this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
Apply the changes:
-
Run this command to view the planned changes:
terraform planIf you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
-
If everything looks correct, apply the changes:
-
Run this command:
terraform apply -
Confirm updating the resources.
-
Wait for the operation to complete.
-
-
Make sure you still have network access to the cluster by the CNAME record:
dig data-proc-test-user.org.
<...>
;; ANSWER SECTION:
data-proc-test-user.org. 600 IN CNAME rc1a-dataproc-m-lsqohjh53rfu659d.mdb.yandexcloud.net.
rc1a-dataproc-m-8kompl81232cdsu8j.mdb.yandexcloud.net. 600 IN A 192.168.1.8
Delete the resources you created
Some resources are not free of charge. Delete the resources you no longer need to avoid paying for them:
- Delete the Yandex Data Processing cluster.
- If you reserved public static IP addresses, release and delete them.
- Delete the Object Storage bucket. Before deleting the bucket, delete all its objects.
- Delete the subnet.
- Delete the route table.
- Delete the NAT gateway.
- Delete the network.
- Delete the DNS zone.
-
In the terminal window, go to the directory containing the infrastructure plan.
Warning
Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.
-
Delete resources:
-
Run this command:
terraform destroy -
Confirm deleting the resources and wait for the operation to complete.
All the resources described in the Terraform manifests will be deleted.
-