Creating a Kubernetes job

Our elixir-drip-migrations job configuration file will be really similar to the previous Deployment configuration, but instead of running the container default command (that is, sh -c bin/$APP_NAME foreground set on Dockerfile.deploy), we override the command that will be run when the application container starts (that is, sh -c bin/$APP_NAME migrate_up). We also tell Kubernetes to never restart jobs like these, and that it should terminate the job after 300 seconds, no matter what:

$ cat deploy/elixir-drip-migrations-prod.yml apiVersion: batch/v1kind: Jobmetadata:  generateName: elixir-drip-migrations  namespace: production  labels:    env: productionspec:  activeDeadlineSeconds: 300  template:    metadata:      labels: env: production ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.