Manage DNS
Learn how to add and manage DNS in Humanitec.

Introduction

DNS names provide a standard way to make services accessible on the public internet. In Kubernetes applications, DNS names are most often used with Ingress objects to map incoming requests to an external Load Balancer to workloads running inside the cluster.
In Humanitec, a DNS name is represented as a Resource of type dns.
By default, Humanitec will automatically generate dynamic DNS name under the .newapp.io domain along with a valid SSL certificate. However, it is possible to configure different DNS names that will get picked up in different environments.

DNS

A Resource Definition can be used to define how new DNS names should be generated. In most cases, this involves creating a subdomain to an existing domain. Humanitec provides 2 drivers which can be used to dynamically generate DNS names as required on existing domains:
This driver assumes that a wildcard record exists in the appropriate zone file resolving all DNS requests on any subdomain to be directed to the cluster Load Balancer. The driver will generate new unique subdomains and requires a static wildcard TLS certificate.
By definition, this driver can only be used for environments in a single cluster.
This driver adds records to a Cloudflare Zonefile pointing at the Load Balancer for the relevant cluster. The driver will generate new unique subdomains and requires a static wildcard TLS certificate.
This driver can be used with environments running on different clusters.

Add Resource Definition

  • Start on the Resources Management screen and click on the Show all resources button. An overlay with all available resource categories and types will be presented to you.
  • Below Routing select DNS.
  • Choose an ID that you will use to identify the resource definition in Humanitec later.
  • Select a driver. Based on your resource driver, a form will be down with the required driver parameters which will be passed to the driver on every resource creation.
  • Fill out the connection parameters that Humanitec and click on Create.

Static DNS

The static driver type can be used to define static DNS names to be used for ingress.
As each workload that needs to be exposed requires a different DNS name the resource matching criteria used must exactly match the relevant workload.
Here is an example of the API call to create a Static Resource Definition where a workload called frontend-service in the production environment of the topic-share app will be exposed with the DNS name app.topicshare.com:
1
curl --request POST \
2
--header "Authorization: Bearer $HUMANITEC_TOKEN" \
3
--header "Content-Type: application/json" \
4
--data '{
5
"id": "fe-dns-name",
6
"type": "dns",
7
"driver_type": "humanitec/static",
8
"driver_inputs": {
9
"values": {
10
"host": "app.topicshare.com",
11
"tls_cn": "*.topicshare.com"
12
},
13
"secrets": {
14
"tls": {
15
"tls.crt": "...",
16
"tls.key": "..."
17
}
18
}
19
},
20
"criteria": [
21
{
22
"app_id": "topic-share",
23
"env_id": "production",
24
"res_id": "workloads.frontend-service"
25
}
26
]
27
}' \
28
https://api.humanitec.com/orgs/topicshare/resources/defs
Copied!
Where $HUMANITEC_TOKEN is an appropriate authentication token.
Last modified 1mo ago