ketch.yaml

The ketch.yaml is a special file that you can use when deploying applications.

You can use the file to describe certain aspects of the application being deployed. The file describes information about deployment hooks and application processes being created in the Kubernetes cluster.

Deployment Hooks

Ketch provides different deployment hook options, such as restart:before and restart:after. Deployment hooks allow you to run commands during different stages of the application deployment.

Below is an example of how to declare hooks in the ketch.yaml file:

hooks:
  restart:
    before:
      - python -c 'import datetime; print("before " + str(datetime.datetime.now()))'
    after:
      - python -c 'import datetime; print("after " + str(datetime.datetime.now()))'

Currently, you can use the ketch.yaml file with the following hooks:

  • restart:before: executes commands before the unit is restarted. Commands listed in this hook run once per unit. For instance, if there is an application with two units and the ketch.yaml file listed above, the command python manage.py local_file would run two times, once per unit.
  • restart:after: works like before-each, but runs after restarting a unit.

Kubernetes Processes

When running your application on a Ketch provisioned pool, you can set specific configurations for Kubernetes.

You can configure which ports are exposed to each process of the application. Here is a complete example:

kubernetes:
  processes:
    web:
      ports:
        - name: apache-http # an optional name for the port
          protocol: TCP 
          port: 80 # The port that is going to be exposed on the router.
          target_port: 9999 # The port on which the application listens on.
    worker:
      ports:
        - name: http 
          protocol: TCP
          port: 80
    worker-2:
      ports: []

Each exposed port can be configured for each process using the port's key:

  • kubernetes:processes::ports:name: is a descriptive name for the port. This field is optional.
  • kubernetes:processes::ports:protocol: defines the port protocol. The accepted values are TCP (default) and UDP.
  • kubernetes:processes::ports:target_port: is the port that the process is listening on. If omitted, the port value is used.
  • kubernetes:processes::ports:port: is the port that will be exposed on a Kubernetes service. If omitted, the target_port value is used.

If both port and target_port are omitted in a port config, the deployment fails.

Developers can set a process to expose no ports with an empty field, like the worker above.