---
title: Charmhub | Deploy SD-Core NRF K8s using Charmhub - The Open Operator Collection
description: Deploy the latest version of SD-Core NRF K8s as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s
---

# SD-Core NRF K8s

[Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

* [Canonical Telco](https://charmhub.io/publisher/telco-charmers "View all packages from Canonical Telco")

Platform:

1.5/stable 757

```
juju deploy sdcore-nrf-k8s --channel 1.5/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#drawer)

## charms.sdcore\_nrf\_k8s.v0.fiveg\_nrf\_k8s

* [*Docstrings*Docstrings](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s)
  [*Code*Source code](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.sdcore_nrf_k8s.v0.fiveg_nrf_k8s
    ```

    [Download fiveg\_nrf\_k8s.py](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s/download)
  + *Last updated* 07 Dec 2023
  + *Revision* Library version 0.1

Library for the `fiveg_nrf_k8s` relation.

This library contains the Requires and Provides classes for handling the `fiveg_nrf_k8s`
interface.

The purpose of this library is to relate a charm claiming to provide
NRF information and another charm requiring this information.

##### Getting Started

From a charm directory, fetch the library using `charmcraft`:

```
charmcraft fetch-lib charms.sdcore_nrf_k8s.v0.fiveg_nrf_k8s
```

Add the following libraries to the charm's `requirements.txt` file:

* pydantic

###### Requirer charm

The requirer charm is the one requiring the NRF information.

Example:

```
from ops.charm import CharmBase
from ops.main import main

from charms.sdcore_nrf_k8s.v0.fiveg_nrf_k8s import NRFAvailableEvent, NRFRequires

logger = logging.getLogger(__name__)

class DummyFiveGNRFRequirerCharm(CharmBase):

    def __init__(self, *args):
        super().__init__(*args)
        self.nrf_requirer = NRFRequires(self, "fiveg-nrf")
        self.framework.observe(self.nrf_requirer.on.nrf_available, self._on_nrf_available)

    def _on_nrf_available(self, event: NRFAvailableEvent):
        nrf_url = self.nrf_requirer.nrf_url
        <do something with the nrf_url>

if __name__ == "__main__":
    main(DummyFiveGNRFRequirerCharm)
```

###### Provider charm

The provider charm is the one providing the information about the NRF.

Example:

```
from ops.charm import CharmBase, RelationJoinedEvent
from ops.main import main

from charms.sdcore_nrf_k8s.v0.fiveg_nrf_k8s import NRFProvides

class DummyFiveGNRFProviderCharm(CharmBase):

    NRF_URL = "https://nrf.example.com"

    def __init__(self, *args):
        super().__init__(*args)
        self.nrf_provider = NRFProvides(self, "fiveg-nrf")
        self.framework.observe(
            self.on.fiveg_nrf_relation_joined, self._on_fiveg_nrf_relation_joined
        )

    def _on_fiveg_nrf_relation_joined(self, event: RelationJoinedEvent):
        relation_id = event.relation.id
        self.nrf_provider.set_nrf_information(
            url=self.NRF_URL,
            relation_id=relation_id,
        )

    def _on_nrf_url_changed(
        self,
    ):
        self.nrf_provider.set_nrf_information_in_all_relations(
            url="https://different.nrf.com",
        )

if __name__ == "__main__":
    main(DummyFiveGNRFProviderCharm)
```

---

Index

* [class ProviderAppData](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#providerappdata)
* [class ProviderSchema](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#providerschema)
* [def data\_matches\_provider\_schema(
  data
  )](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#data_matches_provider_schema)
* [class NRFAvailableEvent](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfavailableevent)
* + [def \_\_init\_\_(
    self,
    handle,
    url)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfavailableevent-__init__)
* + [def snapshot(
    self)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfavailableevent-snapshot)
* + [def restore(
    self,
    snapshot)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfavailableevent-restore)
* [class NRFBrokenEvent](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfbrokenevent)
* + [def \_\_init\_\_(
    self,
    handle)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfbrokenevent-__init__)
* [class NRFRequirerCharmEvents](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfrequirercharmevents)
* [class NRFRequires](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfrequires)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfrequires-__init__)
* + [def nrf\_url(
    self)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfrequires-nrf_url)
* [class NRFProvides](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfprovides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfprovides-__init__)
* + [def set\_nrf\_information(
    self,
    url,
    relation\_id)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfprovides-set_nrf_information)
* + [def set\_nrf\_information\_in\_all\_relations(
    self,
    url)](https://charmhub.io/sdcore-nrf-k8s/libraries/fiveg_nrf_k8s#nrfprovides-set_nrf_information_in_all_relations)

#### class ProviderAppData

Description

Provider app data for fiveg\_nrf\_k8s. None

#### class ProviderSchema

Description

Provider schema for fiveg\_nrf\_k8s. None

#### def data\_matches\_provider\_schema(data: dict)

Returns whether data matches provider schema.

Arguments

data
(dict)

Data to be validated.

Returns

True if data matches provider schema, False otherwise.

#### class NRFAvailableEvent

Description

Charm event emitted when a NRF is available. It carries the NRF url. None

Methods

NRFAvailableEvent.
\_\_init\_\_(

*self*

,
handle: Handle

,
url: str
)

Description

Init. None

NRFAvailableEvent.
snapshot(

*self*
)

Description

Returns snapshot. None

NRFAvailableEvent.
restore(

*self*

,
snapshot: dict
)

Description

Restores snapshot. None

#### class NRFBrokenEvent

Description

Charm event emitted when a NRF goes down. None

Methods

NRFBrokenEvent.
\_\_init\_\_(

*self*

,
handle: Handle
)

Description

Init. None

#### class NRFRequirerCharmEvents

Description

List of events that the NRF requirer charm can leverage. None

#### class NRFRequires

Description

Class to be instantiated by the NRF requirer charm. None

Methods

NRFRequires.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Description

Init. None

NRFRequires.
nrf\_url(

*self*
)

Returns NRF url.

Returns

str

NRF url.

#### class NRFProvides

Description

Class to be instantiated by the charm providing the NRF data. None

Methods

NRFProvides.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Description

Init. None

NRFProvides.
set\_nrf\_information(

*self*

,
url: str

,
relation\_id: int
)

Sets NRF url in the application(s) relation data.

Arguments

url
(str)

NRF url.

relation\_id
(int)

Relation ID.

Returns

None

NRFProvides.
set\_nrf\_information\_in\_all\_relations(

*self*

,
url: str
)

Sets NRF url in applications for all applications.

Arguments

url
(str)

NRF url.

Returns

None
