DNS Hostnames for Direct Connection to Containers

Being able to easily connect to Cloud services is a criteria of great importance for all of the developers. In Apiqcloud, each newly created node is assigned a number of automatically generated hostnames, pointed to the appropriate server internal/external IP address.

Depending on a type of the created node, the set of hostnames for it could differ. Thus, below we’ll consider the possible ways to refer to a particular node, hosted at Apiqcloud Cloud, either from inside (i.e. when managing it via Apiqcloud SSH Gate) or outside of the Cloud:

  • Hostnames for Specific Containers
  • Supplementary Hostnames for Particular Node Types
  • Hostnames for Specific Layers
  • Short Hostnames for Containers within One Environment
  • Hostnames for Linked Containers

Each container at the platform can be accessed by its internal IP address with an URL of one of the following formats:

  • node${nodeId}-${envName}.${platformDomain}
  • node${nodeId}.${envName}.${platformDomain}

Herewith, the placeholders should be replaced with the next values:

  • ${nodeId} - an automatically generated unique digit identifier, assigned to every container within a Platform

  • ${envName} - environment name (not an alias), specified during its creation
  • ${platformDomain} - domain name of a Apiqcloud installation hosting service provider

Both variants can be used for refering to the nodes from inside or outside of the platform (i.e. allowing to establish both internal and external connections).

Some of Apiqcloud certified stacks are provisioned with additional hostname prefixes (i.e. where the appropriate stack name is used instead of the node string) to make their management more convenient.

Note: Such supplementary prefixes are valid only within domains with a hyphen as a separator.
Node Type Stack Additional Hostname
Custom Docker Сontainers docker${nodeId}-${envName}.${platformDomain}
Database Cassandra 1/2 cassandra${nodeId}-${envName}.${platformDomain}
CouchDB couchdb${nodeId}-${envName}.${platformDomain}
MariaDB 5/10 mariadb${nodeId}-${envName}.${platformDomain}
Memcached memcached${nodeId}-${envName}.${platformDomain}
MongoDB 2/3 mongodb${nodeId}-${envName}.${platformDomain}
MSSQL mssql${nodeId}-${envName}.${platformDomain}
MySQL 5.6/5.7 mysql${nodeId}-${envName}.${platformDomain}
Neo4j 1/2 neo4j${nodeId}-${envName}.${platformDomain}
OrientDB orientdb${nodeId}-${envName}.${platformDomain}
PostgreSQL 8/9 postgres${nodeId}-${envName}.${platformDomain}
Redis redis${nodeId}-${envName}.${platformDomain}
VPS vps${nodeId}-${envName}.${platformDomain}

All alternative domain strings, shown in the table above, can be utilized similarly to the hostnames for specific containers.

For the new environments, you can get all internal IP addresses of containers within one node layer using the following hostname:

  • ${nodeGroup}.${envName}.${platformDomain}

Here, ${nodeGroup} placeholder is a name of a particular layer the required container belongs to. By default, layers are named in accordance with the appropriate nodeGroup specific role.

Note: Node groups added via the extra layers in the topology wizard are named in the same way, but with the appropriate ${N} index. Herewith, the default layers in topology wizard (e.g. blcpsqldb, etc.) are considered as the first index, so the enumeration in extra layers starts with the second one, e.g. cp2cp3cp4, … (except of the extraextra2extra3, …). For example:

For example, this command can be used to get an application servers list for any environment within the platform:

Tip: In order to get a list of containers for the current environment, just a short hostname can be used.

Herewith, every time a new container is created (removed) in a system, the appropriate record is automatically added to (removed from) DNS for the layer hostname.

All the newly created Docker containers and dockerized Apiqcloud-managed stacks are provisioned with the specific DNS rules, which allow usage of the additional simplified hostnames:

  • node${nodeId} - alias to refer to a container in confines of a single environment
  • ${nodeGroup} - alias to refer to a layer in confines of a single environment

Utilizing such short hostnames in server configuration files, application source code and SSH console (within often used commands like pinghostdig, etc) makes operating with Dockerized stacks via Platform internal network much more convenient. Additionally, such approach enables painless environment migration to another hardware region through eliminating the necessity to adjust your application code due to the changed server location.

Upon linking two Docker-based environment layers, a set of dedicated DNS records are automatically added to the global Apiqcloud database. This allows to refer to the nodes within a target layer from the source ones (but not vice versa) when working in confines of these two layers using the following hostname aliases:

  • ${linkAlias} - to refer to a random node within a target layer; an exact node to respond is chosen by means of the Round-Robin algorithm - this ensures even load distribution
  • ${linkAlias}_${N} - to access a particular container within a target layer

Here, the appropriate placeholders are to be substituted with:

  • ${linkAlias} - link name you’ve specified during its setting (e.g. tomcat in the image below)${N} - nominal index number (in a 1…N range) of a particular container within the target linking layer (e.g. tomcat_1tomcat_2), etc; herewith, master container is always considered the 1st instance, whilst the rest of layer nodes are assigned numbers according to their nodeID values, being sorted in ascending order (starting with the _2 index, then _3_4, etc.)

For example, if there are three containers on a layer - with the 123124 (master) and 125 IDs. According to the above-described implementation, the aliases will be assigned as follows:

  • alias_1 - link to the 124 container as a master node
  • alias_2 - will point to the 123 instance since it has the lowest ID among the remaining containers
  • alias_3 - for referring to the 125 container as the one with the next lowest nodeID
Tip: By appending an environment domain to the alias ${linkAlias}.${envName}.${platformDomain}, the corresponding linked layer name can be resolved and accessed externally, i.e. from anywhere over the Internet. And by ${linkAlias}_${N} corresponding container of a linked layer can be resolved internally only, within the linked layers network.

Now, you know all the specifics and shortcuts that can be used to refer to your nodes, which will help to quickly and efficiently organize connections between your application instances.

  • DNS Hostnames for Direct Connection to Containers in apiqcloud
  • 0 Utilizadores acharam útil
Esta resposta foi útil?

Artigos Relacionados

Container Redeploy

Update Container via Dashboard The most straightforward and user-friendly way to redeploy a...

Multiple Public IP Addresses for a Single Container

Multiple Public IP Addresses for a Single Container Apiqcloud PaaS supports assigning multiple...

Setup WordPress Multisite Network with Domain Mapping and CDN

While running several websites, it can be more useful to go with WordPress multisite network than...

How to Bind Custom Domain via CNAME

In order to bind custom domain name to such environment, a special CNAME (canonical name)...

How to Bind Custom Domain via A Record

  The majority of applications in production use an External IP address as more secure and...