best practice to run db:create with kubernetes and minikube

6/21/2019

I am new to kubernetes and I am trying to setup a rails application using minikube.

I wanted to know whats the best practice to run setup tasks like rake db:create which we execute only once during the application setup.

I currently did it by executing

kubectl exec pod_name rake db:create

would this be a good practice to setup the database for the first time or is there a better or standard way to this?

-- opensource-developer
kubernetes
minikube

1 Answer

7/2/2019

You might be able to achieve the same result, by propagating command: field in the source manifest file, i.e:

apiVersion: v1
kind: Pod
metadata:
  name: ruby
spec:
  containers:
  - name: ruby
    image: ruby:2.5
    command: [ "/bin/bash", "-c", "rake db:create" ]

Reach out more information in the official k8s documentation, some hints explained here.

-- mk_sta
Source: StackOverflow