Skip to content

Commit 5c52a24

Browse files
Add support for API Ingress (#255)
* Add support for API Ingress * Apply suggestions from code review Co-authored-by: Theis Ferré Hjortkjær <theisferre@gmail.com> Signed-off-by: Joseph Teddick <43552317+josephteddick@users.noreply.github.com> * Update Chart patch Signed-off-by: Joseph Teddick <43552317+josephteddick@users.noreply.github.com> --------- Signed-off-by: Joseph Teddick <43552317+josephteddick@users.noreply.github.com> Co-authored-by: Theis Ferré Hjortkjær <theisferre@gmail.com>
1 parent 4ce85b8 commit 5c52a24

File tree

4 files changed

+71
-1
lines changed

4 files changed

+71
-1
lines changed

charts/opencost/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords:
99
- finops
1010
- monitoring
1111
- opencost
12-
version: 2.1.1
12+
version: 2.1.2
1313
maintainers:
1414
- name: jessegoodier
1515
- name: toscott

charts/opencost/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ $ helm install opencost opencost/opencost
4848
| opencost.customPricing.enabled | bool | `false` | Enables custom pricing configuration |
4949
| opencost.customPricing.provider | string | `"custom"` | Sets the provider type for the custom pricing file. |
5050
| opencost.dataRetention.dailyResolutionDays | int | `15` | |
51+
| opencost.exporter.apiIngress.annotations | object | `{}` | Annotations for API Ingress resource |
52+
| opencost.exporter.apiIngress.enabled | bool | `false` | Ingress for OpenCost API |
53+
| opencost.exporter.apiIngress.hosts | list | See [values.yaml](values.yaml) | A list of host rules used to configure the API Ingress |
54+
| opencost.exporter.apiIngress.ingressClassName | string | `""` | Ingress controller which implements the resource |
55+
| opencost.exporter.apiIngress.servicePort | string | `"http"` | Redirect ingress to an extraPort defined on the service such as oauth-proxy |
56+
| opencost.exporter.apiIngress.tls | list | `[]` | Ingress TLS configuration |
5157
| opencost.exporter.apiPort | int | `9003` | |
5258
| opencost.exporter.aws.access_key_id | string | `""` | AWS secret key id |
5359
| opencost.exporter.aws.secret_access_key | string | `""` | AWS secret access key |

charts/opencost/templates/ingress.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,45 @@ spec:
3737
name: {{ $.Values.opencost.ui.ingress.servicePort }}
3838
{{- end }}
3939
{{- end }}
40+
{{- end }}
41+
---
42+
{{- if .Values.opencost.exporter.apiIngress.enabled }}
43+
apiVersion: networking.k8s.io/v1
44+
kind: Ingress
45+
metadata:
46+
name: {{ include "opencost.fullname" . }}-api-ingress
47+
namespace: {{ include "opencost.namespace" . }}
48+
labels: {{- include "opencost.labels" . | nindent 4 }}
49+
{{- with .Values.opencost.exporter.apiIngress.annotations }}
50+
annotations: {{- toYaml . | nindent 4 }}
51+
{{- end }}
52+
spec:
53+
{{- with .Values.opencost.exporter.apiIngress.ingressClassName }}
54+
ingressClassName: {{ . }}
55+
{{- end }}
56+
{{- if .Values.opencost.exporter.apiIngress.tls }}
57+
tls:
58+
{{- range .Values.opencost.exporter.apiIngress.tls }}
59+
- hosts:
60+
{{- range .hosts }}
61+
- {{ . | quote }}
62+
{{- end }}
63+
secretName: {{ .secretName }}
64+
{{- end }}
65+
{{- end }}
66+
rules:
67+
{{- range .Values.opencost.exporter.apiIngress.hosts }}
68+
- host: {{ .host | quote }}
69+
http:
70+
paths:
71+
{{- range .paths }}
72+
- path: {{ .path }}
73+
pathType: {{ .pathType }}
74+
backend:
75+
service:
76+
name: {{ include "opencost.fullname" $ }}
77+
port:
78+
name: {{ $.Values.opencost.exporter.apiIngress.servicePort }}
79+
{{- end }}
80+
{{- end }}
4081
{{- end }}

charts/opencost/values.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,29 @@ opencost:
223223
# FOO: BAR
224224
# For example, if accessing mimir directly and getting 401 Unauthorized
225225
# PROMETHEUS_HEADER_X_SCOPE_ORGID: anonymous
226+
apiIngress:
227+
# -- Ingress for OpenCost API
228+
enabled: false
229+
# -- Ingress controller which implements the resource
230+
ingressClassName: ""
231+
# -- Annotations for Ingress resource
232+
annotations: {}
233+
# kubernetes.io/tls-acme: "true"
234+
# -- A list of host rules used to configure the Ingress
235+
# @default -- See [values.yaml](values.yaml)
236+
hosts:
237+
- host: example.local
238+
paths:
239+
- path: /
240+
pathType: Prefix
241+
# -- Redirect ingress to an extraPort defined on the service such as oauth-proxy
242+
servicePort: http
243+
# servicePort: oauth-proxy
244+
# -- Ingress TLS configuration
245+
tls: []
246+
# - secretName: chart-example-tls
247+
# hosts:
248+
# - chart-example.local
226249
customPricing:
227250
# -- Enables custom pricing configuration
228251
enabled: false

0 commit comments

Comments
 (0)