Skip to content

Commit

Permalink
Loading the kubeconfig file var on client instead of kubeshell
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosamorim committed Jun 4, 2018
1 parent 5501410 commit 7a24558
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions kubeshell/client.py
Expand Up @@ -3,21 +3,24 @@
from kubernetes import client, config
from kubernetes.client.api_client import ApiException

import os
import logging
import urllib3

# disable warnings on stdout/stderr from urllib3 connection errors
ulogger = logging.getLogger("urllib3")
ulogger.setLevel("ERROR")
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
kubeconfig_filepath = os.getenv("KUBECONFIG") or "~/.kube/config"


class KubernetesClient(object):

def __init__(self):
self.logger = logging.getLogger(__name__)
try:
config.load_kube_config()
config_file = os.path.expanduser(kubeconfig_filepath)
config.load_kube_config(config_file=config_file)
except:
self.logger.warning("unable to load kube-config")

Expand All @@ -29,7 +32,6 @@ def __init__(self):
self.batchV1Api = client.BatchV1Api()
self.batchV2Api = client.BatchV2alpha1Api()


def get_resource(self, resource, namespace="all"):
ret, resources = None, list()
try:
Expand Down
3 changes: 1 addition & 2 deletions kubeshell/kubeshell.py
Expand Up @@ -10,7 +10,7 @@
from kubeshell.completer import KubectlCompleter
from kubeshell.lexer import KubectlLexer
from kubeshell.toolbar import Toolbar
from kubeshell.client import KubernetesClient
from kubeshell.client import KubernetesClient, kubeconfig_filepath

import os
import click
Expand All @@ -24,7 +24,6 @@
registry = load_key_bindings_for_prompt()
completer = KubectlCompleter()
client = KubernetesClient()
kubeconfig_filepath = os.getenv("KUBECONFIG") or "~/.kube/config"


class KubeConfig(object):
Expand Down

0 comments on commit 7a24558

Please sign in to comment.