chore(k8s): start articles on costs control

This commit is contained in:
Michele Cereda
2025-06-24 00:59:53 +02:00
parent 77fd322c17
commit 45d73920b5
4 changed files with 182 additions and 1 deletions

View File

@@ -202,6 +202,7 @@
"knockd",
"kubeconfig",
"kubeconform",
"kubecost",
"kubectx",
"kubelet",
"kubens",
@@ -244,6 +245,7 @@
"oidc",
"omnia",
"ondemand",
"opencost",
"openmediavault",
"openpgp",
"openrc",

View File

@@ -0,0 +1,80 @@
# Kubecost
Monitoring application providing real-time cost visibility and insights.
1. [TL;DR](#tldr)
1. [Further readings](#further-readings)
1. [Sources](#sources)
## TL;DR
<details>
<summary>Setup</summary>
```sh
helm repo add 'kubecost' 'https://kubecost.github.io/cost-analyzer/' && helm repo update 'kubecost'
helm show values --repo 'https://kubecost.github.io/cost-analyzer/' 'cost-analyzer'
helm --namespace 'kubecost' upgrade --install 'kubecost' 'kubecost/cost-analyzer' --create-namespace
helm --namespace 'kubecost' upgrade --install 'kubecost' --create-namespace \
--repo 'https://kubecost.github.io/cost-analyzer/' 'cost-analyzer' \
--set 'persistentVolume.enabled=false'
# EKS-specific
VERSION='' \
helm --namespace 'kubecost' upgrade --install 'kubecost' --create-namespace \
'oci://public.ecr.aws/kubecost/cost-analyzer' --version "$VERSION" \
--values "https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/$VERSION/cost-analyzer/values-eks-cost-monitoring.yaml"
helm --namespace 'kubecost' uninstall 'kubecost' \
&& kubectl delete namespace 'kubecost'
```
</details>
<details>
<summary>Usage</summary>
```sh
kubectl --namespace 'kubecost' port-forward 'svc/kubecost-cost-analyzer' '9090' \
&& open 'http://localhost:9090'
```
</details>
<!-- Uncomment if used
<details>
<summary>Real world use cases</summary>
```sh
```
</details>
-->
## Further readings
- [Website]
- [Codebase]
### Sources
- [Documentation]
- [Amazon EKS Integration]
<!--
Reference
═╬═Time══
-->
<!-- In-article sections -->
<!-- Knowledge base -->
<!-- Files -->
<!-- Upstream -->
[Amazon EKS Integration]: https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installations-amazon-eks-integration
[codebase]: https://github.com/kubecost
[documentation]: https://github.com/kubecost/docs
[website]: https://www.kubecost.com/
<!-- Others -->

View File

@@ -0,0 +1,92 @@
# OpenCost
Monitoring application providing real-time cost visibility and insights.
1. [TL;DR](#tldr)
1. [Further readings](#further-readings)
1. [Sources](#sources)
## TL;DR
<details>
<summary>Setup</summary>
Requires:
- A [Prometheus] instance to be available.
> [!caution]
> OpenCost's pods **will** error out and go in CrashLoopBackoff if it cannot connect to Prometheus.<br/>
> See the Helm chart values at `opencost.prometheus` to configure that connection.
- The above Prometheus instance to have a scrape target configured for OpenCost.<br/>
See [OpenCost extraScrapeConfigs for Prometheus].
```sh
helm repo add 'opencost' 'https://opencost.github.io/opencost-helm-chart' && helm repo update 'opencost'
helm search repo 'opencost/opencost' --versions
helm show values --repo 'https://opencost.github.io/opencost-helm-chart' 'opencost'
helm --namespace 'opencost' upgrade --install 'opencost' 'opencost/opencost' --create-namespace
helm --namespace 'opencost' upgrade --install 'opencost' --create-namespace \
--repo 'https://opencost.github.io/opencost-helm-chart' 'opencost' \
--set 'opencost.prometheus.internal.namespaceName=prometheus'
helm --namespace 'opencost' uninstall 'opencost' \
&& kubectl delete namespace 'opencost'
```
</details>
<details>
<summary>Usage</summary>
```sh
kubectl --namespace 'opencost' port-forward 'service/opencost' '9003' '9090'
curl 'http://localhost:9003/allocation/compute?window=60m' \
open 'http://localhost:9090'
```
</details>
<!-- Uncomment if used
<details>
<summary>Real world use cases</summary>
```sh
```
</details>
-->
## Further readings
- [Website]
- [Codebase]
### Sources
- [Documentation]
- [Amazon EKS Integration]
- [helm chart]
<!--
Reference
═╬═Time══
-->
<!-- In-article sections -->
<!-- Knowledge base -->
[Prometheus]: ../prometheus/README.md
<!-- Files -->
<!-- Upstream -->
[Amazon EKS Integration]: https://www.ibm.com/docs/en/kubecost/self-hosted/2.x?topic=installations-amazon-eks-integration
[codebase]: https://github.com/opencost/opencost
[documentation]: https://opencost.io/docs/
[helm chart]: https://github.com/opencost/opencost-helm-chart/
[website]: https://opencost.io/
[OpenCost extraScrapeConfigs for Prometheus]: https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
<!-- Others -->

View File

@@ -55,10 +55,17 @@ docker run -p '9090:9090' -v "$PWD/config/dir:/etc/prometheus" -v 'prometheus-da
helm repo add 'prometheus-community' 'https://prometheus-community.github.io/helm-charts' \
&& helm repo update 'prometheus-community'
helm show values 'prometheus-community/prometheus'
helm -n 'prometheus' upgrade -i --create-namespace 'prometheus' 'prometheus-community/prometheus'
helm --namespace 'prometheus' upgrade --install --create-namespace 'prometheus' 'prometheus-community/prometheus'
helm --namespace 'prometheus' upgrade --install --create-namespace 'prometheus' \
--repo 'https://prometheus-community.github.io/helm-charts' 'prometheus' \
--set 'prometheus-pushgateway.enabled=false' --set 'alertmanager.enabled=false' \
--set 'server.persistentVolume.enabled=false'
kubectl -n 'prometheus' get pods -l 'app.kubernetes.io/name=prometheus,app.kubernetes.io/instance=prometheus' \
-o jsonpath='{.items[0].metadata.name}' \
| xargs -I '%%' kubectl -n 'prometheus' port-forward "%%" '9090'
helm --namespace 'prometheus' uninstall 'prometheus'
```