Separating test and production environments
Using DNS configuration, you can separate test and production environments, which improves infrastructure stability and simplifies management. The example below shows how to isolate the test environment into a separate DNS subzone:
- The production environment remains in the main DNS zone
example.com. - The test environment is hosted in the
test.example.comsubzone, which is delegated to the VK Cloud DNS servers. - Resource records for each environment are created and managed only in their own zone.
-
Go to the VK Cloud management console.
-
Create a DNS zone for the production environment if it has not been created yet.
-
Install the
digutility on your computer to verify DNS configuration:Ubuntu, DebianRed Hat, CentOS, FedoramacOSWindows$ sudo apt update && sudo apt install dnsutils
Create a subzone for the test environment, specifying the parameters:
- Project: the project hosting the DNS zone of the production environment.
- DNS zone:
test.example.com. - Contact email: the zone administrator's email.
Leave the other parameters at their defaults or configure them as needed.
Create NS records in the example.com DNS zone, specifying the parameters:
- Record type:
NS. - Name:
test. - Value: the addresses of the NS servers for the
example.comzone, which can be viewed in the list of resource records. In this example:ns1.mcs.mail.ru— for the first record,ns2.mcs.mail.ru— for the second record.
Example of resource records in the example.com DNS zone after delegating subzone management:
test NS ns1.mcs.mail.rutest NS ns2.mcs.mail.ru
-
Create an A record in the
test.example.comsubzone, specifying the parameters:- Record type:
A. - Name:
app. - IP address: the IP address of the test server.
- TTL: leave at the default or configure as needed.
- Record type:
-
Create a CNAME record in the
test.example.comsubzone, specifying the parameters:- Record type:
CNAME. - Name:
api. - Value: the domain of the test services.
- TTL: leave at the default or configure as needed.
- Record type:
-
(Optional) Create other resource records in the
test.example.comsubzone that will be needed for the test environment. For example, MX and TXT records can be used to define test mail servers and their settings.
Example of resource records in the test.example.com subzone after configuring DNS for the test environment:
app A 192.168.1.10api CNAME app.test.example.com
The example uses a private IP address. If your server is accessible from the internet, use a public IP.
-
Create an A record in the
example.comDNS zone, specifying the parameters:- Record type:
A. - Name:
app. - IP address: the IP address of the production server.
- TTL: leave at the default or configure as needed.
- Record type:
-
Create a CNAME record in the
example.comDNS zone, specifying the parameters:- Record type:
CNAME. - Name:
api. - Value: the domain of the production services.
- TTL: leave at the default or configure as needed.
- Record type:
-
(Optional) Create other resource records in the
example.comDNS zone that will be needed for the production environment. For example, MX and TXT records can be used to define mail servers and their settings. -
Delete the resource records for the test environment from the
example.comzone, if any exist there.
Example of resource records in the example.com DNS zone after configuring DNS for the production environment:
app A 83.166.234.101api CNAME app.example.com
-
Verify name resolution for the test environment:
dignslookup$ dig app.test.example.com +shortThe response will return the IP address you configured in the
test.example.comsubzone. In this example:192.168.1.10. -
Verify name resolution for the production environment:
dignslookup$ dig app.example.com +shortThe response will return the IP address you configured in the
example.comDNS zone. In this example:83.166.234.101. -
Verify the subzone delegation:
dignslookup$ dig NS test.example.com +shortThe response will return the addresses of the NS servers for the
example.comzone, which can be viewed in the list of resource records. In this example:ns1.mcs.mail.ruandns2.mcs.mail.ru.
If the created resources are no longer needed, delete them: