Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it handles replicated services?[Sorry for asking question here] #120

Open
Aniket-Singla opened this issue Oct 10, 2020 · 2 comments
Open

Comments

@Aniket-Singla
Copy link

Hi, I have a replicated service (3 replicas) in my docker swarm orchestration. I wanted to know that whether there is a way to run the cron only at one container out of three in a day? I could not find anything about replicated services in does, so asked here.

@taraspos
Copy link
Collaborator

Hey, Ofelia is not swarm service-aware (even if it can run a new service), it is container aware.
You need to specify the name of the container to run command in.

I'm not sure how docker swarm naming containers, but probably it is has a random part in the name, so you can't really run the job-exec.
However, if your swarm service runs some specific image, for example, my_swarm_image:latest you can use job-run to run a new container from that image and execute a specific commands in there, however, not sure if that would satisfy your requirements.

@Aniket-Singla
Copy link
Author

Aniket-Singla commented Oct 11, 2020

I guess starting a new container from that image wont help because I pass on some environment variables to stack while booting my containers through deploy stack. See below:

version: "3"

services:
  production_app:
    image: {id}.dkr.ecr.ap-south-1.amazonaws.com/image:latest
    expose:
      - 8000
    deploy:
      replicas: 2
    command: >
        sh -c "python manage.py migrate && gunicorn app.wsgi:application --workers 3 --bind 0.0.0.0:8000"
    env_file:
      - .prod.env

  nginx:
    image: {id}.dkr.ecr.ap-south-1.amazonaws.com/nginx:latest
    ports:
      - 80:80

These env vars are crucial for that command to succeed as they contain database creds. I dont know what would be a good way for those environments to be setup by ofelia while starting up the container. (As this env file does not lies with the server, it is on my jenkins server). I dont want to change the way I supply environment variables to my existing service.

Anyways thanks for giving some direction. Feel free to close this issue, if it is out of scope of ofelia(swarm services).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants