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?
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.