Skip to content

Commit

Permalink
Merge d5105e7 into fff1895
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Dec 13, 2018
2 parents fff1895 + d5105e7 commit 26a0b70
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
38 changes: 38 additions & 0 deletions reana_commons/k8s/api_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2018 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Kubernetes API Client."""

from functools import partial

from kubernetes import client
from kubernetes import config as k8s_config
from werkzeug.local import LocalProxy


def create_api_client(api='BatchV1'):
"""Create Kubernetes API client using config.
:param api: String which represents which Kubernetes API to spawn. By
default BatchV1.
:returns: Kubernetes python client object for a specific API i.e. BatchV1.
"""
k8s_config.load_incluster_config()
api_configuration = client.Configuration()
api_configuration.verify_ssl = False
if api == 'CoreV1':
api_client = client.CoreV1Api()
else:
api_client = client.BatchV1Api()
return api_client


current_k8s_batchv1_api_client = LocalProxy(create_api_client)

current_k8s_corev1_api_client = LocalProxy(partial(create_api_client,
api='CoreV1'))
2 changes: 1 addition & 1 deletion reana_commons/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

from __future__ import absolute_import, print_function

__version__ = "0.5.0.dev20181210"
__version__ = "0.5.0.dev20181213"
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
'sphinx-rtd-theme>=0.1.9',
],
'tests': tests_require,
'kubernetes': [
'kubernetes>=6.0.0',
],
}

extras_require['all'] = []
Expand All @@ -56,6 +59,7 @@
'click>=7.0,<8.0',
'jsonschema[format]>=2.6.0,<2.7',
'kombu>=4.2.0,<5.0',
'Werkzeug==0.14.1',
]

packages = find_packages()
Expand Down

0 comments on commit 26a0b70

Please sign in to comment.