[BUG] `modules.kubernetes` is broken due to use of deprecated API version
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
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
kubeconfigfile - 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the modules.kubernetes entry point and reproduce the failure with Kubernetes Python API bindings 24.2.0 using salt-call kubernetes.nodes and the supplied kubeconfig. Trace the deprecated deployment API usage and determine the refactoring needed for current bindings; done means the module loads and kubernetes.nodes shows the cluster nodes with the newer dependency.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kubernetes, python
- Domain
- cloud, devops, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100