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

Create new k8s client everytime to avoid token refresh issues #18

Merged
merged 2 commits into from
May 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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