Skip to content

Commit

Permalink
feat: port features from cnpg chart (#173)
Browse files Browse the repository at this point in the history
Signed-off-by: Niccolò Fei <[email protected]>
Signed-off-by: Tao Li <[email protected]>
Co-authored-by: Jaime Silvela <[email protected]>
Co-authored-by: Tao Li <[email protected]>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent 30128b8 commit a2c8017
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 79 deletions.
29 changes: 16 additions & 13 deletions charts/edb-postgres-for-kubernetes/README.md

Large diffs are not rendered by default.

24 changes: 20 additions & 4 deletions charts/edb-postgres-for-kubernetes/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,37 @@ spec:
{{- include "edb-postgres-for-kubernetes.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "edb-postgres-for-kubernetes.selectorLabels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
{{- end }}
{{- if .Values.dnsPolicy }}
dnsPolicy: {{ .Values.dnsPolicy }}
{{- end }}
containers:
- args:
- controller
- --leader-elect
{{- with .Values.config.name }}
- --config-map-name={{ . }}
- --secret-name={{ . }}
{{- if .Values.config.name }}
{{- if not .Values.config.secret }}
- --config-map-name={{ .Values.config.name }}
{{- else }}
- --secret-name={{ .Values.config.name }}
{{- end }}
{{- end }}
- --webhook-port={{ .Values.webhook.port }}
{{- range .Values.additionalArgs }}
Expand All @@ -68,6 +81,9 @@ spec:
- name: WATCH_NAMESPACE
value: "{{ .Release.Namespace }}"
{{- end }}
{{- if .Values.additionalEnv }}
{{- tpl (.Values.additionalEnv | toYaml) . | nindent 8 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
livenessProbe:
Expand Down
43 changes: 43 additions & 0 deletions charts/edb-postgres-for-kubernetes/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2021 EnterpriseDB Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
{{- if .Values.monitoring.podMonitorEnabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "edb-postgres-for-kubernetes.fullname" . }}
labels:
{{- include "edb-postgres-for-kubernetes.labels" . | nindent 4 }}
{{- with .Values.monitoring.podMonitorAdditionalLabels }}
{{- toYaml . | nindent 4 }}
{{- end}}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "edb-postgres-for-kubernetes.selectorLabels" . | nindent 6 }}
podMetricsEndpoints:
- port: metrics
{{- with .Values.monitoring.podMonitorMetricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.monitoring.podMonitorRelabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
50 changes: 50 additions & 0 deletions charts/edb-postgres-for-kubernetes/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,54 @@ subjects:
name: {{ include "edb-postgres-for-kubernetes.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "edb-postgres-for-kubernetes.fullname" . }}-view
labels:
{{- include "edb-postgres-for-kubernetes.labels" . | nindent 4 }}
{{- if .Values.rbac.aggregateClusterRoles }}
rbac.authorization.k8s.io/aggregate-to-view: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-admin: "true"
{{- end }}
rules:
- apiGroups:
- postgresql.k8s.enterprisedb.io
resources:
- backups
- clusters
- poolers
- scheduledbackups
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "edb-postgres-for-kubernetes.fullname" . }}-edit
labels:
{{- include "edb-postgres-for-kubernetes.labels" . | nindent 4 }}
{{- if .Values.rbac.aggregateClusterRoles }}
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-admin: "true"
{{- end }}
rules:
- apiGroups:
- postgresql.k8s.enterprisedb.io
resources:
- backups
- clusters
- poolers
- scheduledbackups
verbs:
- create
- delete
- deletecollection
- patch
- update
---
{{- end }}

This file was deleted.

51 changes: 32 additions & 19 deletions charts/edb-postgres-for-kubernetes/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"additionalArgs": {
"type": "array"
},
"additionalEnv": {
"type": "array"
},
"affinity": {
"type": "object"
},
Expand Down Expand Up @@ -80,9 +83,15 @@
}
}
},
"dnsPolicy": {
"type": "string"
},
"fullnameOverride": {
"type": "string"
},
"hostNetwork": {
"type": "boolean"
},
"image": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -128,6 +137,23 @@
}
}
},
"monitoring": {
"type": "object",
"properties": {
"podMonitorAdditionalLabels": {
"type": "object"
},
"podMonitorEnabled": {
"type": "boolean"
},
"podMonitorMetricRelabelings": {
"type": "array"
},
"podMonitorRelabelings": {
"type": "array"
}
}
},
"monitoringQueriesConfigMap": {
"type": "object",
"properties": {
Expand All @@ -148,6 +174,9 @@
"podAnnotations": {
"type": "object"
},
"podLabels": {
"type": "object"
},
"podSecurityContext": {
"type": "object",
"properties": {
Expand All @@ -170,6 +199,9 @@
"rbac": {
"type": "object",
"properties": {
"aggregateClusterRoles": {
"type": "boolean"
},
"create": {
"type": "boolean"
}
Expand Down Expand Up @@ -206,25 +238,6 @@
}
}
},
"test": {
"type": "object",
"properties": {
"image": {
"type": "object",
"properties": {
"pullPolicy": {
"type": "string"
},
"repository": {
"type": "string"
},
"tag": {
"type": "string"
}
}
}
}
},
"tolerations": {
"type": "array"
},
Expand Down
54 changes: 40 additions & 14 deletions charts/edb-postgres-for-kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ imagePullSecrets:
nameOverride: ""
fullnameOverride: ""

hostNetwork: false
dnsPolicy: ""

crds:
# -- Specifies whether the CRDs should be created when installing the chart.
create: true

# -- The webhook configuration.
webhook:
port: 9443
mutating:
Expand All @@ -58,24 +63,36 @@ webhook:
config:
# -- Specifies whether the secret should be created
create: true
# -- Specifies whether it should be stored in a secret, instead of a configmap
# -- The name of the configmap/secret to use.
name: postgresql-operator-controller-manager-config
# -- Specifies whether it should be stored in a secret, instead of a configmap.
secret: false
# -- This option determines if the operator is responsible for observing
# events across the entire Kubernetes cluster or if its focus should be
# narrowed down to the specific namespace within which it has been deployed.
clusterWide: true
# Examples:
# -- The content of the configmap/secret, see
# https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/operator_conf/#available-options
# for all the available options.
data:
PULL_SECRET_NAME: edb-pull-secret
# INHERITED_ANNOTATIONS: categories
# INHERITED_LABELS: environment, workload, app
# WATCH_NAMESPACE: namespace-a,namespace-b
# EDB_LICENSE_KEY: <YOUR_EDB_LICENSE_KEY_HERE>

data:
PULL_SECRET_NAME: edb-pull-secret
name: postgresql-operator-controller-manager-config

# -- Additional arguments to be added to the operator's args list
additionalArgs: []

# -- Array containing extra environment variables which can be templated.
# For example:
# - name: RELEASE_NAME
# value: "{{ .Release.Name }}"
# - name: MY_VAR
# value: "mySpecialKey"
additionalEnv: []

serviceAccount:
# -- Specifies whether the service account should be created
create: true
Expand All @@ -86,11 +103,16 @@ serviceAccount:
rbac:
# -- Specifies whether ClusterRole and ClusterRoleBinding should be created
create: true
# -- Aggregate ClusterRoles to Kubernetes default user-facing roles.
# Ref: https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles
aggregateClusterRoles: false

# -- Annotations to be added to the pod
podAnnotations: {}
# -- Annotations to be added to all other resources
# -- Annotations to be added to all other resources.
commonAnnotations: {}
# -- Annotations to be added to the pod.
podAnnotations: {}
# -- Labels to be added to the pod.
podLabels: {}

# -- Container Security Context
containerSecurityContext:
Expand Down Expand Up @@ -141,12 +163,16 @@ tolerations: []
# -- Affinity for the operator to be installed
affinity: {}

# -- Test related configurations
test:
image:
repository: busybox
pullPolicy: IfNotPresent
tag: "latest"
monitoring:

# -- Specifies whether the monitoring should be enabled. Requires Prometheus Operator CRDs.
podMonitorEnabled: false
# -- Metrics relabel configurations to apply to samples before ingestion.
podMonitorMetricRelabelings: []
# -- Relabel configurations to apply to samples before scraping.
podMonitorRelabelings: []
# -- Additional labels for the podMonitor
podMonitorAdditionalLabels: {}

# Default monitoring queries
monitoringQueriesConfigMap:
Expand Down

0 comments on commit a2c8017

Please sign in to comment.