Skip to content

Controlling a pod

Commands

Sometimes it might be useful to be able to control a pod directly, e.g. to seed the service database by running scripts.

First, you need the exact name (note that pod names are generated when the pod is created) of the pod you need to run a command on:

$ dev-cli ssh kubectl

$ kubectl get pods

NAME                                    READY   STATUS      RESTARTS   AGE
design-store-654977f677-b27nq           1/1     Running     0          39d

With the pod name in hand, you can run executables on the pod:

kubectl exec design-store-654977f677-b27nq -- php artisan migrate:status

Defaulted container "design-store" out of: design-store, migrations (init)
+------+-------------------------------------------------------+-------+
| Ran? | Migration                                             | Batch |
+------+-------------------------------------------------------+-------+
| Yes  | 2021_08_01_070832_create_authors_table                | 1     |
| Yes  | 2021_09_01_085323_create_designs_table                | 1     |
| Yes  | 2021_10_01_113024_create_themes_table                 | 1     |
| Yes  | 2021_11_05_103014_create_highlights_table             | 1     |
| Yes  | 2021_12_06_064132_add_design_translations_table       | 1     |
| Yes  | 2021_12_08_115231_create_theme_translations_table     | 1     |
| Yes  | 2021_12_09_091649_create_highlight_translations_table | 1     |
| Yes  | 2022_02_23_101211_create_prices_table                 | 1     |
| Yes  | 2022_05_12_093921_rename_theme_translations           | 2     |
+------+-------------------------------------------------------+-------+

If you need to run shell inside the pod, you can run:

  • exec <pod name> -it – /bin/sh the -it flag attaches stdin and stdout to the client's terminal.
  • k9s -> select the kubernetes pod -> Press s on your keyboard to enter shell mode.