Skip to content

Commit

Permalink
anyway_kubectl exec via docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Jan 25, 2024
1 parent 64d12f8 commit 934ce3f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Pulled August 8, 2021
FROM python:3.8@sha256:caa7d8d6bfaa181f30c5a5074b81b6963246615f0140dca1d86e1e98efa99dc6
RUN wget https://download.docker.com/linux/static/stable/x86_64/docker-25.0.1.tgz &&\
tar xzf docker-25.0.1.tgz &&\
mv docker/docker /usr/local/bin/ &&\
rm -rf docker docker-25.0.1.tgz
RUN pip install --upgrade pip
RUN curl -Lo /usr/local/bin/kubectl "https://dl.k8s.io/release/v1.16.7/bin/linux/amd64/kubectl" &&\
chmod +x /usr/local/bin/kubectl
WORKDIR /srv
COPY requirements.txt ./
RUN pip install -r requirements.txt
Expand Down
6 changes: 4 additions & 2 deletions anyway_etl/anyway_kubectl.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import subprocess

from .config import ANYWAY_KUBECTL_NAMESPACE
from .config import ANYWAY_MAIN_CONTAINER_NAME


def check_call(*args):
subprocess.check_call(['kubectl', '-n', ANYWAY_KUBECTL_NAMESPACE, 'exec', 'deployment/anyway-main', '--', *args])
subprocess.check_call([
'docker', 'exec', ANYWAY_MAIN_CONTAINER_NAME, *args
])
2 changes: 1 addition & 1 deletion anyway_etl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

SQLALCHEMY_URL = os.environ.get('SQLALCHEMY_URL', 'postgresql://anyway:anyway@localhost:9876/anyway')

ANYWAY_KUBECTL_NAMESPACE = os.environ.get('ANYWAY_KUBECTL_NAMESPACE')
ANYWAY_MAIN_CONTAINER_NAME = os.environ.get('ANYWAY_MAIN_CONTAINER_NAME')

0 comments on commit 934ce3f

Please sign in to comment.