# Akri IP Camera Firmware Upgrade Demo Walk-Through ###### tags: `Guides` This document will walk through how to perform a firmware upgrade of an IP camera with Akri. Specifically, it will help you use open source tools to create a mock ONVIF compliant IP camera that has support for the [`UpgradeSystemFirmware` ONVIF Device Management Handle](http://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl) and start an upgrade service that will "upgrade" the camera. The demo will have the following flow: 1. Install Akri with an ONVIF firmware upgrade Configuration 2. Discovery Handler/ Agent discovers camera and creates an Instance CR 3. Controller deploys firmware upgrade broker 4. Broker calls the `UpgradeSystemFirmware` endpoint on the camera 5. Camera calls its “upgrade service” 6. Upgrade service restarts camera with incremented firmware version ![Demo Flow Diagram](https://i.imgur.com/Jx9h0Ps.png) Before running the demo, there are some pre-configuration steps required to: 1. Set up the mock IP camera 2. Start the upgrade service 3. Install the ONVIF Device Manager Note: The mock camera setup and upgrade service have only been tested on Ubuntu 20.04 ## Pre-configuration ### Setting up mock ONVIF Camera 1. Clone the [`onvif-camera-mocking`](https://github.com/kate-goldenring/onvif-camera-mocking) repository 2. Follow the ["Option A: Copying from onvif_build container"](https://github.com/kate-goldenring/onvif-camera-mocking#option-a-copying-from-onvif_build-container) steps to copy the ONVIF server and discovery service to the root of the `onvif-camera-mocking` repository. **Be sure to pull and run the `ghcr.io/kate-goldenring/onvif-build-fw-upgrade:latest` image**. ### Start the Firmware Upgrade Service Clone and follow the instructions on the [ONVIF Firmware Upgrade Service README](https://github.com/kate-goldenring/onvif-firmware-upgrade-service) to start the mock camera and firmware upgrade service. ### Installing the ONVIF Device Manager Install the [ONVIF Device Manager](https://sourceforge.net/projects/onvifdm/) in order to see the camera's on the network and observe their firmware version's increase. If you successfully completed the previous pre-configuration steps, you should see the "TestDev" IP camera in the ONVIF Device Manager. ## Running the demo [Set up your cluster](https://docs.akri.sh/user-guide/cluster-setup), and then set `AKRI_HELM_CRICTL_CONFIGURATION` env var as explained in the Akri configure crictl [ documentation](https://docs.akri.sh/user-guide/cluster-setup#configure-crictl). ```shell= export AKRI_HELM_CRICTL_CONFIGURATION=<set based on distro> ``` ```shell= kubectl get no # 1. Install Akri with an ONVIF firmware upgrade Configuration helm install akri akri-helm-charts/akri \ $AKRI_HELM_CRICTL_CONFIGURATION \ --set onvif.discovery.enabled=true \ --set onvif.configuration.enabled=true \ --set onvif.configuration.capacity=2 \ --set onvif.configuration.name='akri-onvif-fw-update' \ --set onvif.configuration.brokerJob.image.repository='ghcr.io/kate-goldenring/onvif-upgrade-broker' # Watch as the Akri Agent, Controller, Configuration, CRDs, Instances, Brokers, and Services are created watch kubectl get akric,akrii,pods,services # This installation kicks off the rest of the demo steps # 2. Discovery Handler/ Agent discovers camera and creates an Instance CR # 3. Controller deploys firmware upgrade broker # 4. Broker calls the `UpgradeSystemFirmware` endpoint on the camera # 5. Camera calls its “upgrade service” # 6. Upgrade service restarts camera with incremented firmware version # Once the upgrade Pods have `Completed` the cameras should go offline for 30 seconds. # Notice (in the ONVIF Device Manager) how their firmware version has increased to `2` when they come back online. ``` Cleanup ```shell= helm delete akri ``` ## Demo extended with Streaming Application To showcase using Akri to both use and manage devices. The previous demo can be extended by first using Akri to deploy frame server brokers that will pull footage from the IP cameras and serve them. Then, a streaming application will consume the footage from these services and display it. At this point, you can perform an upgrade of the devices and visually see how the application temporarily stops while the cameras are being upgraded. **This is the demo that was showcased in the [CNCF Live Webinar: Discovering and Managing IoT Devices from Kubernetes with Akri](https://community.cncf.io/events/details/cncf-cncf-online-programs-presents-cncf-live-webinar-discovering-and-managing-iot-devices-from-kubernetes-with-akri/)** [Set up your cluster](https://docs.akri.sh/user-guide/cluster-setup), and then set `AKRI_HELM_CRICTL_CONFIGURATION` env var as explained in the Akri configure crictl [ documentation](https://docs.akri.sh/user-guide/cluster-setup#configure-crictl). ```shell= export AKRI_HELM_CRICTL_CONFIGURATION=<set based on distro> ``` ```shell= kubectl get no # Install Akri with a Configuration to deploy frame server brokers to each discovered IP camera. helm install akri akri-helm-charts/akri \ $AKRI_HELM_CRICTL_CONFIGURATION \ --set onvif.discovery.enabled=true \ --set onvif.configuration.enabled=true \ --set onvif.configuration.capacity=2 \ --set onvif.configuration.brokerPod.image.repository='ghcr.io/project-akri/akri/onvif-video-broker' \ --set onvif.configuration.brokerPod.image.tag='latest' # Watch as the Akri Agent, Controller, Configuration, CRDs, Instances, Brokers, and Services are created watch kubectl get akric,akrii,pods,services # Install streaming app curl https://raw.githubusercontent.com/project-akri/akri/main/deployment/samples/akri-video-streaming-app.yaml | sed -E 's/akri-udev-video/akri-onvif/g' | kubectl apply -f - watch kubectl get pods,services # Get node port for streaming app kubectl get service/akri-video-streaming-app --output=jsonpath='{.spec.ports[?(@.name=="http")].nodePort}' && echo # in a separate terminal, port forward so you can access the application on localhost: ssh user@ADDRESS -L 50000:localhost:PORT # Navigate to `localhost:50000` to see the streaming app # Install firmware upgrade configuration helm install onvif-upgrade-config akri-helm-charts/akri \ --set controller.enabled=false \ --set agent.enabled=false \ --set rbac.enabled=false \ --set onvif.configuration.enabled=true \ --set onvif.configuration.name='akri-onvif-fw-update' \ --set onvif.configuration.brokerJob.image.repository='ghcr.io/kate-goldenring/onvif-upgrade-broker' \ --set onvif.configuration.capacity='2' # Watch for new Jobs and Pods watch kubectl get akric,jobs,pods # Once the upgrade Pods have `Completed` the cameras should go offline for 30 seconds. # Notice (in the ONVIF Device Manager) how their firmware version has increased to `2` when they come back online. ``` Cleanup ```shell= helm delete onvif-upgrade-config curl https://raw.githubusercontent.com/project-akri/akri/main/deployment/samples/akri-video-streaming-app.yaml | sed -E 's/akri-udev-video/akri-onvif/g' | kubectl delete -f - helm delete akri ```