Skip to content

Commit 2994fd9

Browse files
committed
feat(deploy): add Helm chart
1 parent f47a26a commit 2994fd9

11 files changed

+528
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: managed-postgres-operator
3+
description: A Helm chart for the managed-postgres-operator
4+
type: application
5+
version: 0.1.0
6+
appVersion: "1.16.0"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../crds
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "managed-postgres-operator.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "managed-postgres-operator.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "managed-postgres-operator.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "managed-postgres-operator.labels" -}}
37+
helm.sh/chart: {{ include "managed-postgres-operator.chart" . }}
38+
{{ include "managed-postgres-operator.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "managed-postgres-operator.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "managed-postgres-operator.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "managed-postgres-operator.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "managed-postgres-operator.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: {{ include "managed-postgres-operator.fullname" . }}
6+
labels:
7+
{{- include "managed-postgres-operator.labels" . | nindent 4 }}
8+
rules:
9+
- apiGroups:
10+
- managed-postgres-operator.hoppscale.com
11+
resources:
12+
- postgresdatabases
13+
- postgresroles
14+
- postgresschemas
15+
verbs:
16+
- create
17+
- delete
18+
- get
19+
- list
20+
- patch
21+
- update
22+
- watch
23+
- apiGroups:
24+
- managed-postgres-operator.hoppscale.com
25+
resources:
26+
- postgresdatabases/finalizers
27+
- postgresroles/finalizers
28+
- postgresschemas/finalizers
29+
verbs:
30+
- update
31+
- apiGroups:
32+
- managed-postgres-operator.hoppscale.com
33+
resources:
34+
- postgresdatabases/status
35+
- postgresroles/status
36+
- postgresschemas/status
37+
verbs:
38+
- get
39+
- patch
40+
- update
41+
- apiGroups:
42+
- ""
43+
resources:
44+
- secrets
45+
verbs:
46+
- create
47+
- update
48+
- get
49+
- list
50+
- watch
51+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.rbac.create }}
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: {{ include "managed-postgres-operator.fullname" . }}
6+
labels:
7+
{{- include "managed-postgres-operator.labels" . | nindent 4 }}
8+
subjects:
9+
- kind: ServiceAccount
10+
name: {{ include "managed-postgres-operator.serviceAccountName" . }}
11+
namespace: {{ .Release.Namespace }}
12+
roleRef:
13+
kind: ClusterRole
14+
name: {{ include "managed-postgres-operator.fullname" . }}
15+
apiGroup: rbac.authorization.k8s.io
16+
{{- end }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "managed-postgres-operator.fullname" . }}
5+
labels:
6+
{{- include "managed-postgres-operator.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "managed-postgres-operator.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "managed-postgres-operator.labels" . | nindent 8 }}
20+
{{- with .Values.podLabels }}
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
spec:
24+
{{- with .Values.imagePullSecrets }}
25+
imagePullSecrets:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
serviceAccountName: {{ include "managed-postgres-operator.serviceAccountName" . }}
29+
{{- with .Values.podSecurityContext }}
30+
securityContext:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
containers:
34+
- name: {{ .Chart.Name }}
35+
{{- with .Values.securityContext }}
36+
securityContext:
37+
{{- toYaml . | nindent 12 }}
38+
{{- end }}
39+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
imagePullPolicy: {{ .Values.image.pullPolicy }}
41+
{{- with .Values.resources }}
42+
resources:
43+
{{- toYaml . | nindent 12 }}
44+
{{- end }}
45+
{{- with .Values.nodeSelector }}
46+
nodeSelector:
47+
{{- toYaml . | nindent 8 }}
48+
{{- end }}
49+
{{- with .Values.affinity }}
50+
affinity:
51+
{{- toYaml . | nindent 8 }}
52+
{{- end }}
53+
{{- with .Values.tolerations }}
54+
tolerations:
55+
{{- toYaml . | nindent 8 }}
56+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "managed-postgres-operator.serviceAccountName" . }}
6+
labels:
7+
{{- include "managed-postgres-operator.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
replicaCount: 1
2+
3+
image:
4+
repository: ghcr.io/hoppscale/managed-postgres-operator
5+
pullPolicy: IfNotPresent
6+
tag: latest
7+
8+
imagePullSecrets: []
9+
10+
nameOverride: ""
11+
fullnameOverride: ""
12+
13+
rbac:
14+
create: true
15+
16+
serviceAccount:
17+
create: true
18+
automount: true
19+
annotations: {}
20+
name: ""
21+
22+
podAnnotations: {}
23+
podLabels: {}
24+
25+
podSecurityContext: {}
26+
27+
securityContext: {}
28+
29+
resources: {}
30+
31+
nodeSelector: {}
32+
33+
tolerations: []
34+
35+
affinity: {}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.17.2
7+
name: postgresdatabases.managed-postgres-operator.hoppscale.com
8+
spec:
9+
group: managed-postgres-operator.hoppscale.com
10+
names:
11+
kind: PostgresDatabase
12+
listKind: PostgresDatabaseList
13+
plural: postgresdatabases
14+
singular: postgresdatabase
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: PostgresDatabase is the Schema for the postgresdatabases API.
21+
properties:
22+
apiVersion:
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
28+
type: string
29+
kind:
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
36+
type: string
37+
metadata:
38+
type: object
39+
spec:
40+
description: PostgresDatabaseSpec defines the desired state of PostgresDatabase.
41+
properties:
42+
extensions:
43+
description: Extensions is the list of database extensions to install
44+
on the database.
45+
items:
46+
type: string
47+
type: array
48+
keepOnDelete:
49+
description: KeepOnDelete will determine if the deletion of the object
50+
should drop the remote PostgreSQL database. Default is false.
51+
type: boolean
52+
name:
53+
description: Name is the PostgreSQL database's name.
54+
type: string
55+
x-kubernetes-validations:
56+
- message: name is immutable
57+
rule: self == oldSelf
58+
owner:
59+
description: Owner is the PostgreSQL database's owner. It must be
60+
a valid existing role.
61+
type: string
62+
preserveConnectionsOnDelete:
63+
description: PreserveConnectionsOnDelete will determine if the deletion
64+
of the object should drop the existing connections to the remote
65+
PostgreSQL database. Default is false.
66+
type: boolean
67+
privilegesByRole:
68+
additionalProperties:
69+
description: PostgresDatabasePrivilegesSpec defines the desired
70+
database privileges to grant to roles
71+
properties:
72+
connect:
73+
type: boolean
74+
create:
75+
type: boolean
76+
temporary:
77+
type: boolean
78+
type: object
79+
description: PrivilegesByRole will grant privileges to roles
80+
type: object
81+
required:
82+
- name
83+
type: object
84+
status:
85+
description: PostgresDatabaseStatus defines the observed state of PostgresDatabase.
86+
properties:
87+
succeeded:
88+
type: boolean
89+
required:
90+
- succeeded
91+
type: object
92+
type: object
93+
served: true
94+
storage: true
95+
subresources:
96+
status: {}

0 commit comments

Comments
 (0)