Links

Work with Files

Learn how to manage configuration files for Containers in Humanitec

What are Files?

Files are injected into the file-system of the Container at Runtime. They are normally used to provide configuration files for processes that cannot be configured via Environment Variables.
Files differ from Volumes in that they cover specific files rather than directories. Files are also reset on every deployment. You should use Files for things related to configuration that might need to be changed by developers. You should use Volumes for things related to data that the app creates or consumes.
On deployment, Humanitec collects Files defined for containers in a Workload into either a ConfigMap or Secret Kubernetes object. They are then inserted into a to containers's file-system via a projected volume.

Path and Permission Mode

Files are inserted into the Container's file-system at a particular Path and with a particular Permission Mode.
The path must be an absolute path to a file. This means it must start with / and cannot end with /. It must be a valid Unix style file path.
The Permission Mode defines the permission bits on the file in the file-system. Unix like systems (including Linux) define 3 possible sets of permissions for a file:
  • Permissions for the owner of the file
  • Permissions for the group that owns the file
  • Permissions for all users on the system
Each of these permissions can be any combination of Read, Write or Execute. The block of permissions is traditionally written as 3 Octal digits with each digit representing 3 bits for Read, Write and Execute for each of the permissions. You can use tools like chmod-calculator.com to help you calculate the Octal mode for a file. Humanitec defaults to 0777 which allows read, write and execute on all files.

Using Placeholders

Sometimes the value of some configuration will change depending on the Environment that a workload is deployed into. For example, you may want your workload to connect to a different database in a development than in a production environment. To allow for this, Humanitec provides placeholders that can be inserted into the variable values.
Placeholders are of the form ${...} where the content is a placeholder path. Any number of placeholders can be included in the value of a variable. For example:
Hello ${values.PLACEHOLDER_EXAMPLE}!
Will resolve the shared value PLACEHOLDER_EXAMPLE at deployment time and insert the value into the string above.
Find out more about placeholders you can use inUsage

Secrets

Sometimes a file contains a sensitive value that should not be visible to other developers. An example of this would be database credentials. Secrets should be stored as shared Values and Secrets and then referenced in a file using a placeholder. If the content of a placeholder is a secret, Humanitec will automatically convert the entire value into a secret.

Add a File

UI
CLI
API
  1. 1.
    Enter the Workload Details screen for the Workload you want to work on.
  2. 2.
    Ensure you are in Draft mode. If you are not, you can select it from the Deployment drop-down.
  3. 3.
    Choose the container in the workload you want to update.
  4. 4.
    Click + Add files to create the file.
Our CLI is currently in closed beta. Please contact us if you want to learn more.
Adding Files involves adding a property to the files section of the container object in the spec section of a module in a Deployment Set. See Deployment Deltas in the API Documentation for more details of how this can be done.

Working with the File Editor

UI
CLI
API
  1. 1.
    Enter the full path of where the file should be located in the Container's file-system.
  2. 2.
    Enter the mode for the file as an octal number. The most permissive permissions is 0777.
  3. 3.
    To help with editing, you can select a syntax highlighting scheme.
  4. 4.
    Enter the content of the file in the main area.
  5. 5.
    Click Save to save your changes.
  6. 6.
    Click Cancel to discard your changes.
  7. 7.
    You can toggle the highlighting of whitespace characters on and off.
Working with the Editor.
Our CLI is currently in closed beta. Please contact us if you want to learn more.
There is no editor in the API.