Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8a84b47
Initial commit of postgreslet-support chart
eberlep Jan 22, 2021
0874a5f
Initial commit of postgreslet-support chart
eberlep Jan 22, 2021
02964c8
Initial commit of postgreslet chart
eberlep Jan 22, 2021
97bca37
Update README
eberlep Jan 22, 2021
1e48a5a
Added missing .helmignore files
eberlep Jan 22, 2021
50370f0
Update .gitignore
eberlep Jan 22, 2021
4b0344e
Moved helm build to Makefile
eberlep Jan 22, 2021
3aa37c0
Merge remote-tracking branch 'origin' into helm-charts
eberlep Jan 25, 2021
e9fe140
Update CRDs
eberlep Jan 25, 2021
be51112
Linter
eberlep Jan 25, 2021
b8e6f0f
Remove kube-rbac-proxy
eberlep Jan 25, 2021
46e5811
Removed unused roles
eberlep Jan 25, 2021
3cd972e
Removed unused service
eberlep Jan 25, 2021
e81da1e
Introduce some variables and own serviceaccount
eberlep Jan 25, 2021
fa9a6b4
Add missing podSecurityContext
eberlep Jan 25, 2021
f5f1747
Make namespace dynamic
eberlep Jan 25, 2021
c8c4446
Update pod name
eberlep Jan 25, 2021
d36c2a5
Indentation
eberlep Jan 25, 2021
be6ed93
Make args configurable
eberlep Jan 25, 2021
2023fdd
Merge remote-tracking branch 'origin' into helm-charts
eberlep Feb 2, 2021
0c5fab8
Use configmap
eberlep Feb 2, 2021
6148b0c
Update CRDs
eberlep Feb 2, 2021
4712a05
Remove infinite rendering loop
eberlep Feb 2, 2021
0a51f9a
Remove checksum from secret as well
eberlep Feb 2, 2021
dd50c98
Generalize secret hash / adopt to config hash
eberlep Feb 2, 2021
ec92d89
Fix variable swap
eberlep Feb 2, 2021
b84c2a6
Merge remote-tracking branch 'origin' into helm-charts
eberlep Feb 2, 2021
8cf9d64
Make (cluster)role names configurable
eberlep Feb 2, 2021
12643e5
Add comments/docs to values.yaml
eberlep Feb 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ bin
*~

# control-plane kubeconfig file
*kubeconfig
*kubeconfig

# helm files
charts/postgreslet/Chart.lock
charts/postgreslet/charts/*

9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,12 @@ create-postgres:

delete-postgres:
kubectl --kubeconfig kubeconfig delete -f config/samples/database_v1_postgres.yaml

helm-clean:
rm -f charts/postgreslet/Chart.lock
rm -f charts/postgreslet/charts/*

helm:
helm package charts/postgreslet-support/
helm dependency build charts/postgreslet/
helm package charts/postgreslet/
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,37 @@ Delete _postgres_ on control-cluster and all the local corresponding resources.
```sh
make delete-postgres
```

## Local Helm Development

Delete and recreate all existing kind clusters (optional)

```sh
kind delete cluster --name ctrl
kind delete cluster
kind create cluster --name ctrl --kubeconfig ./kubeconfig --config ctrl-cluster-config
kind create cluster
```

Build the charts

```sh
make helm-clean
make helm
```

Prepare the control cluster

```sh
helm --kubeconfig kubeconfig upgrade --install postgreslet-support postgreslet-support-0.1.0.tgz
kubectl --kubeconfig kubeconfig get postgres -A
```

Install the Postgreslet to the service cluster

```sh
make kind-load-image
kubectl create namespace postgreslet-system
helm upgrade --install postgreslet postgreslet-0.1.0.tgz --namespace postgreslet-system --set-file controlplaneKubeconfig=kubeconfig --set image.tag=latest
kubectl get po -A --watch
```
23 changes: 23 additions & 0 deletions charts/postgreslet-support/.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/
24 changes: 24 additions & 0 deletions charts/postgreslet-support/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: postgreslet-support
description: A Helm chart for installing support for postgres resources, which can be used by the Postgreslet

# 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: "v0"
136 changes: 136 additions & 0 deletions charts/postgreslet-support/crds/postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.5
name: postgres.database.fits.cloud
spec:
group: database.fits.cloud
names:
kind: Postgres
listKind: PostgresList
plural: postgres
singular: postgres
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.version
name: Version
type: string
- jsonPath: .status.description
name: Status
type: string
name: v1
schema:
openAPIV3Schema:
description: Postgres is the Schema for the postgres API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: PostgresSpec defines the desired state of Postgres
properties:
accessList:
description: AccessList defines access restrictions
properties:
sourceRanges:
description: SourceRanges defines a list of prefixes in CIDR Notation e.g. 1.2.3.0/24 FIXME implement validation if source is a parsable CIDR
items:
type: string
type: array
type: object
backup:
description: 'todo: add default Backup parametes of the database backup'
properties:
retention:
description: Retention defines how many days a backup will persist
format: int32
type: integer
s3BucketURL:
description: S3BucketURL defines the URL of the S3 bucket for backup
type: string
schedule:
description: Schedule defines how often a backup should be made, in cron format
type: string
type: object
description:
description: Description
type: string
maintenance:
description: 'todo: add default Maintenance defines automatic maintenance of the database'
properties:
timeWindow:
description: TimeWindow defines when the maintenance should happen
properties:
end:
format: date-time
type: string
start:
format: date-time
type: string
type: object
weekday:
description: Weekday defines when the operator is allowed to do maintenance
type: integer
type: object
numberOfInstances:
default: 1
description: NumberOfInstances number of replicas
format: int32
minimum: 1
type: integer
partitionID:
description: PartitionID the partition where the database is created
type: string
projectID:
description: ProjectID metal project ID
type: string
size:
description: Size of the database
properties:
cpu:
description: CPU is in the format as pod.spec.resource.request.cpu
type: string
sharedBuffer:
description: SharedBuffer of the database
type: string
storageSize:
default: 1Gi
description: StorageSize the amount of Storage this database will get
pattern: ^[1-9][0-9]*Gi
type: string
type: object
tenant:
description: Tenant metal tenant
type: string
version:
default: "12"
description: Version is the version of Postgre-as-a-Service
enum:
- "12"
type: string
type: object
status:
description: PostgresStatus defines the observed state of Postgres
properties:
description:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run "make" to regenerate code after modifying this file'
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
23 changes: 23 additions & 0 deletions charts/postgreslet/.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/
30 changes: 30 additions & 0 deletions charts/postgreslet/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v2
name: postgreslet
description: A Helm chart for deploying the Postgres Controller aka Postgreslet

# 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: "0.0.1"

dependencies:
- name: postgreslet-support
version: 0.1.0
# TODO define repo
repository: file://../postgreslet-support
73 changes: 73 additions & 0 deletions charts/postgreslet/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "postgreslet.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 "postgreslet.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 "postgreslet.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "postgreslet.labels" -}}
helm.sh/chart: {{ include "postgreslet.chart" . }}
{{ include "postgreslet.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "postgreslet.selectorLabels" -}}
app.kubernetes.io/name: {{ include "postgreslet.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the prefix to use in (cluster)role names and bindings
*/}}
{{- define "postgreslet.roleNamePrefix" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "postgreslet.fullname" .) .Values.serviceAccount.roleNamePrefix }}
{{- else }}
{{- default "postgreslet" .Values.serviceAccount.roleNamePrefix }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "postgreslet.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "postgreslet.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Loading