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

Add support for API Ingress #255

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions charts/opencost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ $ helm install opencost opencost/opencost
| opencost.customPricing.enabled | bool | `false` | Enables custom pricing configuration |
| opencost.customPricing.provider | string | `"custom"` | Sets the provider type for the custom pricing file. |
| opencost.dataRetention.dailyResolutionDays | int | `15` | |
| opencost.exporter.apiIngress.annotations | object | `{}` | Annotations for API Ingress resource |
| opencost.exporter.apiIngress.enabled | bool | `false` | Ingress for OpenCost API |
| opencost.exporter.apiIngress.hosts | list | See [values.yaml](values.yaml) | A list of host rules used to configure the API Ingress |
| opencost.exporter.apiIngress.ingressClassName | string | `""` | Ingress controller which implements the resource |
| opencost.exporter.apiIngress.servicePort | string | `"http"` | Redirect ingress to an extraPort defined on the service such as oauth-proxy |
| opencost.exporter.apiIngress.tls | list | `[]` | Ingress TLS configuration |
| opencost.exporter.apiPort | int | `9003` | |
| opencost.exporter.aws.access_key_id | string | `""` | AWS secret key id |
| opencost.exporter.aws.secret_access_key | string | `""` | AWS secret access key |
Expand Down
41 changes: 41 additions & 0 deletions charts/opencost/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,45 @@ spec:
name: {{ $.Values.opencost.ui.ingress.servicePort }}
{{- end }}
{{- end }}
{{- end }}
---
{{- if .Values.opencost.exporter.apiIngress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "opencost.fullname" . }}-apiIngress
namespace: {{ include "opencost.namespace" . }}
labels: {{- include "opencost.labels" . | nindent 4 }}
{{- with .Values.opencost.exporter.apiIngress.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.opencost.exporter.apiIngress.ingressClassName }}
ingressClassName: {{ . }}
{{- end }}
{{- if .Values.opencost.exporter.apiIngress.tls }}
tls:
{{- range .Values.opencost.exporter.apiIngress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.opencost.exporter.apiIngress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: Prefix
backend:
service:
name: {{ include "opencost.fullname" $ }}
port:
name: {{ $.Values.opencost.exporter.apiIngress.servicePort }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/opencost/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,28 @@ opencost:
# FOO: BAR
# For example, if accessing mimir directly and getting 401 Unauthorized
# PROMETHEUS_HEADER_X_SCOPE_ORGID: anonymous
apiIngress:
# -- Ingress for OpenCost API
enabled: false
# -- Ingress controller which implements the resource
ingressClassName: ""
# -- Annotations for Ingress resource
annotations: {}
# kubernetes.io/tls-acme: "true"
# -- A list of host rules used to configure the Ingress
# @default -- See [values.yaml](values.yaml)
hosts:
- host: example.local
paths:
- /
# -- Redirect ingress to an extraPort defined on the service such as oauth-proxy
servicePort: http
# servicePort: oauth-proxy
# -- Ingress TLS configuration
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
customPricing:
# -- Enables custom pricing configuration
enabled: false
Expand Down