Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support NetBox plugins #173

Closed
manusys64 opened this issue Dec 20, 2023 · 3 comments
Closed

Support NetBox plugins #173

manusys64 opened this issue Dec 20, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@manusys64
Copy link

manusys64 commented Dec 20, 2023

I would like to know if is possible to add custom plugins through helm chart?
I saw that in default values there are 2 variables related to plugins:

plugins: []
pluginsConfig: {}

I have tried to add a plugin within plugin list variable like so:

plugins: 
- netbox_dns

but helm chart fail to deploy due to this error (which is legit)

django.core.exceptions.ImproperlyConfigured: Unable to import plugin netbox_dns: Module not found. Check that the plugin module has been installed within the correct Python environment.
[ Use DB_WAIT_DEBUG=1 in netbox.env to print full traceback for errors here ]
⏳ Waiting on DB... (0s / 30s)
django.core.exceptions.ImproperlyConfigured: Unable to import plugin netbox_dns: Module not found. Check that the plugin module has been installed within the correct Python environment.

So how we can install new plugins to NetBox deployed via helm chart?

Thank you and best regards!

@JevgenijsKonevs
Copy link

JevgenijsKonevs commented Jan 23, 2024

@manusys64
One way how you can install the plugins is to create custom Netbox Docker image.

Example of Dockerfile config :

FROM netboxcommunity/netbox:v3.5.1

RUN . /opt/netbox/venv/bin/activate && \
    pip install netbox-plugin-dns 

Add reference to the custom Dockerfile in Helm chart :

image:
  repository: YOUR_REPOSITORY
  tag: "IMAGE_TAG"
plugins:
  - netbox_dns

@viperbmw
Copy link

viperbmw commented Mar 21, 2024

I have tried to use this Dockerfile to build a custom image.

FROM netboxcommunity/netbox:latest
RUN echo "netbox-secrets" >> requirements.txt && \
    echo "netbox-secrets" >> local_requirements.txt \
    echo "netbox-topology-views" >> requirements.txt && \
    echo "netbox-topology-views" >> local_requirements.txt \
    echo "netbox-bgp" >> requirements.txt && \
    echo "netbox-bgp" >> local_requirements.txt
RUN . /opt/netbox/venv/bin/activate && pip install netbox-secrets netbox-topology-views netbox-bgp
RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img
SHELL ["/bin/bash", "-c"]
RUN echo $'\n\
PLUGINS = ["netbox_secrets", "netbox_bgp","netbox_topology_views"]\n\
PLUGINS_CONFIG = {\n\
    \'netbox_topology_views\': {\n\
        \'static_image_directory\': \'netbox_topology_views/img\',\n\
        \'allow_coordinates_saving\': True,\n\
        \'always_save_coordinates\': True\n\
    }\n\
}' >> /opt/netbox/netbox/netbox/configuration.py
RUN SECRET_KEY="dummydummydummydummydummydummydummydummydummydummy" /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py collectstatic --no-input

When I try to use the custom image in the Helm Chart I get

/opt/netbox/docker-entrypoint.sh: line 20: ./manage.py: No such file or directory
[ Use DB_WAIT_DEBUG=1 in netbox.env to print full traceback for errors here ]
⏳ Waiting on DB... (18s / 30s)

What am I doing wrong?

When using the image in docker compose it works.........

@LeoColomb LeoColomb changed the title How to add/install additional Netbox Plugins using helm chart Support additional Netbox plugins Jul 27, 2024
@LeoColomb LeoColomb added documentation Improvements or additions to documentation enhancement New feature or request labels Jul 29, 2024
@LeoColomb LeoColomb changed the title Support additional Netbox plugins Support additional NetBox plugins Oct 13, 2024
@LeoColomb LeoColomb changed the title Support additional NetBox plugins Support NetBox plugins Oct 23, 2024
@LeoColomb
Copy link
Member

After an extensive study, I'm going to close this feature request.
Adding plugin installation at runtime is against the container (and Kubernetes) principle.
This is very well explained by @cimnine in netbox-community/netbox-docker#1071:

This change would – in my opinion – go against a basic principle of containers: That containers (and everything that defines them) are fully defined during build-time (or at least after the build) and that everything required by the container is packaged together. In other words, a container should provide everything that is required to run that container, besides truly external dependencies like databases or configuration.

This applies even more in a Kubernetes context. In a same deployment, a new pod is expected to be as equal as possible as another one. Adding an installation step breaks that rule, adds surface for errors and breakage.
While adding the installation step as an init container is possible, it requires storing the Python virtual environment in a volume, which is more tricky than just a pip install and would makes upgrade much more challenging.

The recommended way to process is the one documented on NetBox container image wiki (and written above by @JevgenijsKonevs).
That way also ensures the Python compatibility between plugins and NetBox itself is mostly checked outside the Kubernetes deployment.


With the use of Helm chart, the custom image build and use can be simplified to the following steps.

  1. Build your own image with the plugins (and their requirements) bundled on top of NetBox image.
    The following is a Dockerfile example:

    FROM netboxcommunity/netbox:latest
    RUN /opt/netbox/venv/bin/pip install --no-warn-script-location \
        plugin_1 \
        plugin_2
  2. Use the chart values to load the configuration.
    For example:

    plugins:
      - plugin-1
      - plugin-2
    pluginsConfig:
      plugin-2:
        custom: true

@LeoColomb LeoColomb pinned this issue Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants