kubectl rake db:migrate
% kubectl get pods NAME READY STATUS RESTARTS AGE db 1/1 Running 0 6m47s redis 1/1 Running 0 37m sidekiq 1/1 Running 0 37m web 1/1 Running 0 37m
Solution
% kubectl exec web \ -- bash -c \ 'cd /myapp && RAILS_ENV=development bin/rails db:migrate RAILS_ENV=development'
OR
% kubectl exec web bundle exec rails db:migrate
if you need rails webpacker:install on k8s
% kubectl exec web bundle exec rails webpacker:install