Link Search Menu Expand Document
  • shareProcessNamespace로 main container와 chromedriver container간 pid를 공유하도록 만들기
  • main process가 완료되면 sidecar가 죽도록 만들기

pod spec

spec:
    shareProcessNamespace: true
    containers:
    - name: main
      image: :
      command:
      - "./main"
      env:
      - name: CHROME_HOST
          value: localhost:9222
    - name: sidecar-chrome
      image: chromedp/headless-shell:stable
      command:
      - "sh"
      - "-c"
      - |
          /headless-shell/headless-shell --no-sandbox --remote-debugging-address=0.0.0.0 --remote-debugging-port=9222 --disable-dev-shm-usage &
          CHILD_PID=$!
          sleep 5
          (while true; do if pidof main > /dev/null; then echo''; else kill $CHILD_PID; exit 0; fi; sleep 1; done) # main process 눈팅하면서 죽으면 headless-shell 종료
      ports:
      - containerPort: 9222

Back to top

Page last modified: 2022-12-20.

Share on: