4

Currently I have a setup on AWS with 4 EC2 machines. They provide a web interface that among other things also has a database search. My recent project was to move the database search to AWS Elastic Search. That took a while but in the end it was fine, because to create the initial index I simply had to SSH into one of the machines, run the command to create the index and I was done.

I could not have done it without SSH'ing into it because the production environment (meaning DB and ES instances) is not directly accessible from dev PCs (which makes sense to me).

So, being quite new to Kubernetes my question is: if we were to migrate these EC2 instances and switch to a Kubernetes kind of setup, how would I run the initial command to create the ES index?

I know I can connect to a pod when it's a single container but these would most likely have containers at least for nginx, redis and django (the one I'd want to connect).

1 Answer 1

10

A little more information is needed about specific operations you are doing, but generally your options are:

  1. For one-time operations: use kubectl exec to get into containers and do commands (works similar to docker exec).

  2. Also for one-time operations, spawn separate pods with shell access to interact with existing pods, something along the lines:

kubectl run -it --rm --restart=Never --image busybox tempbusybox -- sh
  1. For reproducible (not one-time) operations, you may use kubernetes jobs.

  2. In some cases you may use init containers for setup tasks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.