685f4c456a
PodResources client could be used by sriov cni to obtain devices allocated for container by sriov device-plugin. KubeletPodResources service is still in alpha, so it should be explicitly enabled in kubelet feature-gates: kubelet --feature-gates KubeletPodResources=true New config option 'kubelet_root_dir' added to 'sriov' section that defaults to kubelet default root-dir '/var/lib/kulelet'. In case kubelet started with non-default root directory passed via '--root-dir' option, the same value should be configured in 'kubelet_root_dir'. Note that if sriov binding driver will be used inside container 'kubelet_root_dir'/pod-resources directory should be mounted to this container in order to allow communication with kubelet via gRPC protocol over the unix domain socket. Partial-Bug: 1826865 Depends-On: https://review.openstack.org/#/c/652629 Change-Id: Icf088b839db079efe9c7647c31be4ead867ed32b Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
# Copyright (c) 2019 Samsung Electronics Co.,Ltd
|
|
# 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 oslo_log import log
|
|
|
|
import grpc
|
|
|
|
from kuryr_kubernetes.pod_resources import api_pb2
|
|
from kuryr_kubernetes.pod_resources import api_pb2_grpc
|
|
|
|
LOG = log.getLogger(__name__)
|
|
|
|
POD_RESOURCES_SOCKET = '/pod-resources/kubelet.sock'
|
|
|
|
|
|
class PodResourcesClient(object):
|
|
|
|
def __init__(self, kubelet_root_dir):
|
|
socket = 'unix:' + kubelet_root_dir + POD_RESOURCES_SOCKET
|
|
LOG.debug("Creating PodResourcesClient on socket: %s", socket)
|
|
self._channel = grpc.insecure_channel(socket)
|
|
self._stub = api_pb2_grpc.PodResourcesListerStub(self._channel)
|
|
|
|
def list(self):
|
|
try:
|
|
response = self._stub.List(api_pb2.ListPodResourcesRequest())
|
|
LOG.debug("PodResourceResponse: %s", response)
|
|
return response
|
|
except grpc.RpcError as e:
|
|
LOG.error("ListPodResourcesRequest failed: %s", e)
|
|
raise
|