Getting Syncthing to work with both containers

I have a deployed pod that has two containers (app and web). The web container has nginx and serves up most of the web site. The app container contains a specialized server the serves up the rest of the website via nginx. Everything works mostly great and I can connect with okteto to do testing. Everything is stored in one repo with a Dockerfile containing both the app and web targets.

But, there is one catch: okteto can sync the local repo folder with the ‘web’ container just fine. So I can change file in the repo and I can see the change in the nginx parts of the web site just fine. But if I change a file for the app side, it is not seen. I have to make changes locally then down/up the okteto so see the difference. This is a pain; and needing to modify both in coordination. A name-changed version of the okteto.yml file:

name: abcd
namespace: bling
dev:
  abcd:
    container: web
    command: nginx-entrypoint
    sync:
      - .:/app
    persistentVolume:
      enabled: false
    forward:
      - 8080:8080
    services:
      - name: abcd
        container: app
        command: entrypoint-prod php-fpm
        sync:
          - .:/app

The question: is it possible to have okteto sync the filesystem with both containers?

Just in case it was relevant, I did try having two copies of the same repo so that okteto could use different local dirs for each container to sync against. But it didn’t seem to help.

Welcome to our community @JohnAD , thanks for posting!

The services key is meant to solve that issue. It seems like you are using it already, but it’s not working as expected.

Few questions to help troubleshoot this:

  1. Can you check that /app is the right location where php expects the files to be at?
  2. Is php-fpm configured to restart on changes?
  3. If you exec into the PHP container, do you see any files on /app? And is the file updated?

If this doesn’t solve the issue, could you run okteto doctor while okteto up is active, so it generates a troubleshooting bundle, and share it with us? (if there’s private information, you can share it with me in a DM).

I’m suspecting the problem is related to:

    persistentVolume:
      enabled: false

The target cluster does not support persistent volumes. And adding those same lines to the service is not permitted by the okteto tool.

You are correct, @JohnAD. When using services, persistentVolume.enabled key needs to be set to true as stated in our documentation.

A possible work around could be having each container under a dev key. With that you could run okteto up for both containers separately, keeping the possibility to work with both simultaneously when you’d need to.
For example, you could run the web container with okteto up web and if you need both running in dev mode execute okteto up app separately.

Hope this helps. Let us know otherwise.

Thanks for helping with this. Unfortunately, I can’t get both of them to run. Running okteto up app in one shell shuts down okteto up web in the other shell; and vice versa.

yaml so far:

name: abcd
namespace: bling
dev:
  web:
    name: abcd
    container: web
    command: nginx-entrypoint
    sync:
      - .:/app
    persistentVolume:
      enabled: false
    forward:
      - 8080:8080
  app:
    name: abcd
    container: app
    command: entrypoint-prod php-fpm
    sync:
      - .:/app
    persistentVolume:
      enabled: false

If there a different format needed to get both containers up in the same pod?

Unfortunately we don’t support running more than one okteto up for the same deployment.
Each one should be on a different deployment to enable running okteto up simultaneously. Sorry if that wasn’t clear from my previous message.

Thanks for helping work this out. While “no” is never an ideal answer for what I want; at least it provides closure :smile:

John