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

Use incluster config fallback for KubernetesProvider #3357

Merged
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
21 changes: 20 additions & 1 deletion parsl/providers/kubernetes/kube.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,26 @@ def __init__(self,
if not _kubernetes_enabled:
raise OptionalModuleMissing(['kubernetes'],
"Kubernetes provider requires kubernetes module and config.")
config.load_kube_config()
try:
config.load_kube_config()
except config.config_exception.ConfigException:
# `load_kube_config` assumes a local kube-config file, and fails if not
# present, raising:
#
# kubernetes.config.config_exception.ConfigException: Invalid
# kube-config file. No configuration found.
#
# Since running a parsl driver script on a kubernetes cluster is a common
# pattern to enable worker-interchange communication, this enables an
# in-cluster config to be loaded if a kube-config file isn't found.
#
# Based on: https://github.com/kubernetes-client/python/issues/1005
try:
config.load_incluster_config()
except config.config_exception.ConfigException:
raise config.config_exception.ConfigException(
"Failed to load both kube-config file and in-cluster configuration."
)

self.namespace = namespace
self.image = image
Expand Down
Loading