cncf / cnf-testbed

ARCHIVED: 🧪🛏️Cloud-native Network Function (CNF) Testbed --> See LFN Cloud Native Telecom Initiative https://wiki.lfnetworking.org/pages/viewpage.action?pageId=113213592
https://wiki.lfnetworking.org/pages/viewpage.action?pageId=113213592
Apache License 2.0
164 stars 51 forks source link

Reduce the size of Network Functions Docker images #341

Closed electrocucaracha closed 4 years ago

electrocucaracha commented 4 years ago

The current Dockerfile implementation of the Network Functions has the following sizes

Image name Size
gogtp:sgw 482MB
gogtp:mme 649MB
gogtp:pgw 481MB
gogtp:enb 655MB
gogtp:latest 696MB

Implementing some of the official best practices, the following results can be achieved.

Image name Size
gogtp:sgw 20.6MB
gogtp:mme 21.5MB
gogtp:pgw 20.5MB
gogtp:enb 22.2MB
gogtp:latest 68MB

So these changes reduce the space required by the Docker registry.

michaelspedersen commented 4 years ago

All in all this is good set of changes, and the reduction in image size is definitely an improvement. My only concerns are:

electrocucaracha commented 4 years ago

All in all this is good set of changes, and the reduction in image size is definitely an improvement. My only concerns are:

* Entrypoints, as the eNB has to be the last application to run (otherwise it will fail).

  * While there are several ways to work around this, it will require further update of the example deployment code in the repository.

* Existing deployments: One example can be seen [here](https://github.com/cncf/cnf-testbed/blob/master/examples/use_case/gogtp-k8s/k8s_bridged_cmk/gogtp/templates/deployment.yaml). Existing code will need to be updated to include the `-config /etc/<app>.yml` parameter when overriding the entrypoint.

Hey @michaelspedersen thanks for the quick response. I was thinking to create a docker-compose.yml file as a quick way to express requirements and order execution but I'm still working on it.

Regarding the configuration file, I was thinking to override the configuration file /etc/<app>.yml with a customized file something like this:

docker run -d -v ./enb/single-host-enb.yml:/etc/enb.yml gogtp:enb
michaelspedersen commented 4 years ago

Running it through Docker would be one approach, but for the testbed we will likely still have to consider Helm as well. Adding the configuration can be done by a volume mount similar to what you mention, but ideally it should be added as a configmap.

IIRC the binary will look for the configuration in it's own directory, so unless the config is pushed to /usr/local/bin (let's not do that :) ) then I think the best approach is to update all of the existing code to always include the path to the configuration file as well.

electrocucaracha commented 4 years ago

Yeah, using a ConfigMap should be more appropriate. The main idea is to separate the configuration file somewhere it can be override it to following some of the twelve factor principles.

Regarding the destination of the binaries and configuration, eventually they need to be changed to a least privileged place. Running docker containers with all privileged permissions could be a bad idea.

Last but not least, I noticed that some containers expose ports which are not defined in the Dockerfiles. I'm going to keep testing and their review code.

michaelspedersen commented 4 years ago

Changes added to the Tested. Some updates are needed for existing use-cases, but until the images are updated on docker hub everything will function "as usual"

michaelspedersen commented 4 years ago

Updated use-cases to reflect changes to GoGTP code and changes to image.