Git Product home page Git Product logo

tng-sp-ia-k8s's Introduction

Build Status Join the chat at https://gitter.im/sonata-nfv/Lobby

5GTANGO Kubernetes wrapper for NFV cloud-native deployments

Kubernetes Wrapper: Component in the SONATA framework that is responsible to manage the interface between MANO and deployed functions.

Requires

  • Docker

Implementation

  • implemented in Python 3.4
  • dependecies: amqp-storm
  • The main implementation can be found in: tng-sp-ia-k8s/k8s.py

How to run it

  • (follow the general README.md of this repository to setup and test your environment)
  • To run the k8s wrapper locally, you need:
    • a running RabbitMQ broker (see general README.md of this repo for info on how to do this)
    • a running plugin manager connected to the broker (see general README.md of this repo for info on how to do this)
  • Run the k8s wrapper (directly in your terminal not in a Docker container):
    • python3.4 tng-sp-ia-k8s/k8s.py
  • Or: run the k8s wrapper (in a Docker container):
    • docker build -t tng-sp-ia-k8s .
    • docker run -it --link broker:broker --name tng-sp-ia-k8s tng-sp-ia-k8s

Output

The output of the k8s wrapper should look like this:

INFO:k8s-wrapper:main:Starting IA Wrapper: 'k8s.KubernetesWrapper' ...
INFO:k8s-wrapper:main:Wrapper is connected to broker.
INFO:k8s-wrapper:main:Wrapper running...

It shows how the k8s wrapper connects to the broker, registers itself to the plugin manager and receives the instantiation event.

Unit tests

  • To run the unit tests of the k8s individually, run the following from the root of the repo:
    • ./test/test_tng-sp-ia-k8s.sh

Licensing

This 5GTANGO component is published under Apache 2.0 license. Please see the LICENSE file for more details.

Lead Developers

The following lead developers are responsible for this repository and have admin rights. They can, for example, merge pull requests.

Feedback-Chanel

  • You may use the mailing list sonata-dev-list
  • Please use the GitHub issues to report bugs.

tng-sp-ia-k8s's People

Contributors

pkarkazis avatar tsoenen avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tng-sp-ia-k8s's Issues

Port parser is not creating the right service object "readUint32: unexpected character: \ufffd"

We are getting an error creating the service object when adding ports:

INFO:k8s-wrapper:main:Creating a Service
/usr/local/lib/python3.4/site-packages/urllib3-1.24-py3.4.egg/urllib3/connectionpool.py:847: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
ERROR:k8s-wrapper:messaging:Error in subscription thread:
Traceback (most recent call last):
  File "/tng-sp-ia-k8s/kubernetes_wrapper/messaging.py", line 194, in connection_thread
    channel.start_consuming(to_tuple=False)
  File "/usr/local/lib/python3.4/site-packages/amqpstorm/channel.py", line 302, in start_consuming
    auto_decode=auto_decode
  File "/usr/local/lib/python3.4/site-packages/amqpstorm/channel.py", line 273, in process_data_events
    self._consumer_callbacks[consumer_tag](message)
  File "/tng-sp-ia-k8s/kubernetes_wrapper/messaging.py", line 171, in _wrapper_cbf
    cbf(ch, method, properties, body)
  File "/tng-sp-ia-k8s/kubernetes_wrapper/k8s.py", line 286, in function_instance_create
    self.start_next_task(func_id)
  File "/tng-sp-ia-k8s/kubernetes_wrapper/k8s.py", line 170, in start_next_task
    print(task.result())
  File "/usr/local/lib/python3.4/concurrent/futures/_base.py", line 395, in result
    return self.__get_result()
  File "/usr/local/lib/python3.4/concurrent/futures/_base.py", line 354, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/tng-sp-ia-k8s/kubernetes_wrapper/k8s.py", line 430, in deploy_cnf
    engine.KubernetesWrapperEngine.create_service(self, obj_service, "default")
  File "/tng-sp-ia-k8s/kubernetes_wrapper/k8s_wrapper.py", line 176, in create_service
    body=service, namespace=namespace , async_req=False)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/apis/core_v1_api.py", line 6934, in create_namespaced_service
    (data) = self.create_namespaced_service_with_http_info(namespace, body, **kwargs)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/apis/core_v1_api.py", line 7025, in create_namespaced_service_with_http_info
    collection_formats=collection_formats)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/api_client.py", line 321, in call_api
    _return_http_data_only, collection_formats, _preload_content, _request_timeout)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/api_client.py", line 155, in __call_api
    _request_timeout=_request_timeout)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/api_client.py", line 364, in request
    body=body)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/rest.py", line 266, in POST
    body=body)
  File "/usr/local/lib/python3.4/site-packages/kubernetes-8.0.0b1-py3.4.egg/kubernetes/client/rest.py", line 222, in request
    raise ApiException(http_resp=r)
