Software installation
Installation of juju and charmcraft:
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-6.png)
Creation of the Charm structure
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-7.png)
After running these commands, you should have the following structure:
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-8.png)
Changing files
Changing files to create a basic charm
metadata.yaml
You should replace the maintainer:
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-9.png)
config.yaml
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-10.png)
actions.yaml
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-11.png)
src/charm.py
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-12-745x1024.png)
local-config.yaml
Keep in mind that you should replace the hostname with your machine, as well as the username and password that you have.
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-13.png)
Notes
Before building the charm you might need to execute the following commands:
$ lxd init --auto
$ lxc network set lxdbr0 ipv6.address none
Build the charm:
$ charmcraft build
Before deploying you might need to choose your controller (In your case should be localhost):
$ juju bootstrap
Deploying the charm using the configurations in the local-config file:
$ juju deploy ./prometheus-node-exporter_ubuntu-20.04-amd64.charm --config local-config.yaml
Check status:
$ juju status
Execute the ‘run‘ action to run a command inside the VM/VNF. You can check your unit_id with juju status.
$ juju run-action prometheus-node-exporter/<unit_id> run "command"="ls -la" --wait
Adding the Prometheus Node Metrics Exporter’s logic
Update actions.yaml
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-14.png)
Update src/charm.py
Add needed imports
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-15.png)
Inside the SampleProxyCharm class add the custom actions
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-16.png)
Define the 2 functions inside the class:
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-17.png)
Add functions to handle the prometheus:
![](https://community.5gasp.eu/wp-content/uploads/2023/03/image-18-397x1024.png)
Check if charm is working.
Build and deploy the charm again.
First, remove the first charm that we deployed:
$ juju remove-application prometheus-node-exporter
Using the commands in the first charm, build and deploy.
Run the action for the prometheus that we created:
$ juju run-action prometheus-node-exporter/<unit_id> start-prometheus-exporter --wait
Useful juju commands
Delete an application
$ juju remove-application <application_id>
Delete a machine
$ juju remove-machine <machine_id>
Check deployment logs
$ juju debug-log
Continuously observe deployment status
$ juju status –watch 5s
Access machine terminal
$ juju ssh <machine_id>
Tutorial materials
For a better description of the tutorial, you can check our video here.
You can also check a PDF version of this tutorial here.