Comments (10)
Hi @pierluigilenoci. That's an interesting error to get, it looks like your flags are correct. It may be an issue with your network configuration in Kubernetes. Can you try the following, and let me know what happens? It may help us debug this problem.
kubectl proxy --port 8080
curl -G 'http://localhost:8080/api/v1/namespaces/k8s-kubecost/services/cost-analyzer-cost-analyzer:tcp-model/proxy/getConfigs'
kubectl cost
uses the Kubernetes API server to proxy a request to Kubecost. If you have a restrictive firewalling or other network security policy, running this command may surface that.
from kubectl-cost.
curl -G 'http://localhost:8080/api/v1/namespaces/k8s-kubecost/services/cost-
analyzer-cost-analyzer:tcp-model/proxy/getConfigs'
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {
},
"status": "Failure",
"message": "error trying to reach service: dial tcp [REDACTED]:9003: i/o timeout",
"code": 500
}
We have network policies in place. Ref: kubecost/cost-analyzer-helm-chart#743
from kubectl-cost.
Okay, not surprising if you have restrictive network policies in place. I'm unfamiliar with your setup and so cannot provide a recommendation. Allowing API servers to access the Kubecost API is a bit sketchy if you're worried about this kind of behavior in your cluster and have implemented policies preventing it.
This is a tricky situation to handle. The most robust, "behaves like kubectl
" method I can think of is to manage a port-forward
on the user's behalf while kubectl cost
is running, but I can see many pitfalls there. As a short-term workaround, we could also modify kubectl cost
only slightly to allow you to provide a URL to your Kubecost deployment to override this proxying behavior. Would the latter option satisfy your needs in the short-term?
from kubectl-cost.
@michaelmdresser my setup is quite simple:
A deny all policy inside the Kubecost namespace:
---
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: deny-all-ingress-traffic
namespace: k8s-kubecost
spec:
podSelector: {}
policyTypes:
- Ingress
and this configuration for the Kubecost chart:
networkPolicy:
enabled: true
denyEgress: false
sameNamespace: false
namespace: k8s-kubecost
I believe that it is the basic setup of anyone who implements Network Policy: close everything and open only what is needed.
I would have expected that the networkPolicy
option would have created something working for the kubectl plugin to work as well.
It's my opinion that finding workarounds to make everything work in an installation that should in fact be a standard is not a solution that satisfies me.
What do you think about it?
from kubectl-cost.
Naturally, a deny all ingress to the k8s-kubecost
namespace will cause the current approach to fail. I understand what you want and how to address it. We can use client-go to port forward in code and maintain a session for the duration of the program. This is certainly a more robust approach. We will prioritize it, but of course contributions are welcome if you'd like to jump on it sooner @pierluigilenoci 😁.
References:
- in client-go: https://github.com/kubernetes/client-go/blob/master/tools/portforward/portforward.go
- blog post using this functionality: https://gianarb.it/blog/programmatically-kube-port-forward-in-go
from kubectl-cost.
Addressing in #80
from kubectl-cost.
With #80 merged and v0.2.0
released. I expect kubectl cost
to work for you now. Please give it a try and let me know how it goes.
from kubectl-cost.
Sorry, we'll need to merge #82 and make a new release for this to work fully. I'll update you when that's done.
from kubectl-cost.
v0.2.1
is out and will hopefully have resolved this problem. Let me know how it goes.
from kubectl-cost.
Works perfectly, thank you a lot! ❤️
from kubectl-cost.
Related Issues (20)
- Error: GLIBC not found HOT 7
- Feature Request: kubectl cost prices HOT 4
- some label queries don't work HOT 6
- The logs report didn't get PVC pricing in Alicloud
- predict method not allowed on 1.102 HOT 8
- Disregard
- Predict command is not working through proxy HOT 2
- Add `--opencost` flag to specify standard OpenCost settings HOT 3
- [Feature Request] Give users ability to use kubectl cost functionality without having to escalate privlages. HOT 1
- Security Slam 2023 Participation HOT 1
- Support request ro HTTPS oauth proxy sidecar HOT 1
- A potential risk of kubecost makes a worker node get the token of any Service Account HOT 2
- [FR/BUG] Show __idle__ costs (again) using OpenCost HOT 4
- OpenCost dependency is old HOT 1
- Update used libraries to mitigate CVE scanners HOT 2
- cost-model container is running and responding to the healthz endpoint, but the response is empty. HOT 2
- Broken docs link.... HOT 5
- kubecost cost cli predict fails on 2.2.x HOT 1
- Building kubecost fails due to go1.16 being used in go.mod HOT 3
- kubectl cost predict -f test.yaml Not working HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubectl-cost.