Skip to content

Commit e0d7400

Browse files
jmckulkjkatz
authored andcommitted
Adds support for metrics
This change adds a chart that will install the metrics infrastructure.
1 parent 94e0118 commit e0d7400

File tree

11 files changed

+689
-1
lines changed

11 files changed

+689
-1
lines changed

docs/content/installation/other/helm.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ After configuring the `values.yaml` file with you configuration options, the
2020
installer will be run using the `helm` command line tool and takes care of
2121
setting up all of the objects required to run the PostgreSQL Operator.
2222

23-
The Helm chart is available in the [Helm](https://github.com/CrunchyData/postgres-operator/tree/master/installers/helm)
23+
The `postgres-operator` Helm chart is available in the [Helm](https://github.com/CrunchyData/postgres-operator/tree/master/installers/helm)
2424
directory in the PostgreSQL Operator repository.
2525

2626
## Requirements
@@ -176,6 +176,33 @@ pgo client version 4.4.0-beta.1
176176
pgo-apiserver version 4.4.0-beta.1
177177
```
178178

179+
## Metrics Chart
180+
181+
The PostgreSQL Operator metrics infrastructure can be installed using a separate
182+
Helm chart. This chart can install or uninstall metrics in a namespace where
183+
the operator is currently running. The metrics installer runs similarly to the
184+
`postgres-operator` chart by creating the ServiceAccount, RBAC resources,
185+
and ConfigMap that are needed to run the install job.
186+
187+
The `metrics` Helm chart is available in the [Helm](https://github.com/CrunchyData/postgres-operator/tree/master/installers/helm)
188+
directory in the PostgreSQL Operator repository.
189+
190+
### Installing
191+
192+
{{% notice tip %}}
193+
Ensure that you have install the PostgreSQL Operator before installing metrics.
194+
{{% /notice %}}
195+
196+
```shell
197+
helm install metrics -n pgo /path/to/metrics/chart_dir
198+
```
199+
200+
### Uninstalling
201+
202+
```shell
203+
helm install metrics -n pgo /path/to/metrics/chart_dir
204+
```
205+
179206
## Upgrade and Uninstall
180207

181208
Once install has be completed using Helm, it will also be used to upgrade and

installers/helm/metrics/Chart.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v2
2+
name: postgres-operator-metrics
3+
description: Metrics Install for Crunchy PostgreSQL Operator
4+
type: application
5+
version: 0.1.0
6+
appVersion: 4.4.0-beta.1
7+
home: https://github.com/CrunchyData/postgres-operator
8+
icon: https://github.com/CrunchyData/postgres-operator/raw/master/crunchy_logo.png

installers/helm/metrics/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Installing Metrics Infrastructure
2+
3+
This Helm chart installs the metrics deployment for Crunchy PostgreSQL Operator
4+
by using its “pgo-deployer” container. Helm will setup the ServiceAccount, RBAC,
5+
and ConfigMap needed to run the container as a Kubernetes Job. Then a job will
6+
be created based on `helm` `install`, or `uninstall` to install or uninstall
7+
metrics. After the job has completed the RBAC will be cleaned up.
8+
9+
## Prerequisites
10+
11+
- Helm v3
12+
- Kubernetes 1.14+
13+
14+
## Getting the chart
15+
16+
Clone the `postgres-operator` repo:
17+
```
18+
git clone https://github.com/CrunchyData/postgres-operator.git
19+
```
20+
21+
## Installing
22+
23+
```
24+
cd postgres-operator/installers/helm/metrics
25+
helm install metrics . -n pgo
26+
```
27+
28+
## Uninstalling
29+
30+
```
31+
cd postgres-operator/installers/helm/metrics
32+
helm uninstall metrics -n pgo
33+
```
34+
35+
## Configuraiton
36+
37+
The following shows the configurable parameters that are relevant to the Helm
38+
Chart. A full list of all Crunchy PostgreSQL Operator configuration options can
39+
be found in the [documentation](https://access.crunchydata.com/documentation/postgres-operator/latest/installation/configuration/).
40+
41+
| Name | Default | Description |
42+
| ---- | ------- | ----------- |
43+
| fullnameOverride | "" | |
44+
| rbac.create | true | If false RBAC will not be created. RBAC resources will need to be created manually and bound to `serviceAccount.name` |
45+
| rbac.useClusterAdmin | false | If enabled the ServiceAccount will be given cluster-admin privileges. |
46+
| serviceAccount.create | true | If false a ServiceAccount will not be created. A ServiceAccount must be created manually. |
47+
| serviceAccount.name | "" | Use to override the default ServiceAccount name. If serviceAccount.create is false this ServiceAccount will be used. |
48+
49+
{{% notice tip %}}
50+
If installing into an OpenShift 3.11 or Kubernetes 1.11 cluster `rbac.useClusterAdmin` must be enabled.
51+
{{% /notice %}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Thank you for installing the Crunchy PostgreSQL Operator Metrics v{{ .Chart.AppVersion }}!
2+
3+
((((((((((((((((((((((
4+
(((((((((((((%%%%%%%(((((((((((((((
5+
(((((((((((%%% %%%%((((((((((((
6+
(((((((((((%%( (((( ( %%%(((((((((((
7+
(((((((((((((%% (( ,(( %%%(((((((((((
8+
(((((((((((((((%% *%%/ %%%%%%%((((((((((
9+
(((((((((((((((((((%%(( %%%%%%%%%%#(((((%%%%%%%%%%#((((((((((((
10+
((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%((((((((((((((
11+
*((((((((((((((((((((%%%%%% /%%%%%%%%%%%%%%%%%%%((((((((((((((((
12+
(((((((((((((((((((((((%%%/ .%, %%%((((((((((((((((((,
13+
((((((((((((((((((((((% %#(((((((((((((((((
14+
(((((((((((((((%%%%%% #%(((((((((((((((((
15+
((((((((((((((%% %%(((((((((((((((,
16+
((((((((((((%%%#% % %%(((((((((((((((
17+
((((((((((((%. % % #((((((((((((((
18+
(((((((((((%% % %%* %(((((((((((((
19+
#(###(###(#%% %%% %% %%% #%%#(###(###(#
20+
###########%%%%% /%%%%%%%%%%%%% %% %%%%% ,%%#######
21+
###############%% %%%%%% %%% %%%%%%%% %%#####
22+
################%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %%##
23+
################%% %%%%%%%%%%%%%%%%% %%%% %
24+
##############%# %% (%%%%%%% %%%%%%
25+
#############% %%%%% %%%%%%%%%%%
26+
###########% %%%%%%%%%%% %%%%%%%%%
27+
#########%% %% %%%%%%%%%%%%%%%#
28+
########%% %% %%%%%%%%%
29+
######%% %% %%%%%%
30+
####%%% %%%%% %
31+
%% %%%%
32+
33+
More information on using the postgres-operator can be found in the docs:
34+
https://access.crunchydata.com/documentation/postgres-operator/
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- define "deployerJob.spec" }}
2+
spec:
3+
backoffLimit: 0
4+
template:
5+
metadata:
6+
name: pgo-deploy
7+
labels:
8+
{{ include "postgres-operator.labels" . | indent 8 }}
9+
spec:
10+
serviceAccountName: {{ include "postgres-operator.serviceAccountName" . }}
11+
restartPolicy: Never
12+
containers:
13+
- name: pgo-deploy
14+
image: {{ .Values.pgo_image_prefix }}/pgo-deployer:{{ .Values.pgo_image_tag }}
15+
imagePullPolicy: IfNotPresent
16+
env:
17+
- name: DEPLOY_ACTION
18+
value: "{{ .deployAction }}"
19+
volumeMounts:
20+
- name: deployer-conf
21+
mountPath: "/conf"
22+
volumes:
23+
- name: deployer-conf
24+
configMap:
25+
name: {{ template "postgres-operator.fullname" . }}-cm
26+
{{- end }}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "postgres-operator.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-operator.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-operator.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
32+
{{- end }}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "postgres-operator.labels" -}}
38+
helm.sh/chart: {{ include "postgres-operator.chart" . }}
39+
{{ include "postgres-operator.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
meta.helm.sh/release-name: {{ .Release.Name }}
45+
meta.helm.sh/release-namespace: {{ .Release.Namespace }}
46+
{{- end }}
47+
48+
{{/*
49+
Selector labels
50+
*/}}
51+
{{- define "postgres-operator.selectorLabels" -}}
52+
app.kubernetes.io/name: {{ include "postgres-operator.name" . }}
53+
app.kubernetes.io/instance: {{ .Release.Name }}
54+
{{- end }}
55+
56+
{{/*
57+
Create the name of the service account to use
58+
*/}}
59+
{{- define "postgres-operator.serviceAccountName" -}}
60+
{{- if .Values.serviceAccount.create }}
61+
{{- default "pgo-deployer-metrics-sa" .Values.serviceAccount.name }}
62+
{{- else }}
63+
{{- default "default" .Values.serviceAccount.name }}
64+
{{- end }}
65+
{{- end }}
66+
67+
{{/*
68+
Create the template for image pull secrets
69+
*/}}
70+
{{- define "postgres-operator.imagePullSecret" -}}
71+
{{- if ne .Values.pgo_image_pull_secret "" }}
72+
imagePullSecrets:
73+
- name: "{{ .Values.pgo_image_pull_secret }}"
74+
{{ end }}
75+
{{ end }}
76+
77+
{{/*
78+
Create the template for clusterroleName based on values.yaml parameters
79+
*/}}
80+
{{- define "postgres-operator.clusterroleName" -}}
81+
{{- if .Values.rbac.useClusterAdmin -}}
82+
cluster-admin
83+
{{- else -}}
84+
{{ include "postgres-operator.fullname" . }}-cr
85+
{{- end }}
86+
{{- end }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{ $_ := set . "deployAction" "install-metrics" }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: pgo-deploy
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{ include "postgres-operator.labels" . | indent 4 }}
10+
annotations:
11+
helm.sh/hook: post-install
12+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
13+
{{ template "deployerJob.spec" . }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{ $_ := set . "deployAction" "uninstall-metrics" }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: pgo-deploy
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{ include "postgres-operator.labels" . | indent 4 }}
10+
annotations:
11+
helm.sh/hook: pre-delete
12+
helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation
13+
{{ template "deployerJob.spec" . }}

0 commit comments

Comments
 (0)