VK Cloud logo

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.com subzone, which is delegated to the VK Cloud DNS servers.
  • Resource records for each environment are created and managed only in their own zone.

Preparatory steps

  1. Go to the VK Cloud management console.

  2. Create a DNS zone for the production environment if it has not been created yet.

  3. Install the dig utility on your computer to verify DNS configuration:

    $ sudo apt update && sudo apt install dnsutils

1. Create a subzone

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.

2. Delegate subzone management

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.com zone, 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

3. Configure DNS for the test environment

  1. Create an A record in the test.example.com subzone, 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.
  2. Create a CNAME record in the test.example.com subzone, specifying the parameters:

    • Record type: CNAME.
    • Name: api.
    • Value: the domain of the test services.
    • TTL: leave at the default or configure as needed.
  3. (Optional) Create other resource records in the test.example.com subzone 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.

4. Configure DNS for the production environment

  1. Create an A record in the example.com DNS 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.
  2. Create a CNAME record in the example.com DNS 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.
  3. (Optional) Create other resource records in the example.com DNS 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.

  4. Delete the resource records for the test environment from the example.com zone, 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

5. Verify the DNS settings

  1. Verify name resolution for the test environment:

    $ dig app.test.example.com +short

    The response will return the IP address you configured in the test.example.com subzone. In this example: 192.168.1.10.

  2. Verify name resolution for the production environment:

    $ dig app.example.com +short

    The response will return the IP address you configured in the example.com DNS zone. In this example: 83.166.234.101.

  3. Verify the subzone delegation:

    $ dig NS test.example.com +short

    The response will return the addresses of the NS servers for the example.com zone, which can be viewed in the list of resource records. In this example: ns1.mcs.mail.ru and ns2.mcs.mail.ru.

Delete unused resources

If the created resources are no longer needed, delete them:

  1. Delete the test.example.com subzone.
  2. Delete the unneeded NS records in the example.com DNS zone.
Was this article helpful?