Skip to content

Commit 34b3f82

Browse files
Merge pull request #114 from spa-skyson/helmchart
helmchart v1.0.0
2 parents 1470013 + de11ab8 commit 34b3f82

File tree

9 files changed

+573
-0
lines changed

9 files changed

+573
-0
lines changed

postgresus/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

postgresus/Chart.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v2
2+
name: postgresus
3+
description: A Helm chart for Postgresus - PostgreSQL backup and management system
4+
type: application
5+
version: 1.0.0
6+
appVersion: "v1.45.3"
7+
keywords:
8+
- postgresql
9+
- backup
10+
- database
11+
- restore
12+
home: https://github.com/RostislavDugin/postgresus
13+
maintainers:
14+
- name: Alexander Gazal
15+

postgresus/README.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# Postgresus Helm Chart
2+
3+
Helm chart for deploying Postgresus - a PostgreSQL backup and management system.
4+
5+
## Description
6+
7+
This Helm chart deploys Postgresus in a Kubernetes cluster using StatefulSet to ensure persistent data storage.
8+
9+
## Installation
10+
11+
### Install with Default Values
12+
13+
```bash
14+
helm install postgresus ./helm-chart/postgresus -n postgresus --create-namespace
15+
```
16+
17+
### Install with Custom Values
18+
19+
```bash
20+
helm install postgresus ./helm-chart/postgresus -n postgresus --create-namespace -f custom-values.yaml
21+
```
22+
23+
### Upgrade Release
24+
25+
```bash
26+
helm upgrade postgresus ./helm-chart/postgresus -n postgresus
27+
```
28+
29+
### Uninstall Release
30+
31+
```bash
32+
helm uninstall postgresus -n postgresus
33+
```
34+
35+
## Configuration
36+
37+
### Main Parameters
38+
39+
| Parameter | Description | Default Value |
40+
|----------|----------|----------------------|
41+
| `namespace.create` | Create namespace | `true` |
42+
| `namespace.name` | Namespace name | `postgresus` |
43+
| `image.repository` | Docker image | `rostislavdugin/postgresus` |
44+
| `image.tag` | Image tag | `v1.34.0` |
45+
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
46+
| `replicaCount` | Number of replicas | `1` |
47+
48+
### Resources
49+
50+
| Parameter | Description | Default Value |
51+
|----------|----------|----------------------|
52+
| `resources.requests.memory` | Memory request | `512Mi` |
53+
| `resources.requests.cpu` | CPU request | `250m` |
54+
| `resources.limits.memory` | Memory limit | `1Gi` |
55+
| `resources.limits.cpu` | CPU limit | `500m` |
56+
57+
### Storage
58+
59+
| Parameter | Description | Default Value |
60+
|----------|----------|----------------------|
61+
| `persistence.enabled` | Enable persistent storage | `true` |
62+
| `persistence.storageClassName` | Storage class | `longhorn` |
63+
| `persistence.accessMode` | Access mode | `ReadWriteOnce` |
64+
| `persistence.size` | Storage size | `10Gi` |
65+
| `persistence.mountPath` | Mount path | `/postgresus-data` |
66+
67+
### Service
68+
69+
| Parameter | Description | Default Value |
70+
|----------|----------|----------------------|
71+
| `service.type` | Service type | `ClusterIP` |
72+
| `service.port` | Service port | `4005` |
73+
| `service.targetPort` | Target port | `4005` |
74+
| `service.headless.enabled` | Enable headless service | `true` |
75+
76+
### Ingress
77+
78+
| Parameter | Description | Default Value |
79+
|----------|----------|----------------------|
80+
| `ingress.enabled` | Enable Ingress | `true` |
81+
| `ingress.className` | Ingress class | `nginx` |
82+
| `ingress.hosts[0].host` | Hostname | `postgresus.home.fwz.ru` |
83+
| `ingress.tls` | TLS configuration | See values.yaml |
84+
85+
### Health Checks
86+
87+
| Parameter | Description | Default Value |
88+
|----------|----------|----------------------|
89+
| `livenessProbe.enabled` | Enable liveness probe | `false` |
90+
| `readinessProbe.enabled` | Enable readiness probe | `false` |
91+
92+
## Usage Examples
93+
94+
### Change Image Version
95+
96+
```yaml
97+
# custom-values.yaml
98+
image:
99+
tag: v1.20.0
100+
```
101+
102+
```bash
103+
helm upgrade postgresus ./helm-chart/postgresus -n postgresus -f custom-values.yaml
104+
```
105+
106+
### Change Storage Size
107+
108+
```yaml
109+
# custom-values.yaml
110+
persistence:
111+
size: 50Gi
112+
```
113+
114+
### Configure Ingress for Different Domain
115+
116+
```yaml
117+
# custom-values.yaml
118+
ingress:
119+
hosts:
120+
- host: backup.example.com
121+
paths:
122+
- path: /
123+
pathType: Prefix
124+
tls:
125+
- secretName: backup-example-com-tls
126+
hosts:
127+
- backup.example.com
128+
```
129+
130+
### Enable Health Checks
131+
132+
```yaml
133+
# custom-values.yaml
134+
livenessProbe:
135+
enabled: true
136+
137+
readinessProbe:
138+
enabled: true
139+
```
140+
141+
## Verify Deployment
142+
143+
```bash
144+
# Check release status
145+
helm status postgresus -n postgresus
146+
147+
# View pods
148+
kubectl get pods -n postgresus
149+
150+
# View services
151+
kubectl get svc -n postgresus
152+
153+
# View ingress
154+
kubectl get ingress -n postgresus
155+
156+
# View PVC
157+
kubectl get pvc -n postgresus
158+
```
159+
160+
## Debugging
161+
162+
```bash
163+
# View logs
164+
kubectl logs -n postgresus -l app=postgresus
165+
166+
# View events
167+
kubectl get events -n postgresus
168+
169+
# Describe StatefulSet
170+
kubectl describe statefulset postgresus -n postgresus
171+
172+
# Render templates without installation
173+
helm template postgresus ./helm-chart/postgresus -n postgresus
174+
```
175+
176+
## Requirements
177+
178+
- Kubernetes 1.19+
179+
- Helm 3.0+
180+
- PV provisioner (e.g., Longhorn)
181+
- Nginx Ingress Controller (optional)
182+
- Cert-Manager (optional, for automatic certificates)
183+
184+
## Notes
185+
186+
- The chart uses StatefulSet to ensure stable data storage
187+
- Headless service is created automatically for StatefulSet
188+
- By default, one application instance is created (replica=1)
189+
- It's recommended to configure a backup policy for PVC

