Skip to content

Commit

Permalink
Create new k8s client everytime to avoid token refresh issues (#18)
Browse files Browse the repository at this point in the history
* refresh k8s client

* remove global var
  • Loading branch information
surajkota committed May 6, 2021
1 parent 4ed6b55 commit 5ed60a5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/acktest/k8s/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

from ..resources import load_resource_file

_k8s_api_client = None


@dataclass
class CustomResourceReference:
Expand Down Expand Up @@ -112,10 +110,10 @@ def load_and_create_resource(resource_directory: Path,
return reference, spec, resource

def _get_k8s_api_client() -> ApiClient:
global _k8s_api_client
if _k8s_api_client is None:
_k8s_api_client = config.new_client_from_config()
return _k8s_api_client
# Create new client everytime to avoid token refresh issues
# https://github.com/kubernetes-client/python/issues/741
# https://github.com/kubernetes-client/python-base/issues/125
return config.new_client_from_config()


def create_k8s_namespace(namespace_name: str):
Expand Down

0 comments on commit 5ed60a5

Please sign in to comment.