Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased #151 with version bump #155

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords:
- kubecost
- opencost
- monitoring
version: 1.26.4
version: 1.27.0
maintainers:
- name: mattray
url: https://mattray.dev
Expand Down
12 changes: 8 additions & 4 deletions charts/opencost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

OpenCost and OpenCost UI

![Version: 1.26.4](https://img.shields.io/badge/Version-1.26.4-informational?style=flat-square)
![Version: 1.27.0](https://img.shields.io/badge/Version-1.27.0-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![AppVersion: 1.107.1](https://img.shields.io/badge/AppVersion-1.107.1-informational?style=flat-square)

Expand Down Expand Up @@ -30,6 +30,10 @@ $ helm install opencost opencost/opencost
| fullnameOverride | string | `""` | Overwrite all resources name created by the chart |
| imagePullSecrets | list | `[]` | List of secret names to use for pulling the images |
| nameOverride | string | `""` | Overwrite the default name of the chart |
| networkPolicies.enabled | bool | `false` | Whether network policies should be created |
| networkPolicies.prometheus.namespace | string | `"prometheus-system"` | Namespace where internal Prometheus is installed |
| networkPolicies.prometheus.port | int | `9090` | Pod port of in-cluster Prometheus |
| networkPolicies.prometheus.labels | object | `{ "app.kubernetes.io/name": "prometheus" }` | Label\(s\) used to identify the server Pod\(s\) relating to the internal Prometheus |
| opencost.affinity | object | `{}` | Affinity settings for pod assignment |
| opencost.customPricing.configPath | string | `"/tmp/custom-config"` | Path for the pricing configuration. |
| opencost.customPricing.configmapName | string | `"custom-pricing-model"` | Customize the configmap name used for custom pricing |
Expand Down Expand Up @@ -87,9 +91,9 @@ $ helm install opencost opencost/opencost
| opencost.prometheus.external.enabled | bool | `false` | Use external Prometheus (eg. Grafana Cloud) |
| opencost.prometheus.external.url | string | `"https://prometheus.example.com/prometheus"` | External Prometheus url |
| opencost.prometheus.internal.enabled | bool | `true` | Use in-cluster Prometheus |
| opencost.prometheus.internal.namespaceName | string | `"opencost"` | Namespace of in-cluster Prometheus |
| opencost.prometheus.internal.port | int | `9090` | Service port of in-cluster Prometheus |
| opencost.prometheus.internal.serviceName | string | `"my-prometheus"` | Service name of in-cluster Prometheus |
| opencost.prometheus.internal.namespaceName | string | `"prometheus-system"` | Namespace of in-cluster Prometheus |
| opencost.prometheus.internal.serviceName | string | `"prometheus-server"` | Service name of in-cluster Prometheus |
| opencost.prometheus.internal.port | int | `80` | Service port of in-cluster Prometheus |
| opencost.prometheus.password | string | `""` | Prometheus Basic auth password |
| opencost.prometheus.password_key | string | `"DB_BASIC_AUTH_PW"` | Key in the secret that references the password |
| opencost.prometheus.secret_name | string | `nil` | Secret name that contains credentials for Prometheus |
Expand Down
11 changes: 11 additions & 0 deletions charts/opencost/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,14 @@ Define opencost config file name
{{- .Values.opencost.customPricing.provider -}}
{{- end -}}
{{- end -}}

{{/*
Get api version of networking.k8s.io
*/}}
{{- define "networkingAPIVersion" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }}
apiVersion: networking.k8s.io/v1beta1
{{- end }}
{{- end -}}
46 changes: 46 additions & 0 deletions charts/opencost/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- $apiVersion := (include "networkingAPIVersion" .) }}
{{- if .Values.networkPolicies.enabled -}}
{{- if .Values.opencost.prometheus.internal.enabled }}
---
{{ $apiVersion }}
kind: NetworkPolicy
metadata:
name: {{ .Release.Name }}-opencost
namespace: {{ .Release.Namespace }}
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: opencost
policyTypes:
- Ingress
- Egress
ingress:
- from:
- podSelector:
matchLabels:
{{- range $key, $val := .Values.networkPolicies.prometheus.labels }}
{{ $key }}: {{ $val }}
{{- end }}
{{- if ne .Values.networkPolicies.prometheus.namespace .Release.Namespace }}
namespaceSelector:
matchLabels:
name: {{ .Values.networkPolicies.prometheus.namespace }}
{{- end }}
ports:
- port: 9003
egress:
- to:
- podSelector:
matchLabels:
{{- range $key, $val := .Values.networkPolicies.prometheus.labels }}
{{ $key }}: {{ $val }}
{{- end }}
{{- if ne .Values.networkPolicies.prometheus.namespace .Release.Namespace }}
namespaceSelector:
matchLabels:
name: {{ .Values.networkPolicies.prometheus.namespace }}
{{- end }}
ports:
- port: {{ .Values.networkPolicies.prometheus.port }}
{{- end }}
{{- end }}
21 changes: 18 additions & 3 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ serviceAccount:
# -- Whether pods running as this service account should have an API token automatically mounted
automountServiceAccountToken: true

# NetworkPolicies for ingress
networkPolicies:
# -- Specifies whether networkpolicies should be created
enabled: false

# -- Internal Prometheus settings related to NetworkPolicies
prometheus:
# -- Namespace where internal Prometheus is installed
namespace: prometheus-system
# -- Pod port of in-cluster Prometheus
port: 9090
# -- Labels applied to the Prometheus server pod(s)
labels:
app.kubernetes.io/name: prometheus

# -- Strategy to be used for the Deployment
updateStrategy:
rollingUpdate:
Expand Down Expand Up @@ -241,11 +256,11 @@ opencost:
# -- Use in-cluster Prometheus
enabled: true
# -- Service name of in-cluster Prometheus
serviceName: my-prometheus
serviceName: prometheus-server
# -- Namespace of in-cluster Prometheus
namespaceName: opencost
namespaceName: prometheus-system
# -- Service port of in-cluster Prometheus
port: 9090
port: 80
Comment on lines -248 to +263
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly reminder: This is a breaking change, and major version should have been bumped (with proper release notes).

amp:
# -- Use Amazon Managed Service for Prometheus (AMP)
enabled: false # If true, opencost will be configured to remote_write and query from Amazon Managed Service for Prometheus.
Expand Down