Installation Kubecost with Istio (Rancher)
The following requirements are given:
Rancher with default monitoring
Use of an existing Prometheus and Grafana (Kubecost will be installed without Prometheus and Grafana)
Istio with gateway and sidecar for deployments
Activation of Istio
Istio is activated by editing the namespace. To do this, execute the command
kubectl edit namespace kubecost
and insert the labelistio-injection: enabled
After Istio has been activated, some adjustments must be made to the deployment with
kubectl -n kubecost edit deployment kubecost-cost-analyzer
to allow communication within the namespace. For example, the healtch-check is completed successfully. When editing the deployment, the two annotations must be added:
Authorization polices
An authorization policy governs access restrictions in namespaces and specifies how resources within a namespace are allowed to access it.
ap-ingress: communication with Istio
ap-intern: communication with Kubecost
ap-extern: as a port share (9003) for communication from Prometheus (namespace "cattle-monitoring-system") to Kubecost (namespace "kubecost")
Peer Authentication
Peer authentication is used to set how traffic is tunneled to the Istio sidecar. In the example, enforcing TLS is disabled so that Prometheus can grab the metrics from Kubecost (if this action is not performed, it returns at HTTP 503 error).
pa-default.yaml
Destination Rule
A destination rule is used to specify how traffic should be handled after routing to a service. In my case, TLS is disabled for connections from Kubecost to Prometheus and Grafana (namespace "cattle-monitoring-system").
dr-prometheus.yaml
dr-grafana.yaml
Virtual Service
A virtual service is used to direct data traffic specifically to individual services within the service mesh. The virtual service defines how the routing should run. A gateway is required for a virtual service.
vs-kubecost.yaml
After creating the virtual service, Kubecost should be accessible at the URL http(s)://${gateway}/kubecost/
.
Troubleshooting
Kubecost is displaying excessively high cost metrics in the billions
Setting the Helm flag customPricesEnabled
to true
, or enabling Custom Pricing through the UI has been shown to fix an error where Rancher clusters displayed absurdly high cost metrics.
Last updated