@@ -5,22 +5,9 @@ PGO_IMAGE_DESCRIPTION ?= $(PGO_IMAGE_SUMMARY)
5
5
PGO_IMAGE_URL ?= https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes
6
6
PGO_IMAGE_PREFIX ?= localhost
7
7
8
- CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME ?= crunchy-postgres-exporter
9
- CRUNCHY_POSTGRES_EXPORTER_MAINTAINER ?= $(PGO_IMAGE_MAINTAINER )
10
- CRUNCHY_POSTGRES_EXPORTER_SUMMARY ?= Metrics exporter for PostgreSQL
11
- CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION ?= \
12
- When run with the crunchy-postgres family of containers, crunchy-postgres-exporter reads the PostgreSQL data directory \
13
- and has a SQL interface to a database to allow for metrics collection.
14
- CRUNCHY_POSTGRES_EXPORTER_URL ?= https://www.crunchydata.com/products/crunchy-postgresql-for-kubernetes
15
- CRUNCHY_POSTGRES_EXPORTER_IMAGE_PREFIX ?= $(PGO_IMAGE_PREFIX )
16
- CRUNCHY_POSTGRES_EXPORTER_PG_VERSION ?= 15
17
- CRUNCHY_POSTGRES_EXPORTER_PG_FULL_VERSION ?= 15.3
18
-
19
8
PGMONITOR_DIR ?= hack/tools/pgmonitor
20
9
PGMONITOR_VERSION ?= v4.8.1
21
- POSTGRES_EXPORTER_VERSION ?= 0.12.1
22
- POSTGRES_EXPORTER_ARCHITECTURE ?= amd64
23
- POSTGRES_EXPORTER_URL ?= https://github.com/prometheus-community/postgres_exporter/releases/download/v${POSTGRES_EXPORTER_VERSION}/postgres_exporter-${POSTGRES_EXPORTER_VERSION}.linux-${POSTGRES_EXPORTER_ARCHITECTURE}.tar.gz
10
+ QUERIES_CONFIG_DIR ?= hack/tools/queries
24
11
25
12
# Buildah's "build" used to be "bud". Use the alias to be compatible for a while.
26
13
BUILDAH_BUILD ?= buildah bud
@@ -58,23 +45,19 @@ help: ## Display this help.
58
45
.PHONY : all
59
46
all : # # Build all images
60
47
all : build-postgres-operator-image
61
- all : build-crunchy-postgres-exporter-image
62
48
63
49
.PHONY : setup
64
50
setup : # # Run Setup needed to build images
65
51
setup : get-pgmonitor
66
- setup : get-postgres-exporter
67
52
68
53
.PHONY : get-pgmonitor
69
54
get-pgmonitor :
70
55
git -C ' $(dir $(PGMONITOR_DIR))' clone https://github.com/CrunchyData/pgmonitor.git || git -C ' $(PGMONITOR_DIR)' fetch origin
71
56
@git -C ' $(PGMONITOR_DIR)' checkout ' $(PGMONITOR_VERSION)'
72
57
@git -C ' $(PGMONITOR_DIR)' config pull.ff only
73
-
74
- .PHONY : get-postgres-exporter
75
- get-postgres-exporter :
76
- [ ! -e hack/tools/postgres_exporter.tar.gz ] || (rm hack/tools/postgres_exporter.tar.gz && echo " Deleting old exporter" )
77
- wget -O hack/tools/postgres_exporter.tar.gz ' $(POSTGRES_EXPORTER_URL)'
58
+ [ -d ' ${QUERIES_CONFIG_DIR}' ] || mkdir -p ' ${QUERIES_CONFIG_DIR}'
59
+ cp -r ' $(PGMONITOR_DIR)/postgres_exporter/common/.' ' ${QUERIES_CONFIG_DIR}'
60
+ cp ' $(PGMONITOR_DIR)/postgres_exporter/linux/queries_backrest.yml' ' ${QUERIES_CONFIG_DIR}'
78
61
79
62
.PHONY : clean
80
63
clean : # # Clean resources
@@ -105,6 +88,10 @@ clean-deprecated: ## Clean deprecated resources
105
88
@# keys used to be generated before install
106
89
[ ! -d conf/pgo-backrest-repo ] || rm -r conf/pgo-backrest-repo
107
90
[ ! -d conf/postgres-operator ] || rm -r conf/postgres-operator
91
+ @# crunchy-postgres-exporter used to live in this repo
92
+ [ ! -d bin/crunchy-postgres-exporter ] || rm -r bin/crunchy-postgres-exporter
93
+ [ ! -d build/crunchy-postgres-exporter ] || rm -r build/crunchy-postgres-exporter
94
+
108
95
109
96
# #@ Deployment
110
97
.PHONY : createnamespaces
@@ -134,11 +121,13 @@ undeploy: ## Undeploy the PostgreSQL Operator
134
121
.PHONY : deploy-dev
135
122
deploy-dev : # # Deploy the PostgreSQL Operator locally
136
123
deploy-dev : PGO_FEATURE_GATES ?= "TablespaceVolumes=true"
124
+ deploy-dev : get-pgmonitor
137
125
deploy-dev : build-postgres-operator
138
126
deploy-dev : createnamespaces
139
127
kubectl apply --server-side -k ./config/dev
140
128
hack/create-kubeconfig.sh postgres-operator pgo
141
129
env \
130
+ QUERIES_CONFIG_DIR=" ${QUERIES_CONFIG_DIR} " \
142
131
CRUNCHY_DEBUG=true \
143
132
PGO_FEATURE_GATES=" ${PGO_FEATURE_GATES} " \
144
133
CHECK_FOR_UPGRADES=' $(if $(CHECK_FOR_UPGRADES),$(CHECK_FOR_UPGRADES),false)' \
@@ -158,45 +147,6 @@ build-postgres-operator: ## Build the postgres-operator binary
158
147
-o bin/postgres-operator ./cmd/postgres-operator
159
148
160
149
# #@ Build - Images
161
- .PHONY : build-crunchy-postgres-exporter-image
162
- build-crunchy-postgres-exporter-image : # # Build the crunchy-postgres-exporter image
163
- build-crunchy-postgres-exporter-image : CRUNCHY_POSTGRES_EXPORTER_IMAGE_REVISION := $(shell git rev-parse HEAD)
164
- build-crunchy-postgres-exporter-image : CRUNCHY_POSTGRES_EXPORTER_IMAGE_TIMESTAMP := $(shell date -u +% FT% TZ)
165
- build-crunchy-postgres-exporter-image : build/crunchy-postgres-exporter/Dockerfile
166
- $(if $(shell (echo 'buildah version 1.24'; $(word 1,$(BUILDAH_BUILD ) ) --version) | sort -Vc 2>&1) , \
167
- $(warning WARNING: old buildah does not invalidate its cache for changed labels: \
168
- https://github.com/containers/buildah/issues/3517))
169
- $(if $(IMAGE_TAG ) ,, $(error missing IMAGE_TAG) )
170
- $(strip $(BUILDAH_BUILD ) ) \
171
- --tag $(BUILDAH_TRANSPORT )$(CRUNCHY_POSTGRES_EXPORTER_IMAGE_PREFIX ) /$(CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME ) :$(IMAGE_TAG ) \
172
- --build-arg PGVERSION=$(CRUNCHY_POSTGRES_EXPORTER_PG_VERSION ) \
173
- --label name=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME)' \
174
- --label build-date=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_TIMESTAMP)' \
175
- --label description=' $(CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION)' \
176
- --label maintainer=' $(CRUNCHY_POSTGRES_EXPORTER_MAINTAINER)' \
177
- --label summary=' $(CRUNCHY_POSTGRES_EXPORTER_SUMMARY)' \
178
- --label url=' $(CRUNCHY_POSTGRES_EXPORTER_URL)' \
179
- --label vcs-ref=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_REVISION)' \
180
- --label vendor=' $(CRUNCHY_POSTGRES_EXPORTER_MAINTAINER)' \
181
- --label postgres.version.major=' $(CRUNCHY_POSTGRES_EXPORTER_PG_VERSION)' \
182
- --label postgres.version=' $(CRUNCHY_POSTGRES_EXPORTER_PG_FULL_VERSION)' \
183
- --label io.k8s.display-name=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME)' \
184
- --label io.k8s.description=' $(CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION)' \
185
- --label io.openshift.tags=" postgresql,postgres,monitoring,database,crunchy" \
186
- --annotation org.opencontainers.image.authors=' $(CRUNCHY_POSTGRES_EXPORTER_MAINTAINER)' \
187
- --annotation org.opencontainers.image.vendor=' $(CRUNCHY_POSTGRES_EXPORTER_MAINTAINER)' \
188
- --annotation org.opencontainers.image.created=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_TIMESTAMP)' \
189
- --annotation org.opencontainers.image.description=' $(CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION)' \
190
- --annotation org.opencontainers.image.revision=' $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_REVISION)' \
191
- --annotation org.opencontainers.image.title=' $(CRUNCHY_POSTGRES_EXPORTER_SUMMARY)' \
192
- --annotation org.opencontainers.image.url=' $(CRUNCHY_POSTGRES_EXPORTER_URL)' \
193
- $(if $(PGO_VERSION ) ,$(strip \
194
- --label release=' $(PGO_VERSION)' \
195
- --label version=' $(PGO_VERSION)' \
196
- --annotation org.opencontainers.image.version=' $(PGO_VERSION)' \
197
- )) \
198
- --file $< --format docker --layers .
199
-
200
150
.PHONY : build-postgres-operator-image
201
151
build-postgres-operator-image : # # Build the postgres-operator image
202
152
build-postgres-operator-image : PGO_IMAGE_REVISION := $(shell git rev-parse HEAD)
@@ -245,7 +195,7 @@ check: ## Run basic go tests with coverage output
245
195
check-envtest : # # Run check using envtest and a mock kube api
246
196
check-envtest : ENVTEST_USE = hack/tools/setup-envtest --bin-dir=$(CURDIR ) /hack/tools/envtest use $(ENVTEST_K8S_VERSION )
247
197
check-envtest : SHELL = bash
248
- check-envtest :
198
+ check-envtest : get-pgmonitor
249
199
GOBIN=' $(CURDIR)/hack/tools' $(GO ) install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
250
200
@$(ENVTEST_USE ) --print=overview && echo
251
201
source <( $( ENVTEST_USE) --print=env) && PGO_NAMESPACE=" postgres-operator" $(GO_TEST ) -count=1 -cover -tags=envtest ./...
@@ -256,6 +206,7 @@ check-envtest:
256
206
# make check-envtest-existing PGO_TEST_TIMEOUT_SCALE=1.2
257
207
.PHONY : check-envtest-existing
258
208
check-envtest-existing : # # Run check using envtest and an existing kube api
209
+ check-envtest-existing : get-pgmonitor
259
210
check-envtest-existing : createnamespaces
260
211
kubectl apply --server-side -k ./config/dev
261
212
USE_EXISTING_CLUSTER=true PGO_NAMESPACE=" postgres-operator" $(GO_TEST ) -count=1 -cover -p=1 -tags=envtest ./...
@@ -366,14 +317,3 @@ release-postgres-operator-image-labels:
366
317
$(if $(PGO_IMAGE_NAME ) ,, $(error missing PGO_IMAGE_NAME) )
367
318
$(if $(PGO_IMAGE_SUMMARY ) ,, $(error missing PGO_IMAGE_SUMMARY) )
368
319
$(if $(PGO_VERSION ) ,, $(error missing PGO_VERSION) )
369
-
370
- .PHONY : release-crunchy-postgres-exporter-image release-crunchy-postgres-exporter-image-labels
371
- release-crunchy-postgres-exporter-image : # # Build the postgres-operator image and all its prerequisites
372
- release-crunchy-postgres-exporter-image : release-crunchy-postgres-exporter-image-labels
373
- release-crunchy-postgres-exporter-image : build-crunchy-postgres-exporter-image
374
- release-crunchy-postgres-exporter-image-labels :
375
- $(if $(CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION ) ,, $(error missing CRUNCHY_POSTGRES_EXPORTER_DESCRIPTION) )
376
- $(if $(CRUNCHY_POSTGRES_EXPORTER_MAINTAINER ) ,, $(error missing CRUNCHY_POSTGRES_EXPORTER_MAINTAINER) )
377
- $(if $(CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME ) ,, $(error missing CRUNCHY_POSTGRES_EXPORTER_IMAGE_NAME) )
378
- $(if $(CRUNCHY_POSTGRES_EXPORTER_SUMMARY ) ,, $(error missing CRUNCHY_POSTGRES_EXPORTER_SUMMARY) )
379
- $(if $(PGO_VERSION ) ,, $(error missing PGO_VERSION) )
0 commit comments