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
Kubecost v1.85.0+ includes changes to support cAdvisor metrics without the container_name
rewrite rule.
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/
.
Last updated