Skip to content

Commit

Permalink
feat: adding namespace override (#171)
Browse files Browse the repository at this point in the history
* feat: adding namespace override

Signed-off-by: Rafael Brito <[email protected]>

* Version bump and README update

Signed-off-by: Matt Ray <[email protected]>

---------

Signed-off-by: Rafael Brito <[email protected]>
Signed-off-by: Matt Ray <[email protected]>
Co-authored-by: Matt Ray <[email protected]>
  • Loading branch information
brito-rafa and mattray authored Jan 16, 2024
1 parent c6eaa8f commit 28e114a
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| mattray | [email protected] | <https://mattray.dev> |
| toscott | |
| brito-rafa | |
| Name |
| ---- |
| mattray |
| toscott |
| brito-rafa |

## Usage

Expand Down
4 changes: 2 additions & 2 deletions charts/opencost/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ keywords:
- kubecost
- opencost
- monitoring
version: 1.28.3
version: 1.29.0
maintainers:
- name: mattray
url: https://mattray.dev
- name: toscott
- name: brito-rafa
home: https://github.com/opencost/opencost-helm-chart
2 changes: 1 addition & 1 deletion 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.28.2](https://img.shields.io/badge/Version-1.28.2-informational?style=flat-square)
![Version: 1.29.0](https://img.shields.io/badge/Version-1.29.0-informational?style=flat-square)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![AppVersion: 1.108.0](https://img.shields.io/badge/AppVersion-1.108.0-informational?style=flat-square)

Expand Down
23 changes: 21 additions & 2 deletions charts/opencost/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,31 @@

## Installing the Chart

To install the chart with the release name `opencost`:
To install the chart with the release name `opencost` on `opencost` namespace:

```console
$ helm install opencost opencost/{{ template "chart.name" . }}
$ helm install opencost opencost/{{ template "chart.name" . }} --namespace opencost --create-namespace
```

In order to have a working opencost installation, you need to provide one running instance of Prometheus.
The following will install a prometheus instance on the namespace `prometheus-system`, where the default helm chart is expecting:

```
helm install prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \
--namespace prometheus-system --create-namespace \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
-f https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yaml
```

During installation, you can specify the following parameters if you have your own internal Prometheus:

```
`--set opencost.prometheus.internal.namespace=<your-namespace>`
`--set opencost.prometheus.internal.service=<your-service>`
```


{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
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 @@ -30,6 +30,17 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}
{{- end -}}

{{/*
Allow the release namespace to be overridden
*/}}
{{- define "opencost.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- 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).
Expand Down
2 changes: 1 addition & 1 deletion charts/opencost/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ roleRef:
subjects:
- kind: ServiceAccount
name: {{ template "opencost.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
namespace: {{ include "opencost.namespace" . }}
{{- end }}
1 change: 1 addition & 0 deletions charts/opencost/templates/configmap-custom-pricing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.opencost.customPricing.configmapName }}
namespace: {{ include "opencost.namespace" . }}
data:
{{ include "opencost.configFileName" . }}.json: |-
{
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "opencost.fullname" . }}
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "opencost.fullname" . }}-ingress
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.opencost.ui.ingress.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/opencost/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
kind: NetworkPolicy
metadata:
name: {{ .Release.Name }}-opencost
namespace: {{ .Release.Namespace }}
namespace: {{ include "opencost.namespace" . }}
spec:
podSelector:
matchLabels:
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "opencost.fullname" . }}-pvc
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.opencost.exporter.persistence.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: {{ include "opencost.prometheus.secretname" . }}
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.secretAnnotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ include "opencost.fullname" . }}
namespace: {{ include "opencost.namespace" . }}
labels:
{{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
Expand Down
1 change: 1 addition & 0 deletions charts/opencost/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "opencost.serviceAccountName" . }}
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
nameOverride: ""
# -- Overwrite all resources name created by the chart
fullnameOverride: ""
# -- Override the deployment namespace
namespaceOverride: ""

# -- List of secret names to use for pulling the images
imagePullSecrets: []
Expand Down

0 comments on commit 28e114a

Please sign in to comment.