-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[prometheus-opencost-exporter] new OpenCost Prometheus exporter chart (…
…#3872) * Initial commits Signed-off-by: Matt Ray <[email protected]> * Migrated over ServiceAccount from the opencost-helm-chart repo Signed-off-by: Matt Ray <[email protected]> * Imported ClusterRole and ClusterRoleBinding Signed-off-by: Matt Ray <[email protected]> * Add the Deployment from opencost-helm-chart Signed-off-by: Matt Ray <[email protected]> * Add the Service from opencost-helm-chart, edited for exporter-only Signed-off-by: Matt Ray <[email protected]> * Updated with recommendations from review and latest OpenCost release Signed-off-by: Matt Ray <[email protected]> * Updated to sync with upstream https://github.com/opencost/opencost-helm-chart Once that's merged it'll be the upstream to here. Signed-off-by: Matt Ray <[email protected]> * Updating the `home` field based on feedback and version bump Signed-off-by: Matt Ray <[email protected]> * fix url Signed-off-by: André Bauer <[email protected]> --------- Signed-off-by: Matt Ray <[email protected]> Signed-off-by: André Bauer <[email protected]> Co-authored-by: André Bauer <[email protected]>
- Loading branch information
Showing
11 changed files
with
670 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
appVersion: 1.107.1 | ||
version: 0.1.0 | ||
description: Prometheus OpenCost Exporter | ||
home: https://github.com/opencost/opencost | ||
name: prometheus-opencost-exporter | ||
sources: | ||
- https://github.com/prometheus-community/opencost_exporter | ||
apiVersion: v2 | ||
type: application | ||
keywords: | ||
- opencost | ||
- prometheus | ||
- exporter | ||
maintainers: | ||
- email: [email protected] | ||
name: mattray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Prometheus Opencost Exporter | ||
|
||
Prometheus exporter for [OpenCost](https://www.opencost.io) Kubernetes cost monitoring data. | ||
|
||
This chart bootstraps a Prometheus [OpenCost exporter](https://www.opencost.io/docs/integrations/opencost-exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. | ||
|
||
The original source for this Helm chart is <https://github.com/opencost/opencost-helm-chart>. | ||
|
||
## Prerequisites | ||
|
||
- Kubernetes 1.23+ | ||
- Helm 3+ | ||
|
||
## Add Helm Chart Repository | ||
|
||
```console | ||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | ||
helm repo update | ||
``` | ||
|
||
_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ | ||
|
||
## Install Chart | ||
|
||
```console | ||
helm install [RELEASE_NAME] prometheus-community/prometheus-opencost-exporter | ||
``` | ||
|
||
_See [configuration](#configuring) below._ | ||
|
||
_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ | ||
|
||
## Uninstall Chart | ||
|
||
```console | ||
helm uninstall [RELEASE_NAME] | ||
``` | ||
|
||
This removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ | ||
|
||
### Other minor version upgrade | ||
|
||
```console | ||
helm upgrade [RELEASE_NAME] [CHART] --install | ||
``` | ||
|
||
_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ | ||
|
||
## Configuring | ||
|
||
See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands: | ||
|
||
```console | ||
helm show values prometheus-community/prometheus-opencost-exporter | ||
``` |
99 changes: 99 additions & 0 deletions
99
charts/prometheus-opencost-exporter/templates/_helpers.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.labels" -}} | ||
helm.sh/chart: {{ include "prometheus-opencost-exporter.chart" . }} | ||
{{ include "prometheus-opencost-exporter.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "prometheus-opencost-exporter.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create -}} | ||
{{ default (include "prometheus-opencost-exporter.fullname" .) .Values.serviceAccount.name }} | ||
{{- else -}} | ||
{{ default "default" .Values.serviceAccount.name }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.prometheus.secretname" -}} | ||
{{- if .Values.opencost.prometheus.secret_name -}} | ||
{{- .Values.opencost.prometheus.secret_name -}} | ||
{{- else -}} | ||
{{- include "prometheus-opencost-exporter.fullname" . -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create the name of the controller service account to use | ||
*/}} | ||
{{- define "prometheus-opencost-exporter.prometheusServerEndpoint" -}} | ||
{{- if .Values.opencost.prometheus.external.enabled -}} | ||
{{ tpl .Values.opencost.prometheus.external.url . }} | ||
{{- else -}} | ||
{{- $host := tpl .Values.opencost.prometheus.internal.serviceName . }} | ||
{{- $ns := tpl .Values.opencost.prometheus.internal.namespaceName . }} | ||
{{- $port := .Values.opencost.prometheus.internal.port | int }} | ||
{{- printf "http://%s.%s.svc:%d" $host $ns $port -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
Check that either prometheus external or internal is defined | ||
*/}} | ||
{{- define "isPrometheusConfigValid" -}} | ||
{{- if and .Values.opencost.prometheus.external.enabled .Values.opencost.prometheus.internal.enabled -}} | ||
{{- fail "Only use one of the prometheus setups, internal or external" -}} | ||
{{- end -}} | ||
{{- end -}} |
79 changes: 79 additions & 0 deletions
79
charts/prometheus-opencost-exporter/templates/clusterrole.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Cluster role giving opencost to get, list, watch required resources | ||
# No write permissions are required | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "prometheus-opencost-exporter.fullname" . }} | ||
labels: {{- include "prometheus-opencost-exporter.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: [""] | ||
resources: | ||
- configmaps | ||
- deployments | ||
- nodes | ||
- pods | ||
- services | ||
- resourcequotas | ||
- replicationcontrollers | ||
- limitranges | ||
- persistentvolumeclaims | ||
- persistentvolumes | ||
- namespaces | ||
- endpoints | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- daemonsets | ||
- deployments | ||
- replicasets | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- statefulsets | ||
- deployments | ||
- daemonsets | ||
- replicasets | ||
verbs: | ||
- list | ||
- watch | ||
- apiGroups: | ||
- batch | ||
resources: | ||
- cronjobs | ||
- jobs | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- autoscaling | ||
resources: | ||
- horizontalpodautoscalers | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- policy | ||
resources: | ||
- poddisruptionbudgets | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- storage.k8s.io | ||
resources: | ||
- storageclasses | ||
verbs: | ||
- get | ||
- list | ||
- watch |
18 changes: 18 additions & 0 deletions
18
charts/prometheus-opencost-exporter/templates/clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{{- if .Values.rbac.enabled }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "prometheus-opencost-exporter.fullname" . }} | ||
labels: {{- include "prometheus-opencost-exporter.labels" . | nindent 4 }} | ||
{{- with .Values.annotations }} | ||
annotations: {{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ include "prometheus-opencost-exporter.fullname" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "prometheus-opencost-exporter.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
{{- end }} |
Oops, something went wrong.