Skip to content

Latest commit

 

History

History
146 lines (108 loc) · 5.83 KB

README.md

File metadata and controls

146 lines (108 loc) · 5.83 KB
OpenAirInterface AMF Operator

The operator is designed using kopf. The operator is completely written in python. At the moment the operator is highly experimental and designed for orchestration via nephio.

It can be used for oai-amf version v2.0.0.

NOTE: So far we have only tested the operator on a minikube cluster.

The directory structure is below:

.
├── controllers
│   ├── controller.py (Main controller logic)
│   └── utils.py (Supporting functions)
├── deployment
│   └── amf.yaml (to deploy the operator)
├── Dockerfile  
├── package
│   └── amfdeploy.yaml (Standalone deployment of AMF operator)
├── README.md
└── requirements.txt (All the needed python dependencies)

Functioning

The controller is listening to nephio proposed crd workload.nephio.org_amfdeployments.yaml cluster wide. In the future it will listen to OAI proposed CRDs also.

Controller requires configuration file of the network function and it allows configuring certain config parameters when the controller is deployed. The controller requires two configmaps when running inside a pod or during development phase you can just provide the path of the network function configuration file and the controllers configuration file. The reason of having controllers configuration file is to only expose some important paramters to configure the network function rather than exposing all the parameters.

The idea of this controller is not to expose multiple configuration paramters but to easily deploy the network function with less efforts from the user.

There are some environment parameters which are used by the controller to configure network function configuration files. They are present in utils.py

TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
NF_TYPE=str(os.getenv('NF_TYPE','amf'))      ## Network function name
LABEL={'workload.nephio.org/oai': f"{NF_TYPE}"}   ## Labels to put inside the owned resources
OP_CONF_PATH=str(os.getenv('OP_CONF_PATH',f"/tmp/op/{NF_TYPE}.yaml"))  ## Operators configuration file
NF_CONF_PATH = str(os.getenv('NF_CONF_PATH',f"/tmp/nf/{NF_TYPE}.yaml"))  ## Network function configuration file
DEPLOYMENT_FETCH_INTERVAL=int(os.getenv('DEPLOYMENT_FETCH_INTERVAL',1)) # Fetch the status of deployment every x seconds
DEPLOYMENT_FETCH_ITERATIONS=int(os.getenv('DEPLOYMENT_FETCH_ITERATIONS',100))  # Number of times to fetch the deployment
LOG_LEVEL = str(os.getenv('LOG_LEVEL','INFO'))    ## Log level of the controller
TESTING = str(os.getenv('TESTING','no'))    ## If testing the network function, it will remove the init container which checks for NRFs availability
HTTPS_VERIFY = bool(os.getenv('HTTPS_VERIFY',False)) ## To verfiy HTTPs certificates when communicating with cluster
TOKEN=os.popen('cat /var/run/secrets/kubernetes.io/serviceaccount/token').read() ## Token used to communicate with Kube cluster
KUBERNETES_BASE_URL = str(os.getenv('KUBERNETES_BASE_URL','http://127.0.0.1:8080'))
LOADBALANCER_IP = str(os.getenv('LOADBALANCER_IP',None))
SVC_TYPE = str(os.getenv('SVC_TYPE','ClusterIP')) 

AMF needs network-attachement-defination for N2 interface. Normally its nephio which will provide the nad. Controller is also capable of creating a nad via changing these fields in deployment/amf.yaml configmap of amf.yaml

    nad:
      parent: 'eth0'   #parent interface on the host machine to create the bridge
      create: False    #If false it will wait for multus defination in the cluster namespace

In case of docker pull limit on your network better to use pull secrets, just authenticated with the docker hub. You can add the pull secret in the operator configuration, amf.yaml in configmap like below

    imagePullSecrets:
      - name: test

NOTE: All the network function controllers except upf and nrf have the same functioning. Though they have a seperate code base but its still similar at the moment.

Deployment

The image is still not hosted on public respositories so you have to create an image

docker build -f Dockerfile -t oai-amf-controller:v2.0.0 . --no-cache

Create the CRD

kubectl create -f ../../crd/workload.nephio.org_amfdeployments.yaml

Start the controller

kubectl create -f deployment/amf.yaml

Normally nephio will create the nad incase you want to create manually then you do

kubectl create -f ../../oai5gcore/nad/amf.yaml

Create the resource

kubectl create -f package/amfdeploy.yaml

Development environment

For development it is good to use virtual python environment, I am using virtualenv

sudo apt install virtalenv
virtualenv -p python3 -m venv

Install the requirements

pip install -r requirements.txt

Make sure you copy operators yaml configuration file network functions .conf from deployment/amf.yaml and copy it to two different files and configure the env parameters

export OP_CONF_PATH='/path-to/op/amf.yaml'
export NF_CONF_PATH='/path-to/nf/amf.conf'

Now start the operator

kopf run controllers/controller.py --verbose

Note

In case you are not able to remove the package because the finalizer is blocking it then you can patch

kubectl patch amfdeployments.workload.nephio.org oai-amf -p '{"metadata": {"finalizers": []}}' --type merge