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

[BUG] modules.kubernetes is broken due to use of deprecated API version #62621

Open
eliasp opened this issue Sep 5, 2022 · 0 comments
Open
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue Deprecation k8s-modules needs-triage

Comments

@eliasp
Copy link
Contributor

eliasp commented Sep 5, 2022

Description
Using an up-to-date version of the Kubernetes Python API bindings (v24.2.0 as of now) breaks modules.kubernetes, as it uses an API which was deprecated 3 years ago in Kubernetes v1.16 and announced to be deprecated in v1.9.

Setup

  • Ubuntu 22.04 LTS
  • Salt-Minion installed (classic package from APT repos)
  • Kubernetes cluster accessible through parameters provided in kubeconfig file
  • Kubernetes Python API bindings 24.2.0 installed via pip

Steps to Reproduce the behavior

  • Execute salt-call state.single pip.installed name='kubernetes>=24.2.0'
  • Execute salt-call kubernetes.nodes context=default kubeconfig=/path/to/kubeconfig

Expected behavior
Provide full modules.kubernetes functionality with an up-to-date kubernetes Python module, e.g. show all nodes of the cluster when executing kubernetes.nodes.

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
          Salt: 3005

Dependency Versions:
          cffi: Not Installed
      cherrypy: Not Installed
      dateutil: 2.7.3
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 0.6.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: Not Installed
      pycrypto: Not Installed
  pycryptodome: 3.6.1
        pygit2: Not Installed
        Python: 3.8.10 (default, Jun 22 2022, 20:18:18)
  python-gnupg: 0.4.5
        PyYAML: 6.0
         PyZMQ: 18.1.1
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.3.2

System Versions:
          dist: ubuntu 20.04 focal
        locale: utf-8
       machine: x86_64
       release: 5.4.0-88-generic
        system: Linux
       version: Ubuntu 20.04 focal

Additional context
The strategy of simply adding another level of try/except ImportError as done in the past:

try:
    import kubernetes  # pylint: disable=import-self
    import kubernetes.client
    from kubernetes.client.rest import ApiException
    from urllib3.exceptions import HTTPError

    # pylint: disable=no-name-in-module
    try:
        # There is an API change in Kubernetes >= 2.0.0.
        from kubernetes.client import V1beta1Deployment as AppsV1beta1Deployment
        from kubernetes.client import V1beta1DeploymentSpec as AppsV1beta1DeploymentSpec
    except ImportError:
        from kubernetes.client import AppsV1beta1Deployment
        from kubernetes.client import AppsV1beta1DeploymentSpec

...didn't work for me in this case, as it would require quite some refactoring to work with recent Kubernetes APIs.

As a workaround, I'm using ... pip.installed name='kubernetes >= 12.0.0, <= 16.0.0' now which at least ensures the module loads, but I can't tell yet how far it'll cover my clusters functionality provided by its 24.3.0 API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior dependency underlying Salt dependency issue Deprecation k8s-modules needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants