ccremer/fronius-exporter

Multiarch Docker Image

Closed this issue · 8 comments

It would be really nice to have a multi-arch docker image for this.

I would like to run this on a k3s raspberry pi cluster but it looks like the current docker image is only amd64?

This (https://itnext.io/ci-cd-for-a-multi-arch-go-application-using-github-actions-docker-buildx-helm-and-kubernetes-f415a42b2c82) seems to have a good example of how to implement building multi-arch docker images using github actions.

Sure!
I already have my standard way of building for multi-arch, it's just a matter of "doing it".

I also had to add libc6-compat to get it to work.

Here is the Dockerfile I use for building on and for raspberry pi.

FROM golang:1.13 as builder
COPY . /build
RUN cd /build && make build

FROM alpine:3.12
COPY --from=builder /build/fronius-exporter /usr/local/bin/fronius-exporter

RUN \
  apk add --no-cache libc6-compat

ENTRYPOINT ["/usr/local/bin/fronius-exporter"]

It works for 32 and 64 bit arm. I had to switch to 64 bit as prometheus does not very well on 32 bit.

@ccremer happy to test the resulting image if you can push it somewhere

Hi.
I've release a pre-release with ARM. Please try if docker pull ghcr.io/ccremer/fronius-exporter:v0.9.0-rc1 works and runs for you.
Once you give confirmation, I can tag the full release.

@ccremer I'm currently running 32-bit raspbian OS so I would need an armv7 build as well as the arm64

pi@kube-master-0:~ $ sudo ctr image pull ghcr.io/ccremer/fronius-exporter:v0.9.0-rc1
ghcr.io/ccremer/fronius-exporter:v0.9.0-rc1:                                   resolved       |++++++++++++++++++++++++++++++++++++++| 
index-sha256:8f51f2657ce3a5df7e14b6a8b5d73c969a3608455489d3af0b233d502c75d9ed: done           |++++++++++++++++++++++++++++++++++++++| 
elapsed: 2.4 s                                                                 total:   0.0 B (0.0 B/s)                                         
unpacking linux/arm/v7 sha256:8f51f2657ce3a5df7e14b6a8b5d73c969a3608455489d3af0b233d502c75d9ed...
ctr: no match for platform in manifest sha256:8f51f2657ce3a5df7e14b6a8b5d73c969a3608455489d3af0b233d502c75d9ed: not found
pi@kube-master-0:~ $ uname -a
Linux kube-master-0 5.10.17-v7+ #1414 SMP Fri Apr 30 13:18:35 BST 2021 armv7l GNU/Linux
pi@kube-master-0:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

@ccremer I upgraded one of my node to 64 bit to test the amd64 image and it looks like its working well

I think the armv7 build is still worth having if its not too hard to add though

PS C:\Users\Mark> kubectl get nodes -o wide                                                                  
NAME            STATUS   ROLES                  AGE    VERSION        INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                         KERNEL-VERSION   CONTAINER-RUNTIME
kube-worker-0   Ready    <none>                 129d   v1.20.9+k3s1   192.168.0.202   <none>        Raspbian GNU/Linux 10 (buster)   5.10.17-v7+      containerd://1.4.8-k3s1
kube-master-0   Ready    control-plane,master   129d   v1.20.9+k3s1   192.168.0.201   <none>        Raspbian GNU/Linux 10 (buster)   5.10.17-v7+      containerd://1.4.8-k3s1
kube-master-1   Ready    <none>                 28m    v1.20.9+k3s1   192.168.0.203   <none>        Debian GNU/Linux 11 (bullseye)   5.10.63-v8+      containerd://1.4.8-k3s1
PS C:\Users\Mark> kubectl -n fronius get pod -o wide
NAME                                READY   STATUS    RESTARTS   AGE     IP          NODE            NOMINATED NODE   READINESS GATES
fronius-exporter-845c44d889-6ghk5   1/1     Running   0          4m40s   10.42.2.4   kube-master-1   <none>           <none>
PS C:\Users\Mark> kubectl -n fronius exec fronius-exporter-845c44d889-6ghk5 -- curl -s localhost:8080/metrics
# HELP fronius_inverter_power Power flow of the inverter in Watt
# TYPE fronius_inverter_power gauge
fronius_inverter_power{inverter="1"} 4090
# HELP fronius_inverter_soc State of charge of the battery attached to the inverter in percent
# TYPE fronius_inverter_soc gauge
fronius_inverter_soc{inverter="1"} 0
# HELP fronius_scrape_duration_seconds Time it took to scrape the device in seconds
# TYPE fronius_scrape_duration_seconds gauge
fronius_scrape_duration_seconds 3.817705411
# HELP fronius_scrape_error_count Number of scrape errors
# TYPE fronius_scrape_error_count counter
fronius_scrape_error_count 0
# HELP fronius_site_autonomy_ratio Relative autonomy ratio of the site
# TYPE fronius_site_autonomy_ratio gauge
fronius_site_autonomy_ratio 1
# HELP fronius_site_energy_consumption Energy consumption in kWh
# TYPE fronius_site_energy_consumption gauge
fronius_site_energy_consumption{time_frame="day"} 15893
fronius_site_energy_consumption{time_frame="total"} 1.779274e+07
fronius_site_energy_consumption{time_frame="year"} 107214.6015625
# HELP fronius_site_mppt_current_dc Site mppt current DC in A
# TYPE fronius_site_mppt_current_dc gauge
fronius_site_mppt_current_dc{inverter="1",mppt="1"} 5.75
fronius_site_mppt_current_dc{inverter="1",mppt="2"} 5.7700000000000005
# HELP fronius_site_mppt_voltage Site mppt voltage in V
# TYPE fronius_site_mppt_voltage gauge
fronius_site_mppt_voltage{inverter="1",mppt="1"} 331.90000000000003
fronius_site_mppt_voltage{inverter="1",mppt="2"} 329.8
# HELP fronius_site_power_accu Site power supplied to or provided from the accumulator(s) in Watt
# TYPE fronius_site_power_accu gauge
fronius_site_power_accu 0
# HELP fronius_site_power_grid Site power supplied to or provided from the grid in Watt
# TYPE fronius_site_power_grid gauge
fronius_site_power_grid -3584.78
# HELP fronius_site_power_load Site power load in Watt
# TYPE fronius_site_power_load gauge
fronius_site_power_load -505.2199999999998
# HELP fronius_site_power_photovoltaic Site power supplied to or provided from the accumulator(s) in Watt
# TYPE fronius_site_power_photovoltaic gauge
fronius_site_power_photovoltaic 4090
# HELP fronius_site_selfconsumption_ratio Relative self consumption ratio of the site
# TYPE fronius_site_selfconsumption_ratio gauge
fronius_site_selfconsumption_ratio 0.12352567237163808
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 9
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.16.12"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 1.532784e+06
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 1.532784e+06
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.445018e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 735
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 0
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 4.09784e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 1.532784e+06
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 6.4151552e+07
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 2.531328e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 9357
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 6.3995904e+07
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 6.668288e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 0
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 10092
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 4800
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 16384
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 54264
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 65536
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.473924e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 880958
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 425984
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 425984
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 7.36146e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 6
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.25
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 10
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 9.801728e+06
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.64135594445e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 7.29391104e+08
# HELP process_virtual_memory_max_bytes Maximum amount of virtual memory available in bytes.
# TYPE process_virtual_memory_max_bytes gauge
process_virtual_memory_max_bytes 1.8446744073709552e+19
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 4
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
PS C:\Users\Mark> kubectl -n fronius logs fronius-exporter-845c44d889-6ghk5                                   
time="2022-01-05T04:12:25Z" level=info msg="Starting exporter." commit=8d01b08f492cbe3883ba82cb721004fe3128146e date="2022-01-05 04:12:25.221047722 +0000 UTC m=+0.010260118" version=0.9.0-rc1
time="2022-01-05T04:12:25Z" level=info msg="Listening for scrapes." port=":8080"

Sorry for the delay
I added arm v7 now. Hope it works!

@ccremer Working fine on both arch=arm and arch=arm64 using ghcr.io/ccremer/fronius-exporter:v0.9.0.

Thanks heaps!