From 8f8d4420b09f45845aa7626d68e873947d6daa96 Mon Sep 17 00:00:00 2001 From: Peter Luladjiev Date: Wed, 25 Mar 2026 15:46:58 +0200 Subject: [PATCH 1/4] Revert "Update Docker Compose integration to use v2 CLI and get container name" --- .github/workflows/run_tests.yml | 8 ++++++-- CHANGELOG.md | 4 ---- kubetools/__init__.py | 4 ++-- kubetools/config.py | 2 +- kubetools/dev/backends/docker_compose/config.py | 5 +++-- kubetools/dev/backends/docker_compose/docker_util.py | 9 ++++++--- setup.py | 3 +++ 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 68cd4139..f58cc3ea 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,8 +6,12 @@ jobs: tests: strategy: matrix: - os: [ubuntu-22.04, ubuntu-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + os: [ubuntu-20.04, ubuntu-latest] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + exclude: + # Python 3.6 is not available in GitHub Actions Ubuntu 22.04 + - os: ubuntu-latest + python-version: '3.6' runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 45eb9389..a3f233e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,6 @@ ### Unreleased -# v14.0.0 -- Support Docker compose v2 -- Drop Python 3.7 support - # v13.14.2 - Collect additional parameters provided to kubetools cronjob spec and attach to k8s cronjob spec diff --git a/kubetools/__init__.py b/kubetools/__init__.py index 602b6aa3..ae44ff19 100644 --- a/kubetools/__init__.py +++ b/kubetools/__init__.py @@ -1,3 +1,3 @@ -from importlib import metadata +from pkg_resources import get_distribution -__version__ = metadata.version("kubetools") +__version__ = get_distribution('kubetools').version diff --git a/kubetools/config.py b/kubetools/config.py index 5440acf6..943e6546 100644 --- a/kubetools/config.py +++ b/kubetools/config.py @@ -7,7 +7,7 @@ import yaml -from packaging.version import parse as parse_version +from pkg_resources import parse_version from . import __version__ from .exceptions import KubeConfigError diff --git a/kubetools/dev/backends/docker_compose/config.py b/kubetools/dev/backends/docker_compose/config.py index c7e08d06..4c1498d1 100644 --- a/kubetools/dev/backends/docker_compose/config.py +++ b/kubetools/dev/backends/docker_compose/config.py @@ -248,8 +248,9 @@ def create_compose_config(kubetools_config): if dev_network: compose_config['networks'] = { 'default': { - 'name': 'dev', - 'external': True, + 'external': { + 'name': 'dev', + }, }, } diff --git a/kubetools/dev/backends/docker_compose/docker_util.py b/kubetools/dev/backends/docker_compose/docker_util.py index 6c95151c..42caf912 100644 --- a/kubetools/dev/backends/docker_compose/docker_util.py +++ b/kubetools/dev/backends/docker_compose/docker_util.py @@ -1,3 +1,5 @@ +import sys + from functools import lru_cache import docker @@ -136,8 +138,8 @@ def get_containers_status( if not env: env = compose_project.replace(docker_name, '') - # Get the service name from the Docker Compose label (works with both v1 and v2) - name = container.labels['com.docker.compose.service'] + # Where the name is compose-name_container_N, get container + name = container.name.split('_')[1] status = container.status == 'running' ports = [] @@ -202,7 +204,8 @@ def run_compose_process(kubetools_config, command_args, **kwargs): create_compose_config(kubetools_config) compose_command = [ - 'docker', 'compose', + # Use current interpreter to run the docker-compose module installed in the same venv + sys.executable, '-m', 'compose', # Force us to look at the current directory, not relative to the compose # filename (ie .kubetools/compose-name.yml). '--project-directory', '.', diff --git a/setup.py b/setup.py index 6e73b88c..ca02058a 100644 --- a/setup.py +++ b/setup.py @@ -55,9 +55,12 @@ def get_readme_content(): 'pyyaml>=3,<6', 'requests>=2,<2.29.0', # https://github.com/docker/docker-py/issues/3113 'pyretry', + 'setuptools', # To support CronJob api versions 'batch/v1beta1' & 'batch/v1' 'kubernetes>=21.7.0,<25.0.0', 'tabulate<1', + # compose v2 has broken container naming + 'docker-compose<2', ), extras_require={ 'dev': ( From 673f5b6a7f7207897c92772bd17fc878f116b829 Mon Sep 17 00:00:00 2001 From: Peter Luladjiev Date: Wed, 25 Mar 2026 16:24:13 +0200 Subject: [PATCH 2/4] Exclude python 3.7 from tests workflow --- .github/workflows/run_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index f58cc3ea..01690fd3 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -12,6 +12,9 @@ jobs: # Python 3.6 is not available in GitHub Actions Ubuntu 22.04 - os: ubuntu-latest python-version: '3.6' + # Python 3.7 is not available in GitHub Actions Ubuntu 22.04 + - os: ubuntu-latest + python-version: '3.7' runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 From ecf27ef0c192ddf3e298bc3b19e6530feb3f2373 Mon Sep 17 00:00:00 2001 From: Peter Luladjiev Date: Tue, 31 Mar 2026 14:40:24 +0300 Subject: [PATCH 3/4] Replace pkg_resources with importlib.metadata and packaging.version --- kubetools/__init__.py | 4 ++-- kubetools/config.py | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kubetools/__init__.py b/kubetools/__init__.py index ae44ff19..172f5055 100644 --- a/kubetools/__init__.py +++ b/kubetools/__init__.py @@ -1,3 +1,3 @@ -from pkg_resources import get_distribution +from importlib import metadata -__version__ = get_distribution('kubetools').version +__version__ = metadata.version('kubetools') diff --git a/kubetools/config.py b/kubetools/config.py index 943e6546..5440acf6 100644 --- a/kubetools/config.py +++ b/kubetools/config.py @@ -7,7 +7,7 @@ import yaml -from pkg_resources import parse_version +from packaging.version import parse as parse_version from . import __version__ from .exceptions import KubeConfigError diff --git a/setup.py b/setup.py index ca02058a..14cab4ec 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ def get_readme_content(): 'pyyaml>=3,<6', 'requests>=2,<2.29.0', # https://github.com/docker/docker-py/issues/3113 'pyretry', - 'setuptools', + 'packaging', # To support CronJob api versions 'batch/v1beta1' & 'batch/v1' 'kubernetes>=21.7.0,<25.0.0', 'tabulate<1', From 6c3e00f38cbc0307d81f3418be0c8e974ea8bd10 Mon Sep 17 00:00:00 2001 From: Peter Luladjiev Date: Tue, 31 Mar 2026 15:31:46 +0300 Subject: [PATCH 4/4] Remove ubuntu-22 from workflow --- .github/workflows/run_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 01690fd3..ac0d0e02 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,7 +6,7 @@ jobs: tests: strategy: matrix: - os: [ubuntu-20.04, ubuntu-latest] + os: [ubuntu-latest] python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] exclude: # Python 3.6 is not available in GitHub Actions Ubuntu 22.04