Configure Modules

Overview

An app is made up of one or more modules. In this tutorial you will learn how to configure your modules: add containers, change image versions, add variables, and databases.

Click here if you want to learn how to add modules to your app.

Containers

A module is made up of one or more container images. When deployed, all container images in a module will end up in the same Kubernetes Pod. In general, separate services in an app are deployed in separate pods and so should be configured as separate modules. If your app requires multiple containers in a module (e.g. sidecar for logging or monitoring), click here to learn how to add it.

Image

Here you can choose from a list of versions of the container’s image that have been pushed to Humanitec from your CI pipeline. You can choose which image to deploy using the selector. Once you select the image, click Done on module configuration view and click Deploy.

Variables

This section lets you add and remove environment variables that will be made available to the container when it is running. To add Secrets or edit App Default Variables see the Shared App Values & Secrets section instead.

To add an environment variable:

  • enter the variable name the key field,
  • a value in the field to the right, and
  • click Create.

Your changes will be applied once you will deploy your app.

Here, you can also define variable substitutions to dynamically reference values that depend on the environment (e.g., the module’s database name, auto-generated external DNS names, or secrets). A variable substitution consists of a string that you enter in the value of an environment variable in a module’s configuration map. When you deploy your app, Humanitec will replace these strings with the values that they reference.

To add a variable substitution:

  1. In module configuration, enter the name of the variable that your code references in the key field.
  2. Click on the value field to bring up an autocomplete dropdown.

    Screenshot: Variable substitution
    • If you want to create a variable substitution for a database variable, then choose the proper value from externals.
    • If you want to create a variable substitution that will resolve to the name of one of the other modules in your app, choose modules.
    • If you want to reference any of your shared values & secrets, choose values.
  3. Click Create.

Your variable substitution will be created. To apply it, you must redeploy your app.

List of variable substitutions

Database references

Variable substitution name Description
externals.
postgres.name
The name of the database that your module connects to.
externals.
postgres.engine
Database engine used. Will always be POSTGRES.
externals.
postgres.host
The DNS name or IP of the database server.
externals.
postgres.username
Username of the Postgres ROLE that has access to the database defined in name.
externals.
postgres.password
Password of the Postgres ROLE that has access to the database defined in name.
externals.
postgres.port
Port on the server defined by host.

Module references

Variable substitution name Description
module.{MODULE-NAME}.service.name In-cluster DNS name of the module.
modules.{MODULE-NAME}.service.external-name DNS name of the module, which is generated if you expose the module externally.

Container configuration

This section in the module configuration screen allows to define:

  • liveness and readiness probes which are used to determine if the container is still alive and ready to accept requests.
  • the max and min resource requirements for each module. Humanitec’s default values are: min 0.025 and max 0.250 CPU, min 64 MB and max 256 MB Memory.
  • an alternative command to run on container startup.

Screenshot: Container configuration

Container logs

This section shows the logs produced by each of your containers in the module.

Screenshot: Container logs

Add containers

To add additional container images to a module:

  1. Click on a plus icon next to your container in the module configuration view.
  2. Select the container image, give it a name, and click Create.
  3. You will see a new container appear next to your current container. You can configure your containers separately by clicking on their names.

Screenshot: Add containers

Public URL

This section lets you expose your module with a public URL. Check the box and enter the port on which it serves its content. Deploy to apply your changes.

Screenshot: Expose public URL

Other modules can use the module’s DNS name (and in-cluster IP address) as environment variables In the Variables section, enter a variable substitution in the value field with the format: ${modules.MODULE-NAME.service.external-name}. See the variables section for more information.

Databases

Humanitec offers you the option to create databases for each module in a Google Cloud Platform (GCP) cluster managed by Humanitec itself. You can choose from the following types:

  • PostgreSQL
  • MongoDB (coming soon)
  • MySQL (coming soon)

When you add a database for a module, a new database will be created in each environment that this module is deployed into. The connection parameters for the database can be built up (depending on how your container works) using variable substitutions.

For example for a postgres database, the substitutions available are:

  • ${externals.postgres.name}
  • ${externals.postgres.host}
  • ${externals.postgres.port}
  • ${externals.postgres.username}
  • ${externals.postgres.password}

Duplicate module

To duplicate a module with all its configurations:

  1. On the app overview screen, click on the details button in the top right corner of the module you want to duplicate, and then click the Duplicate button.
  2. You will see a new module with a suggested module name which you can change. NOTE: Module name can NOT be changed later. It is required to preserve the deployment history consistency.
  3. Click the checkmark to add the module to your environment and deploy to apply changes.

Screenshot: Duplicate module

Remove module

To remove a module:

  1. On the app overview screen, click on the Details button in the top right corner of the module you want to remove
  2. Click the Remove button. Your module will be removed once you deploy your app.

Screenshot: Remove module