Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
CLUSTERMAN-812: upgrade k8s client library (#334)
Browse files Browse the repository at this point in the history
Upgrading k8s library to match our k8s clusters up to including k8s 1.24.

Note: Since we're using V1Eviction which only became available with k8s 1.22, we must wait with rollout until all clusters are on at least k8s 1.22.

Signed-off-by: Max Falk <[email protected]>
  • Loading branch information
gmdfalk authored Aug 17, 2023
1 parent b3b3f05 commit 6c4b8bb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clusterman/kubernetes/kubernetes_cluster_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import colorlog
import kubernetes
import staticconf
from kubernetes.client import V1beta1Eviction
from kubernetes.client import V1DeleteOptions
from kubernetes.client import V1Eviction
from kubernetes.client import V1ObjectMeta
from kubernetes.client.models.v1_node import V1Node as KubernetesNode
from kubernetes.client.models.v1_pod import V1Pod as KubernetesPod
Expand Down Expand Up @@ -356,7 +356,7 @@ def _evict_pod(self, pod: KubernetesPod):
self._core_api.create_namespaced_pod_eviction(
name=pod.metadata.name,
namespace=pod.metadata.namespace,
body=V1beta1Eviction(
body=V1Eviction(
metadata=V1ObjectMeta(
name=pod.metadata.name,
namespace=pod.metadata.namespace,
Expand Down
3 changes: 2 additions & 1 deletion clusterman/kubernetes/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from kubernetes.client.models.v1_node_selector_requirement import V1NodeSelectorRequirement
from kubernetes.client.models.v1_node_selector_term import V1NodeSelectorTerm
from kubernetes.client.models.v1_pod import V1Pod as KubernetesPod
from kubernetes.config.config_exception import ConfigException

from clusterman.util import ClustermanResources

Expand Down Expand Up @@ -72,7 +73,7 @@ def __init__(self, kubeconfig_path: str, client_class: Type) -> None:
kubernetes.config.load_incluster_config()
else:
kubernetes.config.load_kube_config(kubeconfig_path, context=os.getenv("KUBECONTEXT"))
except TypeError:
except (TypeError, ConfigException):
error_msg = "Could not load KUBECONFIG; is this running on Kubernetes master?"
if "yelpcorp" in socket.getfqdn():
error_msg += "\nHint: try using the clusterman-k8s-<clustername> wrapper script!"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ idna==2.8
jmespath==0.9.4
jsonpickle==1.4.2
kiwisolver==1.1.0
kubernetes==10.0.1
kubernetes==24.2.0
matplotlib==3.4.2
mypy-extensions==0.4.3
numpy==1.21.6
Expand Down
3 changes: 2 additions & 1 deletion tests/kubernetes/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from kubernetes.client.models.v1_node_selector_requirement import V1NodeSelectorRequirement
from kubernetes.client.models.v1_node_selector_term import V1NodeSelectorTerm
from kubernetes.config import ConfigException

from clusterman.kubernetes.util import CachedCoreV1Api
from clusterman.kubernetes.util import ConciseCRDApi
Expand All @@ -21,7 +22,7 @@ def mock_cached_core_v1_api():


def test_cached_corev1_api_no_kubeconfig(caplog):
with pytest.raises(TypeError):
with pytest.raises(ConfigException):
CachedCoreV1Api("/foo/bar/admin.conf")
assert "Could not load KUBECONFIG" in caplog.text

Expand Down

0 comments on commit 6c4b8bb

Please sign in to comment.