postgresus/templates/_helpers.tpl

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "postgresus.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "postgresus.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Create chart name and version as used by the chart label.
26+
*/}}
27+
{{- define "postgresus.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels
33+
*/}}
34+
{{- define "postgresus.labels" -}}
35+
helm.sh/chart: {{ include "postgresus.chart" . }}
36+
{{ include "postgresus.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels
45+
*/}}
46+
{{- define "postgresus.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "postgresus.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
app: postgresus
50+
{{- end }}
51+
52+
{{/*
53+
Create the name of the service account to use
54+
*/}}
55+
{{- define "postgresus.serviceAccountName" -}}
56+
{{- if .Values.serviceAccount.create }}
57+
{{- default (include "postgresus.fullname" .) .Values.serviceAccount.name }}
58+
{{- else }}
59+
{{- default "default" .Values.serviceAccount.name }}
60+
{{- end }}
61+
{{- end }}
62+
63+
{{/*
64+
Namespace
65+
*/}}
66+
{{- define "postgresus.namespace" -}}
67+
{{- if .Values.namespace.create }}
68+
{{- .Values.namespace.name }}
69+
{{- else }}
70+
{{- .Release.Namespace }}
71+
{{- end }}
72+
{{- end }}

postgresus/templates/ingress.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "postgresus.fullname" . }}-ingress
6+
namespace: {{ include "postgresus.namespace" . }}
7+
labels:
8+
{{- include "postgresus.labels" . | nindent 4 }}
9+
{{- with .Values.ingress.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
{{- if .Values.ingress.className }}
15+
ingressClassName: {{ .Values.ingress.className }}
16+
{{- end }}
17+
{{- if .Values.ingress.tls }}
18+
tls:
19+
{{- range .Values.ingress.tls }}
20+
- hosts:
21+
{{- range .hosts }}
22+
- {{ . | quote }}
23+
{{- end }}
24+
secretName: {{ .secretName }}
25+
{{- end }}
26+
{{- end }}
27+
rules:
28+
{{- range .Values.ingress.hosts }}
29+
- host: {{ .host | quote }}
30+
http:
31+
paths:
32+
{{- range .paths }}
33+
- path: {{ .path }}
34+
pathType: {{ .pathType }}
35+
backend:
36+
service:
37+
name: {{ include "postgresus.fullname" $ }}-service
38+
port:
39+
number: {{ $.Values.service.port }}
40+
{{- end }}
41+
{{- end }}
42+
{{- end }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{- if .Values.namespace.create }}
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: {{ .Values.namespace.name }}
6+
labels:
7+
{{- include "postgresus.labels" . | nindent 4 }}
8+
{{- end }}

postgresus/templates/service.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "postgresus.fullname" . }}-service
5+
namespace: {{ include "postgresus.namespace" . }}
6+
labels:
7+
{{- include "postgresus.labels" . | nindent 4 }}
8+
spec:
9+
type: {{ .Values.service.type }}
10+
ports:
11+
- port: {{ .Values.service.port }}
12+
targetPort: {{ .Values.service.targetPort }}
13+
protocol: TCP
14+
name: http
15+
selector:
16+
{{- include "postgresus.selectorLabels" . | nindent 4 }}
17+
---
18+
{{- if .Values.service.headless.enabled }}
19+
apiVersion: v1
20+
kind: Service
21+
metadata:
22+
name: {{ include "postgresus.fullname" . }}-headless
23+
namespace: {{ include "postgresus.namespace" . }}
24+
labels:
25+
{{- include "postgresus.labels" . | nindent 4 }}
26+
spec:
27+
type: ClusterIP
28+
clusterIP: None
29+
ports:
30+
- port: {{ .Values.service.port }}
31+
targetPort: {{ .Values.service.targetPort }}
32+
protocol: TCP
33+
name: http
34+
selector:
35+
{{- include "postgresus.selectorLabels" . | nindent 4 }}
36+
{{- end }}

0 commit comments

Comments
 (0)