Can Kubernetes Jobs can have args applied like Docker?

6/28/2021

I know that I can override args when I docker run myimage arg1

Is there something like

kubectl apply -f myDeployment.yml arg1

My goal is to create a Kubernetes Job to create my database and fill it with content, when I initiate my App the first time:

rails-command.yml

apiVersion: batch/v1
kind: Job
metadata:
  name: rails-command
  creationTimestamp: null
  labels:
    io.kompose.service: api
spec:
  template:
    spec:
      containers:
        - name: rails-command-app
          image: myApp:latest
          imagePullPolicy: Always
          command: ['bundle', 'exec', 'rails']
          args: 
            - 'db:migrate'

Do I have to duplicate my Job to use db:create, db:rollback instead of db:migrate? or can I apply that file with something like this:

kubectl apply -f rails-command.yml db:rollback
kubectl apply -f rails-command.yml db:create
-- Jan
kubernetes

0 Answers