Skip to content
This repository was archived by the owner on Dec 1, 2018. It is now read-only.

default the context namespace to the context in which we are operating #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions pykube/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class KubeConfig(object):
def from_service_account(cls, path="/var/run/secrets/kubernetes.io/serviceaccount", **kwargs):
with open(os.path.join(path, "token")) as fp:
token = fp.read()
if os.path.exists(os.path.join(path, "namespace")):
with open(os.path.join(path, "namespace")) as fp:
namespace = fp.read()
else:
namespace = "default"

host = os.environ.get("PYKUBE_KUBERNETES_SERVICE_HOST")
if host is None:
host = os.environ["KUBERNETES_SERVICE_HOST"]
Expand Down Expand Up @@ -51,6 +57,7 @@ def from_service_account(cls, path="/var/run/secrets/kubernetes.io/serviceaccoun
"context": {
"cluster": "self",
"user": "self",
"namespace": namespace,
},
}
],
Expand Down