-
Notifications
You must be signed in to change notification settings - Fork 519
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
Pricing Configmap watcher unable to open file #1760
Comments
@kirbsauce can we get this assigned for a repro? |
will do |
Also affected. Maybe it would be worth to invest some more time and split runtime config from config which is shipped inside the container image. I first thought that this issue happens in my environment due to that restriction. I then excluded the opencost Pod from the clusterwide policy, but the issue still exists. |
@aminatamoo and @mkilchhofer, how are you configuring the deployment to read your pricing-configs configmap? Based on this doc and this related issue, I get the impression the idea is to apply the configmap data as a JSON file and manually mount that file onto the pod. If I follow a similar format described in the issue I linked, I can get the pricing data mounted onto the pod. Another method to mount pricing-configs, however, is via the ConfigMapWatcher. When I try and use this method, I see the same error you are seeing. @AjayTripathy, would it be best to advise users to use the ConfigMapWatcher to generate a pricing config rather than having users mount the configmap via the deployment? I tested this on my cluster and could get it working if I passed the KUBECOST_NAMESPACE variable to correspond with my deployed "opencost" namespace. However, as mentioned before, I see the same:
when the container tries to update the deployed JSON file with the pricing-configs ConfigMap data. Is this a bug or not intended to be used within OpenCost? |
Thanks for investigating @keithhand .
Meanwhile, @aminatamoo @mkilchhofer have you tried to follow the docs listed by @keithhand ? |
Pretty sure the underlying issue is the baked in json files are being added as root prior to swapping to user 1001. So file mounts at that location fail since user 1001 doesn't have write access to them. It looks like /models can be overwritten with the env variable: CONFIG_PATH I suspect we can mount a configmap to a different spot and swap out the environment variable to point to them. I'll give it a quick shot and if that does the trick I can throw up a PR for the website. |
Just by putting a ConfigMap with the name I currently compare wether we need KubeCost or if OpenCost cover all our usecases. I dont want to have custom prices, but want to test the options available in KubeCost |
Hey @AjayTripathy, I originally took the approach that @mkilchhofer took and ran into this error so I pivoted to mounting the file onto the pod. I tried mounting to the models directory to overwrite the gcp.json config there but that didn't pick up any of the custom prices. I've now followed the instructions in the docs linked (mounting to
So I switched the file name to |
@aminatamoo I was able to override AWS prices following https://www.opencost.io/docs/on-prem#custom-pricing-using-the-opencost-helm-chart (substituting aws.json for default.json). I don't currently have a GCP cluster, but could you check this again? |
Same situation with |
I suspect it can be solved by changing opencost deployment apiVersion: apps/v1
kind: Deployment
metadata:
name: opencost
namespace: opencost
# ...
spec:
# ...
template:
# ...
spec:
# ...
securityContext:
fsGroup: 1001 # OpenCost is running as a non-root user, this gives container permission to write to the volume I'm not sure if opencost actually writes anything to the config file. Is it necessary to open the file in write mode for kubecost? |
@r2k1 It watches configmap and tries to update in file config if it changes. Your suggested change does not work. Exactly same error |
Could you please verify this is still an issue? We've had several updates to the Helm chart to support pricing via ConfigMap and I think this is fixed. |
I think that this still needs to be fixed. Even if you are not using custom pricing, but only a config like this:
Opencost tries to update the config file in
So, IMHO it would still be good not to edit the shipped files directly but copy them first and then edit those. Kind of the same way I did it in #2521 The reason for this would be the same: Allow read-only root filesystems. See: #2599 which should fix this. |
Describe the bug
Whilst attempting to customise pricing configurations by adding the
pricing-configs
configmap, I ran into the following error:To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the configmap watcher to populate /models/gcp.json.
Which version of OpenCost are you using?
latest (1.101.1)
Additional context
Kubernetes versions - 1.23
Public cloud - GCP (GKE)
The text was updated successfully, but these errors were encountered: