diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/charts/opencost-parquet-exporter/Chart.yaml b/charts/opencost-parquet-exporter/Chart.yaml new file mode 100644 index 0000000..e7edb14 --- /dev/null +++ b/charts/opencost-parquet-exporter/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: opencost-parquet-exporter +description: 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" diff --git a/charts/opencost-parquet-exporter/README.md b/charts/opencost-parquet-exporter/README.md new file mode 100644 index 0000000..9e49acc --- /dev/null +++ b/charts/opencost-parquet-exporter/README.md @@ -0,0 +1,38 @@ +# opencost-parquet-exporter + +![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) + +OpenCost Parquet Exporter + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| activeDeadlineSeconds | int | `3600` | Keep job running (from start time) for [activeDeadlineSeconds] | +| 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` | | +| existingServiceAccount | string | `nil` | Optional ServiceAccount use to run this pod | +| 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 | `"main"` | | +| 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` | | +| 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) diff --git a/charts/opencost-parquet-exporter/templates/_annotations.tpl b/charts/opencost-parquet-exporter/templates/_annotations.tpl new file mode 100644 index 0000000..874aa38 --- /dev/null +++ b/charts/opencost-parquet-exporter/templates/_annotations.tpl @@ -0,0 +1,8 @@ +{{/* +Common labels +*/}} +{{- define "parquet-exporter.annotations" -}} +{{- if .Values.awsRolename }} +iam.amazonaws.com/role: {{ .Values.awsRolename }} +{{- end }} +{{- end }} diff --git a/charts/opencost-parquet-exporter/templates/_helpers.tpl b/charts/opencost-parquet-exporter/templates/_helpers.tpl new file mode 100644 index 0000000..ec8b31b --- /dev/null +++ b/charts/opencost-parquet-exporter/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "opencost-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 "opencost-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 "opencost-parquet-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "opencost-parquet-exporter.labels" -}} +helm.sh/chart: {{ include "opencost-parquet-exporter.chart" . }} +{{ include "opencost-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 "opencost-parquet-exporter.selectorLabels" -}} +app.kubernetes.io/name: {{ include "opencost-parquet-exporter.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/opencost-parquet-exporter/templates/cronjob.yaml b/charts/opencost-parquet-exporter/templates/cronjob.yaml new file mode 100644 index 0000000..246c86f --- /dev/null +++ b/charts/opencost-parquet-exporter/templates/cronjob.yaml @@ -0,0 +1,73 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "opencost-parquet-exporter.name" $ }} + annotations: +{{- include "parquet-exporter.annotations" $ | indent 4 }} + labels: +{{ include "opencost-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 "opencost-parquet-exporter.name" $ }} + spec: + activeDeadlineSeconds: {{ .Values.activeDeadlineSeconds }} + ttlSecondsAfterFinished: {{ .Values.ttlSecondsAfterFinished }} + backoffLimit: 3 + template: + metadata: + annotations: + {{- include "parquet-exporter.annotations" $ | indent 12 }} + labels: +{{ include "opencost-parquet-exporter.labels" . | indent 12 }} + name: {{ include "opencost-parquet-exporter.name" $ }} + spec: + {{- if .Values.imagePullSecrets }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: +{{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} + {{- if not ( .Values.existingServiceAccount | empty ) }} + serviceAccountName: {{ .Values.existingServiceAccount }} + {{- 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 "opencost-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 }} diff --git a/charts/opencost-parquet-exporter/values.yaml b/charts/opencost-parquet-exporter/values.yaml new file mode 100644 index 0000000..e5bccee --- /dev/null +++ b/charts/opencost-parquet-exporter/values.yaml @@ -0,0 +1,65 @@ +# -- 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 running (from start time) for [activeDeadlineSeconds] +activeDeadlineSeconds: 3600 +# -- Limit the lifetime of the execution +ttlSecondsAfterFinished: 14400 +# -- Optional ServiceAccount use to run this pod +existingServiceAccount: +securityContext: + runAsUser: 1001 + readOnlyRootFilesystem: true + runAsNonRoot: true + capabilities: + drop: + - ALL +image: + repository: ghcr.io/opencost/opencost-parquet-exporter + tag: main + 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 + - 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