d68a97fe47
Adds basic K8s client implementation and CONF-based singletons for both Neutron and K8s clients. The K8s client added by this patch should be considered a temporary solution that only implements the necessary parts to let us move forward with kuryr-kubernetes. Eventually it will be replaced by either [1] or [2]. The problem with [1] is that it does not yet support the streaming API that we need for WATCH. And [2] is outside of the OSt umbrella, so [1] is preferred over [2] unless [2] makes it into global-requirements.txt. [1] https://github.com/openstack/python-k8sclient [2] https://pypi.python.org/pypi/pykube NOTE: Removed py3-related code from config and top-level __init__. How to properly deal with that code is TBD. Change-Id: Ib4eb410eaf9725c296fcdddd8857eb24b8929915 Partially-Implements: blueprint kuryr-k8s-integration
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
# Copyright (c) 2016 Mirantis, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from kuryr.lib import utils
|
|
|
|
from kuryr_kubernetes import config
|
|
from kuryr_kubernetes import k8s_client
|
|
|
|
_clients = {}
|
|
_NEUTRON_CLIENT = 'neutron-client'
|
|
_KUBERNETES_CLIENT = 'kubernetes-client'
|
|
|
|
|
|
def get_neutron_client():
|
|
return _clients[_NEUTRON_CLIENT]
|
|
|
|
|
|
def get_kubernetes_client():
|
|
return _clients[_KUBERNETES_CLIENT]
|
|
|
|
|
|
def setup_clients():
|
|
_clients[_NEUTRON_CLIENT] = utils.get_neutron_client()
|
|
_clients[_KUBERNETES_CLIENT] = k8s_client.K8sClient(
|
|
config.CONF.kubernetes.api_root)
|