diff --git a/charts/neon-storage-scrubber/.helmignore b/charts/neon-storage-scrubber/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/neon-storage-scrubber/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/neon-storage-scrubber/Chart.yaml b/charts/neon-storage-scrubber/Chart.yaml new file mode 100644 index 0000000..8237c42 --- /dev/null +++ b/charts/neon-storage-scrubber/Chart.yaml @@ -0,0 +1,8 @@ +apiVersion: v2 +name: neon-storage-scrubber +description: AWS Cost Reporter +type: application +version: 1.0.1 +appVersion: "v0.1.0" +sources: + - https://github.com/neondatabase/neon-storage-scrubber diff --git a/charts/neon-storage-scrubber/README.md b/charts/neon-storage-scrubber/README.md new file mode 100644 index 0000000..90409ac --- /dev/null +++ b/charts/neon-storage-scrubber/README.md @@ -0,0 +1,47 @@ +# neon-storage-scrubber + +![Version: 1.0.1](https://img.shields.io/badge/Version-1.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) [![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml) + +AWS Cost Reporter + +**Homepage:** + +## Source Code + +* + +## Installing the Chart + +To install the chart with the release name `neon-storage-scrubber`: + +```console +$ helm repo add neondatabase https://neondatabase.github.io/helm-charts +$ helm install neon-storage-scrubber neondatabase/neon-storage-scrubber +``` + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | Affinity for pod assignment | +| fullnameOverride | string | `""` | String to fully override neon-storage-scrubber.fullname template | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"neondatabase/neon"` | Image repository | +| image.tag | string | `""` | Overrides the image tag whose default is the chart appVersion. | +| imagePullSecrets | list | `[]` | Specify docker-registry secret names as an array | +| nameOverride | string | `""` | String to partially override neon-storage-scrubber.fullname template (will maintain the release name) | +| nodeSelector | object | `{}` | Node labels for pod assignment. | +| podAnnotations | object | `{}` | Annotations for neon-storage-scrubber pods | +| podSecurityContext | object | `{}` | neon-storage-scrubber's pods Security Context | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | neon-storage-scrubber's containers Security Context | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | +| storageScrubber.awsBucket | string | `""` | The AWS bucket for the pageserver storage | +| storageScrubber.awsRegion | string | `""` | The AWS region to run the scrubber | +| tolerations | list | `[]` | Tolerations for pod assignment. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2) diff --git a/charts/neon-storage-scrubber/README.md.gotmpl b/charts/neon-storage-scrubber/README.md.gotmpl new file mode 100644 index 0000000..6e9c96c --- /dev/null +++ b/charts/neon-storage-scrubber/README.md.gotmpl @@ -0,0 +1,23 @@ +{{ template "chart.header" . }} +{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}[![Lint and Test Charts](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml/badge.svg)](https://github.com/neondatabase/helm-charts/actions/workflows/lint-test.yaml) + +{{ template "chart.description" . }} + +**Homepage:** {{ template "chart.homepage" . }} + +{{ template "chart.sourcesSection" . }} + +## Installing the Chart + +To install the chart with the release name `neon-storage-scrubber`: + +```console +$ helm repo add neondatabase https://neondatabase.github.io/helm-charts +$ helm install {{ template "chart.name" . }} neondatabase/{{ template "chart.name" . }} +``` + +{{ template "chart.requirementsSection" . }} + +{{ template "chart.valuesSection" . }} + +{{ template "helm-docs.versionFooter" . }} diff --git a/charts/neon-storage-scrubber/templates/_helpers.tpl b/charts/neon-storage-scrubber/templates/_helpers.tpl new file mode 100644 index 0000000..2c55a63 --- /dev/null +++ b/charts/neon-storage-scrubber/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "neon-storage-scrubber.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 "neon-storage-scrubber.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 "neon-storage-scrubber.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "neon-storage-scrubber.labels" -}} +helm.sh/chart: {{ include "neon-storage-scrubber.chart" . }} +{{ include "neon-storage-scrubber.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "neon-storage-scrubber.selectorLabels" -}} +app.kubernetes.io/name: {{ include "neon-storage-scrubber.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "neon-storage-scrubber.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "neon-storage-scrubber.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/neon-storage-scrubber/templates/cronjob.yaml b/charts/neon-storage-scrubber/templates/cronjob.yaml new file mode 100644 index 0000000..b95c37c --- /dev/null +++ b/charts/neon-storage-scrubber/templates/cronjob.yaml @@ -0,0 +1,68 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ include "neon-storage-scrubber.fullname" . }} + labels: + {{- include "neon-storage-scrubber.labels" . | nindent 4 }} +spec: + timeZone: "Etc/UTC" + schedule: '0 18 * * *' # Runs every day at 6pm + failedJobsHistoryLimit: 1 + concurrencyPolicy: Forbid # Only runs one instance + jobTemplate: + metadata: + name: {{ include "neon-storage-scrubber.fullname" . }} + labels: + {{- include "neon-storage-scrubber.labels" . | nindent 8 }} + spec: + backoffLimit: 0 # Do not restart if the task fails + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 12 }} + {{- end }} + labels: + {{- include "neon-storage-scrubber.selectorLabels" . | nindent 12 }} + spec: + restartPolicy: Never # Do not restart if the task fails + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 12 }} + {{- end }} + serviceAccountName: {{ include "neon-storage-scrubber.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 12 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 16 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: + - /usr/local/bin/storage_scrubber + - pageserver-physical-gc + - --min-age=1week + env: + - name: BUCKET + value: {{ .Values.storageScrubber.awsBucket }} + - name: REGION + value: {{ .Values.storageScrubber.awsRegion }} + - name: RUST_BACKTRACE + value: '1' + - name: PAGESERVER_DISABLE_FILE_LOGGING + value: '1' + resources: + {{- toYaml .Values.resources | nindent 16 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 12 }} + {{- end }} diff --git a/charts/neon-storage-scrubber/templates/serviceaccount.yaml b/charts/neon-storage-scrubber/templates/serviceaccount.yaml new file mode 100644 index 0000000..dc6366b --- /dev/null +++ b/charts/neon-storage-scrubber/templates/serviceaccount.yaml @@ -0,0 +1,15 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "neon-storage-scrubber.serviceAccountName" . }} + labels: + {{- include "neon-storage-scrubber.labels" . | nindent 4 }} + {{- if .Values.serviceAccount.annotations }} + annotations: + {{- with .Values.serviceAccount.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} +automountServiceAccountToken: false +{{- end }} diff --git a/charts/neon-storage-scrubber/values.yaml b/charts/neon-storage-scrubber/values.yaml new file mode 100644 index 0000000..820117d --- /dev/null +++ b/charts/neon-storage-scrubber/values.yaml @@ -0,0 +1,72 @@ +# Default values for neon-storage-scrubber. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + # -- Image repository + repository: neondatabase/neon + # -- image pull policy + pullPolicy: IfNotPresent + # -- Overrides the image tag whose default is the chart appVersion. + tag: "" + +# -- Specify docker-registry secret names as an array +imagePullSecrets: [] +# -- String to partially override neon-storage-scrubber.fullname template (will maintain the release name) +nameOverride: "" +# -- String to fully override neon-storage-scrubber.fullname template +fullnameOverride: "" + +serviceAccount: + # -- Specifies whether a service account should be created + create: true + # -- Annotations to add to the service account + annotations: {} + # -- The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +storageScrubber: + # -- The AWS region to run the scrubber + awsRegion: "" + # -- The AWS bucket for the pageserver storage + awsBucket: "" + +# -- Annotations for neon-storage-scrubber pods +podAnnotations: {} + +# -- neon-storage-scrubber's pods Security Context +podSecurityContext: {} + # fsGroup: 2000 + +# -- neon-storage-scrubber's containers Security Context +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# -- Node labels for pod assignment. +nodeSelector: {} + +# -- Tolerations for pod assignment. +tolerations: [] + +# -- Affinity for pod assignment +affinity: {}