Skip to content

Commit 1c99280

Browse files
Md. Emruz Hossaintamalsaha
authored andcommitted
Add Chart and documentation (#2)
Task: - [x] Add chart - [x] Add documentation
1 parent 0238497 commit 1c99280

File tree

280 files changed

+11678
-2247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+11678
-2247
lines changed

Makefile

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2019 AppsCode Inc.
2+
# Copyright 2016 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
116
SHELL=/bin/bash -o pipefail
217

318
# The binary to build (just the basename).
@@ -44,8 +59,8 @@ BIN_PLATFORMS := $(DOCKER_PLATFORMS)
4459
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
4560
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
4661

47-
BASEIMAGE_PROD ?= postgres:9.5-alpine
48-
BASEIMAGE_DBG ?= postgres:9.5
62+
BASEIMAGE_PROD ?= postgres:11.2-alpine
63+
BASEIMAGE_DBG ?= postgres:11.2
4964

5065
IMAGE := $(REGISTRY)/$(BIN)
5166
VERSION_PROD := $(VERSION)
@@ -54,7 +69,7 @@ TAG := $(VERSION)_$(OS)_$(ARCH)
5469
TAG_PROD := $(TAG)
5570
TAG_DBG := $(VERSION)-dbg_$(OS)_$(ARCH)
5671

57-
GO_VERSION ?= 1.12.5
72+
GO_VERSION ?= 1.12.7
5873
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch
5974

6075
OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
@@ -164,9 +179,21 @@ $(OUTBIN): .go/$(OUTBIN).stamp
164179
commit_timestamp=$(commit_timestamp) \
165180
./hack/build.sh \
166181
"
167-
@if [ $(COMPRESS) = yes ] && [ $(OS) != windows ]; then \
168-
echo "compressing $(OUTBIN)"; \
169-
upx --brute .go/$(OUTBIN); \
182+
@if [ $(COMPRESS) = yes ] && [ $(OS) != darwin ]; then \
183+
echo "compressing $(OUTBIN)"; \
184+
docker run \
185+
-i \
186+
--rm \
187+
-u $$(id -u):$$(id -g) \
188+
-v $$(pwd):/src \
189+
-w /src \
190+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
191+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
192+
-v $$(pwd)/.go/cache:/.cache \
193+
--env HTTP_PROXY=$(HTTP_PROXY) \
194+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
195+
$(BUILD_IMAGE) \
196+
upx --brute /go/$(OUTBIN); \
170197
fi
171198
@if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \
172199
mv .go/$(OUTBIN) $(OUTBIN); \
@@ -255,28 +282,28 @@ dev: gen fmt push
255282
ci: lint test build #cover
256283

257284
.PHONY: qa
258-
qa: docker-manifest
285+
qa:
259286
@if [ "$$APPSCODE_ENV" = "prod" ]; then \
260287
echo "Nothing to do in prod env. Are you trying to 'release' binaries to prod?"; \
261288
exit 1; \
262289
fi
263-
@if [ "$(version_strategy)" = "git_tag" ]; then \
290+
@if [ "$(version_strategy)" = "tag" ]; then \
264291
echo "Are you trying to 'release' binaries to prod?"; \
265292
exit 1; \
266293
fi
267-
@$(MAKE) clean all-push --no-print-directory
294+
@$(MAKE) clean all-push docker-manifest --no-print-directory
268295

269296
.PHONY: release
270-
release: docker-manifest
297+
release:
271298
@if [ "$$APPSCODE_ENV" != "prod" ]; then \
272299
echo "'release' only works in PROD env."; \
273300
exit 1; \
274301
fi
275-
@if [ "$(version_strategy)" != "git_tag" ]; then \
276-
echo "'apply_tag' to release binaries and/or docker images."; \
277-
exit 1; \
302+
@if [ "$(version_strategy)" != "tag" ]; then \
303+
echo "apply tag to release binaries and/or docker images."; \
304+
exit 1; \
278305
fi
279-
@$(MAKE) clean all-push --no-print-directory
306+
@$(MAKE) clean all-push docker-manifest --no-print-directory
280307

281308
.PHONY: clean
282309
clean:

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,31 @@
55
[![Twitter](https://img.shields.io/twitter/follow/appscodehq.svg?style=social&logo=twitter&label=Follow)](https://twitter.com/intent/follow?screen_name=AppsCodeHQ)
66

77
# Postgres
8+
89
Postgres backup and restore plugin for [Stash by AppsCode](https://appscode.com/products/stash).
910

10-
---
11+
## Install
12+
13+
Install PostgreSQL 11.2 backup or restore plugin for Stash as below.
14+
15+
```console
16+
helm repo add appscode https://charts.appscode.com/stable/
17+
helm repo update
18+
helm install appscode/postgres-stash --name=postgres-stash-11.2 --version=11.2
19+
```
1120

12-
**Stash binaries collects anonymous usage statistics to help us learn how the software is being used and how we can improve it. To disable stats collection, run the operator with the flag** `--enable-analytics=false`.
21+
To install catalog for all supported PostgreSQL versions, please visit [here](https://github.com/stashed/catalog).
1322

14-
---
23+
## Uninstall
24+
25+
Uninstall PostgreSQL 11.2 backup or restore plugin for Stash as below.
26+
27+
```console
28+
helm delete postgres-stash-11.2
29+
```
1530

1631
## Support
32+
1733
We use Slack for public discussions. To chit chat with us or the rest of the community, join us in the [AppsCode Slack team](https://appscode.slack.com/messages/C8NCX6N23/details/) channel `#stash`. To sign up, use our [Slack inviter](https://slack.appscode.com/).
1834

1935
If you have found a bug with Stash or want to request for new features, please [file an issue](https://github.com/stashed/stash/issues/new).

chart/postgres-stash/.helmignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
.vscode/

chart/postgres-stash/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
description: 'postgres-stash by AppsCode - PostgreSQL database backup and restore plugin for Stash.'
3+
name: postgres-stash
4+
version: 11.2
5+
appVersion: 11.2
6+
home: https://github.com/stashed/postgres
7+
icon: https://cdn.appscode.com/images/icon/stash.png
8+
sources:
9+
- https://github.com/stashed/postgres
10+
maintainers:
11+
- name: appscode
12+
email: support@appscode.com

chart/postgres-stash/README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Postgres-stash
2+
3+
[postgres-stash](https://github.com/stashed/postgres-stash) - PostgreSQL database backup/restore plugin for [Stash](https://appscode.com/products/stash/) by AppsCode.
4+
5+
## TL;DR;
6+
7+
```console
8+
helm repo add appscode https://charts.appscode.com/stable/
9+
helm repo update
10+
helm install appscode/postgres-stash --name=postgres-stash-11.2 --version=11.2
11+
```
12+
13+
## Introduction
14+
15+
This chart installs necessary `Function` and `Task` definition to backup or restore PostgreSQL database 11.2 using Stash.
16+
17+
## Prerequisites
18+
19+
- Kubernetes 1.11+
20+
21+
## Installing the Chart
22+
23+
- Add AppsCode chart repository to your helm repository list,
24+
25+
```console
26+
helm repo add appscode https://charts.appscode.com/stable/
27+
```
28+
29+
- Update helm repositories to fetch latest charts from the remove repository,
30+
31+
```console
32+
helm repo update
33+
```
34+
35+
- Install the chart with the release name `postgres-stash-11.2` run the following command,
36+
37+
```console
38+
helm install appscode/postgres-stash --name=postgres-stash-11.2 --version=11.2
39+
```
40+
41+
The above commands installs `Functions` and `Task` crds that are necessary to backup PostgreSQL database 11.2 using Stash.
42+
43+
## Uninstalling the Chart
44+
45+
To uninstall/delete the `postgres-stash-11.2` run the following command,
46+
47+
```console
48+
helm delete postgres-stash-11.2
49+
```
50+
51+
The command removes all the Kubernetes components associated with the chart and deletes the release.
52+
53+
## Configuration
54+
55+
The following table lists the configurable parameters of the `postgre-stash` chart and their default values.
56+
57+
| Parameter | Description | Default |
58+
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
59+
| `docker.registry` | Docker registry used to pull respective images | `appscode` |
60+
| `docker.image` | Docker image used to backup/restore PosegreSQL database | `postgres-stash` |
61+
| `docker.tag` | Tag of the image that is used to backup/restore PostgreSQL database. This is usually same as the database version it can backup. | `11.2` |
62+
| `backup.pgArgs` | Optional arguments to pass to `pgdump` command for bakcup | |
63+
| `restore.pgArgs` | Optional arguments to pass to `psql` command for restoration | |
64+
| `metrics.enabled` | Specifies whether to send Prometheus metrics | `true` |
65+
| `metrics.labels` | Optional comma separated labels to add to the Prometheus metrics | |
66+
67+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
68+
69+
For example:
70+
71+
```console
72+
helm install --name postgres-stash-11.2 --set metrics.enabled=false appscode/postgres-stash
73+
```
74+
75+
**Tips:** Use escape character (`\`) while providing multiple comma-separated labels for `metrics.labels`.
76+
77+
```console
78+
helm install chart/postgres-stash --set metrics.labels="k1=v1\,k2=v2"
79+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To verify that all Functions are installed successfully, run:
2+
3+
kubectl get function.stash.appscode.com
4+
5+
To verify that all Tasks are installed successfully, run:
6+
7+
kubectl get task.stash.appscode.com
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "postgres-stash.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "postgres-stash.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "postgres-stash.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
# default labels for posgres-stash resources
35+
{{- define "postgres-stash.labels" -}}
36+
app.kubernetes.io/name: {{ include "postgres-stash.name" . }}
37+
helm.sh/chart: {{ include "postgres-stash.chart" . }}
38+
app.kubernetes.io/instance: {{ .Release.Name }}
39+
app.kubernetes.io/managed-by: {{ .Release.Service }}
40+
{{- end -}}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
apiVersion: stash.appscode.com/v1beta1
2+
kind: Function
3+
metadata:
4+
name: pg-backup-{{- .Chart.Version }}
5+
labels:
6+
{{- include "postgres-stash.labels" . | nindent 4 }}
7+
spec:
8+
image: {{ .Values.docker.registry }}/{{ .Values.docker.image }}:{{- .Values.docker.tag }}
9+
args:
10+
- backup-pg
11+
# setup information
12+
- --provider=${REPOSITORY_PROVIDER:=}
13+
- --bucket=${REPOSITORY_BUCKET:=}
14+
- --endpoint=${REPOSITORY_ENDPOINT:=}
15+
- --rest-server-url=${REPOSITORY_URL:=}
16+
- --path=${REPOSITORY_PREFIX:=}
17+
- --secret-dir=/etc/repository/secret
18+
- --scratch-dir=/tmp
19+
- --enable-cache=${ENABLE_CACHE:=true}
20+
- --max-connections=${MAX_CONNECTIONS:=0} # 0 indicates use default connection limit
21+
- --hostname=${HOSTNAME:=}
22+
- --pg-args=${pgArgs:={{ .Values.backup.pgArgs }}} # optional arguments pass to pgdump command
23+
# target information
24+
- --namespace=${NAMESPACE:=default}
25+
- --app-binding=${TARGET_NAME:=}
26+
# cleanup information
27+
- --retention-keep-last=${RETENTION_KEEP_LAST:=0}
28+
- --retention-keep-hourly=${RETENTION_KEEP_HOURLY:=0}
29+
- --retention-keep-daily=${RETENTION_KEEP_DAILY:=0}
30+
- --retention-keep-weekly=${RETENTION_KEEP_WEEKLY:=0}
31+
- --retention-keep-monthly=${RETENTION_KEEP_MONTHLY:=0}
32+
- --retention-keep-yearly=${RETENTION_KEEP_YEARLY:=0}
33+
- --retention-keep-tags=${RETENTION_KEEP_TAGS:=}
34+
- --retention-prune=${RETENTION_PRUNE:=false}
35+
- --retention-dry-run=${RETENTION_DRY_RUN:=false}
36+
# output & metric information
37+
- --output-dir=${outputDir:=}
38+
- --metrics-enabled={{ .Values.metrics.enabled }}
39+
- --metrics-pushgateway-url=${PROMETHEUS_PUSHGATEWAY_URL:=}
40+
{{- if .Values.metrics.labels }}
41+
- --metrics-labels={{ .Values.metrics.labels | quote }}
42+
{{- end }}
43+
volumeMounts:
44+
- name: ${secretVolume}
45+
mountPath: /etc/repository/secret
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: stash.appscode.com/v1beta1
2+
kind: Task
3+
metadata:
4+
name: pg-backup-{{- .Chart.Version }}
5+
labels:
6+
{{- include "postgres-stash.labels" . | nindent 4 }}
7+
spec:
8+
steps:
9+
- name: pg-backup-{{- .Chart.Version }}
10+
params:
11+
- name: outputDir
12+
value: /tmp/output
13+
- name: secretVolume
14+
value: secret-volume
15+
- name: update-status
16+
params:
17+
- name: outputDir
18+
value: /tmp/output
19+
volumes:
20+
- name: secret-volume
21+
secret:
22+
secretName: ${REPOSITORY_SECRET_NAME}

0 commit comments

Comments
 (0)