Skip to content

Commit

Permalink
Add neon-broker chart. (#15)
Browse files Browse the repository at this point in the history
* Add neon-broker chart.

Similar to neon-proxy, but a bit simpler: single replica, single port for
service itself and metrics, internal service.

* rename to storage_broker

* The chart was renamed from neon-broker to neon-storage-broker, so fix
the references too.

* Add ingress template and the values along with it. Disabled by default,
as it's pretty common practice.

* Make the annotations indentation consistent, there was 4 spaces too may.

* Regenerate readme

* helm-docs seems to generate a version stamp. Fix the version in the
readme. Perhaps we should update the version, but doing that sometime
later.

* remove initcontainers

* Also add a possibility to include additional manidests.

* Regenerate the README, add a documentation regarding extraManifests.

Co-authored-by: Lassi Pölönen <[email protected]>
  • Loading branch information
arssher and lassizci authored Nov 24, 2022
1 parent f3f4c7c commit efb0f6c
Show file tree
Hide file tree
Showing 13 changed files with 542 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/neon-storage-broker/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
10 changes: 10 additions & 0 deletions charts/neon-storage-broker/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v2
name: neon-storage-broker
description: Neon storage broker
type: application
version: 1.0.0
appVersion: "0.1.0"
kubeVersion: "^1.18.x-x"
home: https://neon.tech
sources:
- https://github.com/neondatabase/neon
67 changes: 67 additions & 0 deletions charts/neon-storage-broker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# neon-storage-broker

![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-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)

Neon storage broker

**Homepage:** https://neon.tech

## Source Code

* <https://github.com/neondatabase/neon>

## Installing the Chart

To install the chart with the release name `neon-storage-broker`:

```console
$ helm repo add neondatabase https://neondatabase.github.io/helm-charts
$ helm install neon-storage-broker neondatabase/neon-storage-broker
```

## Requirements

Kubernetes: `^1.18.x-x`

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity for pod assignment |
| extraManifests | list | `[]` | Additional manifests that are created with the chart |
| fullnameOverride | string | `""` | String to fully override neon-storage-broker.fullname template |
| image.pullPolicy | string | `"Always"` | image pull policy |
| image.repository | string | `"neondatabase/neon"` | Neondatabase image repository |
| image.tag | string | `"latest"` | Overrides the image tag whose default is the chart appVersion. |
| imagePullSecrets | list | `[]` | Specify docker-registry secret names as an array |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| metrics.enabled | bool | `false` | Enable prometheus metrcis autodiscovery |
| metrics.serviceMonitor.enabled | bool | `false` | Create ServiceMonitor resource |
| metrics.serviceMonitor.interval | string | `"10s"` | Interval in which prometheus scrapes |
| metrics.serviceMonitor.namespace | string | `""` | The namespace in which the ServiceMonitor will be created, if empty then Release.Namespace used |
| metrics.serviceMonitor.scrapeTimeout | string | `"10s"` | Scrape Timeout duration for prometheus |
| metrics.serviceMonitor.selector | object | `{}` | Additional labels to attach (used by Prometheus operator) |
| nameOverride | string | `""` | String to partially override neon-storage-broker.fullname template (will maintain the release name) |
| nodeSelector | object | `{}` | Node labels for pod assignment. |
| podAnnotations | object | `{}` | Annotations for neon-storage-broker pods |
| podLabels | object | `{}` | Additional labels for neon-storage-broker pods |
| podSecurityContext | object | `{}` | neon-storage-broker's pods Security Context |
| resources | object | `{}` | |
| securityContext | object | `{}` | neon-storage-broker's containers Security Context |
| service.annotations | object | `{}` | Annotations to add to the service |
| service.port | int | `50051` | broker listen port |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| settings | object | `{}` | |
| tolerations | list | `[]` | Tolerations for pod assignment. |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.9.1](https://github.com/norwoodj/helm-docs/releases/v1.9.1)
23 changes: 23 additions & 0 deletions charts/neon-storage-broker/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -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-broker`:

```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" . }}
6 changes: 6 additions & 0 deletions charts/neon-storage-broker/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Externally service is available at http://{{ index .Values.service.annotations "external-dns.alpha.kubernetes.io/hostname" }}:{{ .Values.service.port }}
You can also get LoadBalancer URL by running these commands:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "neon-storage-broker.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "neon-storage-broker.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
62 changes: 62 additions & 0 deletions charts/neon-storage-broker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "neon-storage-broker.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-broker.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-broker.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common for Service and Deployment labels
*/}}
{{- define "neon-storage-broker.labels" -}}
helm.sh/chart: {{ include "neon-storage-broker.chart" . }}
{{ include "neon-storage-broker.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-broker.selectorLabels" -}}
app.kubernetes.io/name: {{ include "neon-storage-broker.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "neon-storage-broker.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "neon-storage-broker.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
84 changes: 84 additions & 0 deletions charts/neon-storage-broker/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "neon-storage-broker.fullname" . }}
labels:
{{- include "neon-storage-broker.labels" . | nindent 4 }}
spec:
strategy:
type: Recreate
replicas: 1
# Which pods the Deployment is managing (duplicates template.metadata.labels).
selector:
matchLabels:
{{- include "neon-storage-broker.selectorLabels" . | nindent 6 }}
# Pod template.
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
# Labels set on created pods.
labels:
{{- include "neon-storage-broker.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "neon-storage-broker.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- storage_broker
- --listen-addr
# In the container, use the same port as service.
- 0.0.0.0:{{ .Values.service.port }}
ports:
- name: broker
containerPort: {{ .Values.service.port }}
protocol: TCP
startupProbe:
httpGet:
path: /metrics
port: broker
initialDelaySeconds: 10
timeoutSeconds: 5
periodSeconds: 10
failureThreshold: 30
livenessProbe:
httpGet:
path: /metrics
port: broker
periodSeconds: 15
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /metrics
port: broker
periodSeconds: 15
timeoutSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/neon-storage-broker/templates/extra-manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{- range .Values.extraManifests }}
---
{{ tpl (toYaml .) $ }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/neon-storage-broker/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "neon-storage-broker.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "neon-storage-broker.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
19 changes: 19 additions & 0 deletions charts/neon-storage-broker/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "neon-storage-broker.fullname" . }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
{{- include "neon-storage-broker.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: broker
protocol: TCP
name: broker
selector:
{{- include "neon-storage-broker.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/neon-storage-broker/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "neon-storage-broker.serviceAccountName" . }}
labels:
{{- include "neon-storage-broker.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit efb0f6c

Please sign in to comment.