Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
kube-config fix
Browse files Browse the repository at this point in the history
  • Loading branch information
eminaktas committed Apr 3, 2021
1 parent 8b8a483 commit 4833285
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions k8s_workload_scaler/kubectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def pick_cluster(self, cluster_name: str = None):
try:
# Load the context in kube-config file
contexts, active_context = config.list_kube_config_contexts(config_file=self.kube_config)
config.load_incluster_config()
self.logger.debug(f"contexts: {contexts}, active_context: {active_context}")
if not contexts:
self.logger.error("Cannot locate any context in kube-config file")
Expand All @@ -51,10 +52,10 @@ def pick_cluster(self, cluster_name: str = None):

return {
'core_v1': client.CoreV1Api(
api_client=config.new_client_from_config(context=picked_cluster)
api_client=config.new_client_from_config(config_file=self.kube_config, context=picked_cluster)
),
'apps_v1': client.AppsV1Api(
api_client=config.new_client_from_config(context=picked_cluster)
api_client=config.new_client_from_config(config_file=self.kube_config, context=picked_cluster)
),
}
except Exception as e:
Expand Down

0 comments on commit 4833285

Please sign in to comment.