kubernetes.client.rest.ApiException: (400)
Reason: Bad Request
HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Thu, 25 Oct 2018 02:12:18 GMT', 'Content-Length': '444'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Service in version \"v1\" cannot be handled as a Service: v1.Service.Spec: v1.ServiceSpec.Ports: []v1.ServicePort: v1.ServicePort.Port: readUint32: unexpected character: \ufffd, error found in #10 byte of ...| \"port\": \"80\"}]}}|..., bigger context ...|\": [{\"name\": \"http\", \"targetPort\": \"80\", \"port\": \"80\"}]}}|...","reason":"BadRequest","code":400}

Confimaps are not taking the right name

The configmap created by the wrapper uses the same name for all containers and when the deployment object wants to use it, then the configmap didn't exists.

Warning  Failed     64s (x3 over 89s)  kubelet, k8s-node  Error: configmap "cdu03-dce23ef1-37e1-4241-8c6a-cccb1a010d34" not found
Warning  Failed     64s (x3 over 79s)  kubelet, k8s-node  Error: configmap "cdu04-dce23ef1-37e1-4241-8c6a-cccb1a010d34" not found

NBI IA Integration

We need to integrate the wrapper with the NBI to receive instantiation requests. To that end, the following steps have to be performed:

Topic: infrastructure.k8s.function.deploy:

  • Define the fields received by the k8s Wrapper
  • Define format of the VNFR created by k8s Wrapper
  • Integration tests between IA <-> k8s Wrapper

Topic: infrastructure.k8s.function.remove:

  • Define the fields received by the k8s Wrapper

  • Define the reply of the function remove request

  • Integration tests between IA <-> k8s Wrapper

  • Documentation

Kubernetes cluster credentials management

Objectives:
We need to have the configuration of the kubernetes clusters stored, providing security of the data

Requirements:

  • Configuration Manager: read, write, delete, update the credentials.
  • The credentials have to be stored encrypted

TODO:

  • Evaluate databases solution for storing k8s credentials (Postgres / Mongo)
  • Classes to handle Read/Write?/Delete?/Update?
  • Integration tests wrapper <-> Database
  • Documentation

Extentions to support scaling

To scale, the MANO will be sending on the topic for cnf deployment and cnf removal. The k8s wrapper needs to be smart with these messages to see when it is a scale event.

adding CNF

topic: infrastucture.k8s.function.deploy

payload example:

service_instance_id: ff0757e7-0d29-417d-8b63-cba80b6ffd9d
vim_uuid: 88888888-2222-3333-4444-888888888888
vnfd:
  author: 5GTANGO Test Team
  cloudnative_deployment_units:
  - connection_points:
    - fip: true
      id: data
      network_id: ff0757e7-0d29-417d-8b63-cba80b6ffd9d_ns_data-2-cnfs
      port: 1883
    id: cdu01-dfe39daa-0538-4133-8de1-d3cf6b43d14a
    image: ubuntu:trusty
  connection_points:
  - id: data
    interface: ipv4
    port: 1883
    type: serviceendpoint
  description: This is a integration test artifact
  descriptor_schema: https://raw.githubusercontent.com/sonata-nfv/tng-schema/master/function-descriptor/vnfd-schema.yml
  function_specific_managers:
  - description: FSM to do some dummy config on the ubuntu image for testing purposes
    id: ubuntuk8s
    image: tsoenen/ubuntuk8s-fsm
    options:
    - key: type
      value: start
    - key: type
      value: configure
  instance_uuid: dfe39daa-0538-4133-8de1-d3cf6b43d14a
  name: cnf1
  uuid: 2dcbf6f1-8019-404e-af24-d59b77fb9f97
  vendor: eu.5gtango
  version: '0.1'
  virtual_links:
  - connection_points_reference:
    - data
    - cdu01:data
    connectivity_type: E-Tree
    id: data-link

When the k8s wrapper receives a message on the .deploy topic, it needs to use the service_instance_id, the vnfd (e.g. image urls) and vim_uuid to check if there is already a pod for this vnfd part of the service instance. If it is, we just need another replica for this pod. If it is not, regular deployment needs to be followed. The response from the wrapper on this message should be the same for both cases.

Removing CNF

topic: infrastructure.k8s.function.remove

example payload:

service_instance_id:
vim_uuid:
vnf_uuid:

When reciving requests to remove a cnf, the K8s wrapper should check which pod is linked to this CNF (based on vim, vnf and service instance id) and check the amount of replicas. If higher than 1, reduce the number by 1. If 1, remove the pod. Responses to the MANO should be similar for both cases. Currently, the functionality for both cases is missing, for now this topic is not correctly handled. A response to a request on this topic looks like this

request_status: "COMPLETED" | "ERROR"
message: None | "possible error message"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.