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

k3s/kubernettes install #525

Merged
merged 56 commits into from
Sep 26, 2024
Merged

k3s/kubernettes install #525

merged 56 commits into from
Sep 26, 2024

Conversation

cfoos
Copy link
Contributor

@cfoos cfoos commented Sep 21, 2024

Here are the files I used to get this running on k3s. The one issue I have not fixed is that in grafana the powerflow graphic in the top right does not work. Everything else appears to work correctly.

Configmap to hold pw login and a few other things.
config map to auto add sun/moon to grafana
Deployment for grafana based on grafana's recommendation but using image used for normal install
pvc for grafana storage, should be updated to storage class being used by whoever deploys, and amount allocated should be updated to something reasonable when created.
service for grafana. I'm using metallb and this should be updated by whoever deploys to what they are using.
deployment for influxdb set to same version as main install method in repo
pvc for influxdb, should be updated to storageclass of whoever deploys and allocations adjusted.
service to expose influxdb to other pods via nodeport
file to set up namespace
deployment for pypowerwall. pulls config from configmap
pvc for pypowerwall
service to expose pypowerwall via nodeport
configmap for telegraf. accesses pypowerwall and influxdb via nodeport so that does not need to be changed, but tz does.
deployment for telegraf, it mounts the configmap to the file system as the conf file
config for weather411, only api/lat/lon need updating when setting up.
weather411 deployment. Mounts config as file.
service for weather411
Just some notes
Changed service to have an ip so the dashboard graphic can access it.
added env variables so that the embedded html works.
@jasonacox
Copy link
Owner

jasonacox commented Sep 23, 2024

Hi @cfoos - Thanks for sharing this.

The one issue I have not fixed is that in grafana the powerflow graphic in the top right does not work

The power flow animation is a iframe in an html panel on Grafana that effectively renders this animation directly from pypowerwall - you can see an example of this hitting the pypowerwall endpoint at http://pypowerwall:8675/example.html - Does that help?

@cfoos
Copy link
Contributor Author

cfoos commented Sep 23, 2024

I tracked down how it was being added, but it being an iframe and finding pypowerwall via browser connection complicated it since under k3s it would be a seperate ip/hostname. Manually setting that in the dashboard helped, but if you put it behind a proxy to get a domain name it breaks in chrome, probably due to xss. I found a plugin for powerflow and I'm re-doing a k3s dashboard using it and adjusting some of the deployments to have things like readiness probes.
https://github.com/A-Lehmann-Elektro-AG/solar-flow-grafana
That can be pulled from grafana but that version is behind what he has on github and does not have solar added yet. I configured it to pull from the same data source as everything else and the only issue is that it is stuck to the refresh rate of the dashboard, but since this is local I just set that to 5s.

Added instructions to set up a test k3s on a single rpi 4.
local pvc for testing
local pvc for testing
modified dashboard for k3s. Also have pw2+ stuff removed since I only have the base 2 to test on.
metallb advertise for testing
metallb config for testing
@cfoos
Copy link
Contributor Author

cfoos commented Sep 25, 2024

One more minor update... We have been putting our tools and optional installations and extended capabilities in the /tools folder

moved

Formatting and order rewrite
@cfoos
Copy link
Contributor Author

cfoos commented Sep 25, 2024

Can we provide the option for both? The powerflow animation provides quite a bit of useful information that don't appear in the plugin.

The issue is that k3s runs everything in pods that have an internal to the cluster communication that is used to get the data from pypowerwall to influxdb then to grafana, but only services set up to be accessed externally can be. Because of that, for embedded html to get data from pypowerwall you need to add a service for external access to pypowerwall and update the embedded html to point to that services ip since your browser is not internal to k3s. Unless someone else knows how, I can't get metallb to allow different deployments/pods to share an ip. Because of that you end up with xss. You could add nginx in front of grafana as a reverse proxy so you can use a domain name and do the same for pypowerwall on a subdomain, but that gets even more complicated and harder to automate down the line.

I think the best way to keep the old data would be to find a data source that can poll pypowerwall from grafana and send that data to a visualization. This seems like it may be the best datasource if we can run the js on pypowerwall and just push the update data.
https://grafana.com/developers/plugin-tools/tutorials/build-a-streaming-data-source-plugin

Basically, run the entire page on the pypowerwall container and push the soe, aggregates, etc to the streaming datasource and use that to live update a visualization that has everything else hard coded instead of fetched on first load.

@jasonacox jasonacox merged commit fdbf065 into jasonacox:main Sep 26, 2024
@jasonacox
Copy link
Owner

Thanks for the contribution @cfoos !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants