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 Parquet-Exporter helm chart #195

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
24 changes: 24 additions & 0 deletions charts/parquet-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: parquet-exporter
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we make this "opencost-parquet-exporter"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That will have a ripple effect in the templates, but I prefer the verbosity/specificity

description: A Helm chart for Kubernetes
Copy link
Collaborator

Choose a reason for hiding this comment

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

"OpenCost Parquet Exporter"


# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
38 changes: 38 additions & 0 deletions charts/parquet-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# parquet-exporter
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we make the title and the path charts/opencost-parquet-exporter to match the repository?


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

A Helm chart for Kubernetes

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| activeDeadlineSeconds | int | `3600` | Keep job runnig (from start time) for [activeDeadlineSeconds] |
Copy link
Collaborator

Choose a reason for hiding this comment

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

"running"

| awsRolename | string | `"testrole"` | AWS IAM role to use when writing to the S3 Bucket. |
| concurrencyPolicy | string | `"Forbid"` | Do not allow multiple runs |
| dnsConfig | object | `{"options":[{"name":"single-request-reopen"},{"name":"ndots","value":"2"}]}` | Specific DNS parameters of the pod |
| dnsConfig.options[0] | object | `{"name":"single-request-reopen"}` | Turning this option on [...] so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request. See also "[single-request-reopen](https://man7.org/linux/man-pages/man5/resolv.conf.5.html)" |
| dnsConfig.options[1] | object | `{"name":"ndots","value":"2"}` | Sets a threshold for the number of dots which must appear in a name [...] before an initial absolute query will be made. . See also "[ndots](https://man7.org/linux/man-pages/man5/resolv.conf.5.html)" |
| dnsPolicy | string | `"ClusterFirst"` | A pod's [DNS polics](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy) |
| env | list | `[{"name":"AWS_REGION","value":"us-west-2"},{"name":"KUBE_CLUSTER","value":"YOUR_CLUSTER_NAME_CHANGE_ME"},{"name":"OPENCOST_PARQUET_FILE_KEY_PREFIX","value":"cluster=$(KUBE_CLUSTER)"},{"name":"OPENCOST_PARQUET_S3_BUCKET","value":"YOUR_S3_BUCKET_NAME_CHANGE_ME"},{"name":"OPENCOST_PARQUET_S3_REGION","value":"YOUR_S3_BUCKET_REGION_NAME_CHANGE_ME"},{"name":"OPENCOST_PARQUET_SVC_HOSTNAME","value":"opencost.opencost.svc.cluster.local."},{"name":"OPENCOST_PARQUET_SVC_PORT","value":"9003"}]` | List of env vars |
| envFrom | string | `nil` | |
| failedJobsHistoryLimit | int | `3` | Keep up to three failed jobs |
| image.imagePullPolicy | string | `"Always"` | |
| image.repository | string | `"ghcr.io/opencost/opencost-parquet-exporter"` | |
| image.tag | string | `"latest"` | |
| resources | object | `{"limits":{"cpu":2,"memory":"5Gi"},"requests":{"cpu":1,"memory":"1Gi"}}` | Compute resources required |
| restartPolicy | string | `"Never"` | |
| schedule | string | `"* * * * *"` | Schedule on which to run the cron job |
| securityContext.capabilities.drop[0] | string | `"ALL"` | |
| securityContext.readOnlyRootFilesystem | bool | `true` | |
| securityContext.runAsNonRoot | bool | `true` | |
| securityContext.runAsUser | int | `1001` | |
| serviceAccount | object | `{"name":"opencost"}` | ServiceAccount use to run this pod |
| successfulJobsHistoryLimit | int | `3` | Keep up to three successful jobs |
| suspend | bool | `false` | |
| terminationGracePeriodSeconds | int | `30` | |
| ttlSecondsAfterFinished | int | `14400` | Limit the lifetime of the execution |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
8 changes: 8 additions & 0 deletions charts/parquet-exporter/templates/_annotations.tpl
Copy link
Contributor

Choose a reason for hiding this comment

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

add new line at the end

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{/*
Common labels
*/}}
{{- define "parquet-exporter.annotations" -}}
{{- if .Values.awsRolename }}
iam.amazonaws.com/role: {{ .Values.awsRolename }}
{{- end }}
{{- end }}
51 changes: 51 additions & 0 deletions charts/parquet-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "parquet-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 "parquet-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 "parquet-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "parquet-exporter.labels" -}}
helm.sh/chart: {{ include "parquet-exporter.chart" . }}
{{ include "parquet-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "parquet-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "parquet-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
73 changes: 73 additions & 0 deletions charts/parquet-exporter/templates/cronjob.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

add new line at the end

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "parquet-exporter.name" $ }}
annotations:
{{- include "parquet-exporter.annotations" $ | indent 4 }}
labels:
{{ include "parquet-exporter.labels" . | indent 4 }}
spec:
concurrencyPolicy: {{ .Values.concurrencyPolicy | quote}}
failedJobsHistoryLimit: {{ .Values.failedJobsHistoryLimit }}
schedule: {{ .Values.schedule | quote}}
successfulJobsHistoryLimit: {{ .Values.successfulJobsHistoryLimit }}
suspend: {{ .Values.suspend }}
jobTemplate:
metadata:
name: {{ include "parquet-exporter.name" $ }}
spec:
activeDeadlineSeconds: {{ .Values.activeDeadlineSeconds }}
ttlSecondsAfterFinished: {{ .Values.ttlSecondsAfterFinished }}
backoffLimit: 3
template:
metadata:
annotations:
{{- include "parquet-exporter.annotations" $ | indent 12 }}
labels:
{{ include "parquet-exporter.labels" . | indent 12 }}
name: {{ include "parquet-exporter.name" $ }}
spec:
{{- if .Values.imagePullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if and (hasKey .Values "serviceAccount") (hasKey .Values.serviceAccount "name") }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- end }}
{{- if hasKey .Values "securityContext" }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- else}}
securityContext: {}
{{- end }}
containers:
- image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.imagePullPolicy }}
name: {{ include "parquet-exporter.name" $ }}
{{- with .Values.resources }}
resources:
{{ toYaml . | indent 16 }}
{{- end }}
{{- with .Values.env }}
env:
{{ toYaml . | indent 16 }}
{{- end }}
{{- with .Values.envFrom }}
envFrom:
{{ toYaml . | indent 16 }}
{{- end }}
{{- with .Values.dnsConfig }}
dnsConfig:
{{ toYaml . | indent 12 }}
{{- end }}
{{- if .Values.dnsPolicy}}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- end }}
restartPolicy: {{ .Values.restartPolicy }}
{{- if .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds}}
{{- end }}
66 changes: 66 additions & 0 deletions charts/parquet-exporter/values.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

add new line at the end

Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# -- AWS IAM role to use when writing to the S3 Bucket.
awsRolename: testrole
# -- Do not allow multiple runs
concurrencyPolicy: Forbid
# -- Keep up to three failed jobs
failedJobsHistoryLimit: 3
# -- Schedule on which to run the cron job
schedule: "* * * * *"
# -- Keep up to three successful jobs
successfulJobsHistoryLimit: 3
suspend: false
# -- Keep job runnig (from start time) for [activeDeadlineSeconds]
activeDeadlineSeconds: 3600
# -- Limit the lifetime of the execution
ttlSecondsAfterFinished: 14400
# -- ServiceAccount use to run this pod
serviceAccount:
name: opencost
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the exporter depend on the opencost service account? I couldn't find something related to this in the exporters repo README.md.

Copy link
Author

@cklingspor cklingspor Apr 12, 2024

Choose a reason for hiding this comment

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

I took that over from @lmello 's code. I have not looked into the actual requirements for the AWS S3 integration but I have to assume that its there for this purpose. Also it is not required to interact with the opencost application.
The service account key/value pair is optional however. Would you rather have me remove it from the values yaml or adjust the description to state that its an optional parameter`

Copy link
Contributor

Choose a reason for hiding this comment

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

If the service account is not required, I would leave it empty. Maybe also change the key to existingServiceAccount? Otherwise I would assume that it creates the service account by itself.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you. Ill change accordingly!

securityContext:
runAsUser: 1001
readOnlyRootFilesystem: true
runAsNonRoot: true
capabilities:
drop:
- ALL
image:
repository: ghcr.io/opencost/opencost-parquet-exporter
tag: main@sha256:29a5d8e7fb4af97c93f91b4d29872512d93080f88303047ff31cd3b263b48e4f
imagePullPolicy: Always
# -- List of env vars
env:
- name: AWS_REGION
value: us-west-2
- name: KUBE_CLUSTER
value: YOUR_CLUSTER_NAME_CHANGE_ME
- name: OPENCOST_PARQUET_FILE_KEY_PREFIX
value: cluster=$(KUBE_CLUSTER)
- name: OPENCOST_PARQUET_S3_BUCKET
value: YOUR_S3_BUCKET_NAME_CHANGE_ME
- name: OPENCOST_PARQUET_S3_REGION
value: YOUR_S3_BUCKET_REGION_NAME_CHANGE_ME
- name: OPENCOST_PARQUET_SVC_HOSTNAME
value: opencost.opencost.svc.cluster.local.
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there supposed to be a trailing "."?

- name: OPENCOST_PARQUET_SVC_PORT
value: "9003"
envFrom:
# -- Compute resources required
resources:
limits:
cpu: 2
memory: 5Gi
requests:
cpu: 1
memory: 1Gi
# -- Specific DNS parameters of the pod
dnsConfig:
options:
# -- Turning this option on [...] so that if two requests from the same port are not handled correctly it will close the socket and open a new one before sending the second request. See also "[single-request-reopen](https://man7.org/linux/man-pages/man5/resolv.conf.5.html)"
- name: single-request-reopen
# -- Sets a threshold for the number of dots which must appear in a name [...] before an initial absolute query will be made. . See also "[ndots](https://man7.org/linux/man-pages/man5/resolv.conf.5.html)"
- name: ndots
value: "2"
# -- A pod's [DNS polics](https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy)
dnsPolicy: ClusterFirst
restartPolicy: Never
terminationGracePeriodSeconds: 30