Skip to content

Commit 24f424f

Browse files
committed
K8SPS-393
1 parent d7aa0be commit 24f424f

File tree

13 files changed

+138
-125
lines changed

13 files changed

+138
-125
lines changed

deploy/cr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ spec:
360360
storage: 1G
361361

362362
pmm:
363-
enabled: false
363+
enabled: true
364364

365-
image: perconalab/pmm-client:dev-latest
365+
image: perconalab/pmm-client:3-dev-latest
366366
imagePullPolicy: Always
367367

368368
resources:

deploy/secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ stringData:
77
root: root_password
88
xtrabackup: backup_password
99
monitor: monitor_password
10-
# pmmserverkey: my_pmm_server_key
10+
pmmserverkey: my_pmm_server_key
1111
operator: operator_password
1212
replication: replication_password
1313
orchestrator: orchestrator_password

e2e-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ full list of variables is the following one:
112112

113113
* `IMAGE` - the Operator, `perconalab/percona-server-mysql-operator:main` by default,
114114
* `IMAGE_MYSQL` - Percona Distribution for MySQL, `perconalab/percona-server:main` by default,
115-
* `IMAGE_PMM_CLIENT` - Percona Monitoring and Management (PMM) client, `perconalab/pmm-client:dev-latest` by default,
115+
* `IMAGE_PMM_CLIENT` - Percona Monitoring and Management (PMM) client, `perconalab/pmm-client:3-dev-latest` by default,
116116
* `IMAGE_PROXY` - ProxySQL, `perconalab/percona-xtradb-cluster-operator:main-proxysql` by default,
117117
* `IMAGE_HAPROXY` - HA Proxy, `perconalab/haproxy:main` by default,
118118
* `IMAGE_BACKUP` - backups, `perconalab/percona-xtrabackup:main` by default,

e2e-tests/functions

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,16 @@ deploy_pmm_server() {
9696
local additional_params="--set platform=openshift --set sa=pmm-server --set supresshttp2=false"
9797
fi
9898

99-
helm install monitoring -n "${NAMESPACE}" --set imageTag=${IMAGE_PMM_SERVER#*:} --set imageRepo=${IMAGE_PMM_SERVER%:*} $additional_params https://percona-charts.storage.googleapis.com/pmm-server-$PMM_SERVER_VERSION.tgz
99+
kubectl delete clusterrole monitoring --ignore-not-found
100+
kubectl delete clusterrolebinding monitoring --ignore-not-found
101+
102+
helm install monitoring percona/pmm -n "${NAMESPACE}" \
103+
--set fullnameOverride=monitoring \
104+
--version ${PMM_SERVER_VERSION} \
105+
--set imageTag=${IMAGE_PMM_SERVER#*:} \
106+
--set imageRepo=${IMAGE_PMM_SERVER%:*} \
107+
--set service.type=LoadBalancer \
108+
--force
100109

101110
until kubectl -n "${NAMESPACE}" exec monitoring-0 -- bash -c "ls -l /proc/*/exe 2>/dev/null| grep postgres >/dev/null"; do
102111
echo "Retry $retry"
@@ -110,15 +119,37 @@ deploy_pmm_server() {
110119
}
111120

112121
get_pmm_api_key() {
113-
local key_name=$1
122+
local key_name=$1
114123

115-
if [[ -z $key_name ]]; then
116-
key_name="operator"
117-
fi
124+
if [[ -z $key_name ]]; then
125+
key_name="operator"
126+
fi
118127

119-
local ADMIN_PASSWORD
120-
ADMIN_PASSWORD=$(kubectl -n "${NAMESPACE}" exec monitoring-0 -- bash -c "printenv | grep ADMIN_PASSWORD | cut -d '=' -f2")
121-
curl --insecure -X POST -H "Content-Type: application/json" -d "{\"name\":\"$key_name\", \"role\": \"Admin\"}" "https://admin:$ADMIN_PASSWORD@$(get_service_ip monitoring-service)/graph/api/auth/keys" | jq .key
128+
local ADMIN_PASSWORD
129+
ADMIN_PASSWORD=$(kubectl -n "${NAMESPACE}" get secret pmm-secret -o jsonpath="{.data.PMM_ADMIN_PASSWORD}" | base64 --decode)
130+
131+
if [[ -z $ADMIN_PASSWORD ]]; then
132+
echo "Error: ADMIN_PASSWORD is empty or not found!" >&2
133+
return 1
134+
fi
135+
136+
local response status_code json_response
137+
response=$(curl --insecure -s -X POST -H 'Content-Type: application/json' \
138+
-d "{\"name\":\"${key_name}\", \"role\": \"Admin\"}" \
139+
--user "admin:${ADMIN_PASSWORD}" \
140+
"https://$(get_service_ip monitoring-service)/graph/api/auth/keys" \
141+
-w "\n%{http_code}")
142+
143+
status_code=$(echo "$response" | tail -n1)
144+
json_response=$(echo "$response" | sed '$ d')
145+
146+
if [[ "$status_code" -eq 200 ]]; then
147+
echo "$json_response" | jq -r '.key'
148+
else
149+
echo "Error: Failed to get API key with HTTP status code: $status_code)" >&2
150+
echo "Response: $json_response" >&2
151+
return 1
152+
fi
122153
}
123154

124155
delete_pmm_api_key() {
@@ -129,11 +160,14 @@ delete_pmm_api_key() {
129160
fi
130161

131162
local ADMIN_PASSWORD
132-
ADMIN_PASSWORD=$(kubectl -n "${NAMESPACE}" exec monitoring-0 -- bash -c "printenv | grep ADMIN_PASSWORD | cut -d '=' -f2")
163+
ADMIN_PASSWORD=$(kubectl -n "${NAMESPACE}" get secret pmm-secret -o jsonpath="{.data.PMM_ADMIN_PASSWORD}" | base64 --decode)
164+
165+
local user_credentials="admin:${ADMIN_PASSWORD}"
133166

134167
local key_id
135-
key_id=$(curl --insecure -X GET "https://admin:$ADMIN_PASSWORD@$(get_service_ip monitoring-service)/graph/api/auth/keys" | jq '.[] | select( .name == "operator").id')
136-
curl --insecure -X DELETE "https://admin:$ADMIN_PASSWORD@$(get_service_ip monitoring-service)/graph/api/auth/keys/$key_id"
168+
key_id=$(curl --insecure -X GET --user "${user_credentials}" "https://$(get_service_ip monitoring-service)/graph/api/auth/keys" | jq '.[] | select( .name == "operator").id')
169+
170+
curl --insecure -X DELETE --user "${user_credentials}" "https://$(get_service_ip monitoring-service)/graph/api/auth/keys/$key_id"
137171
}
138172

139173
deploy_minio() {

e2e-tests/tests/monitoring/01-deploy-pmm-server.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ commands:
1111
sleep 30 # wait for PMM Server to start
1212
1313
API_KEY=$(get_pmm_api_key)
14-
kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY'}}'
14+
kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch "$(jq -n --arg key "$API_KEY" '{"stringData": {"pmmserverkey": $key}}')"
1515
timeout: 120

e2e-tests/tests/monitoring/02-assert.yaml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ spec:
2727
fieldPath: metadata.namespace
2828
- name: CLUSTER_NAME
2929
value: monitoring
30-
- name: CLIENT_PORT_LISTEN
31-
value: "7777"
32-
- name: CLIENT_PORT_MIN
33-
value: "30100"
34-
- name: CLIENT_PORT_MAX
35-
value: "30105"
3630
- name: PMM_AGENT_SERVER_ADDRESS
3731
value: monitoring-service
3832
- name: PMM_AGENT_SERVER_USERNAME
@@ -42,23 +36,14 @@ spec:
4236
secretKeyRef:
4337
key: pmmserverkey
4438
name: internal-monitoring
45-
- name: PMM_SERVER
46-
value: monitoring-service
47-
- name: PMM_USER
48-
value: api_key
49-
- name: PMM_PASSWORD
50-
valueFrom:
51-
secretKeyRef:
52-
key: pmmserverkey
53-
name: internal-monitoring
5439
- name: PMM_AGENT_LISTEN_PORT
5540
value: "7777"
5641
- name: PMM_AGENT_PORTS_MIN
5742
value: "30100"
5843
- name: PMM_AGENT_PORTS_MAX
5944
value: "30105"
6045
- name: PMM_AGENT_CONFIG_FILE
61-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
46+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
6247
- name: PMM_AGENT_SERVER_INSECURE_TLS
6348
value: "1"
6449
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -73,14 +58,14 @@ spec:
7358
value: "1"
7459
- name: PMM_AGENT_SETUP_NODE_TYPE
7560
value: container
76-
- name: PMM_AGENT_PRERUN_SCRIPT
77-
value: /opt/percona/pmm-prerun.sh
7861
- name: PMM_AGENT_SIDECAR
7962
value: "true"
8063
- name: PMM_AGENT_SIDECAR_SLEEP
8164
value: "5"
8265
- name: PMM_AGENT_PATHS_TEMPDIR
8366
value: "/tmp"
67+
- name: PMM_AGENT_PRERUN_SCRIPT
68+
value: "/opt/percona/pmm-prerun.sh"
8469
- name: DB_CLUSTER
8570
value: monitoring
8671
- name: DB_TYPE
@@ -159,12 +144,6 @@ spec:
159144
fieldPath: metadata.namespace
160145
- name: CLUSTER_NAME
161146
value: monitoring
162-
- name: CLIENT_PORT_LISTEN
163-
value: "7777"
164-
- name: CLIENT_PORT_MIN
165-
value: "30100"
166-
- name: CLIENT_PORT_MAX
167-
value: "30105"
168147
- name: PMM_AGENT_SERVER_ADDRESS
169148
value: monitoring-service
170149
- name: PMM_AGENT_SERVER_USERNAME
@@ -174,23 +153,14 @@ spec:
174153
secretKeyRef:
175154
key: pmmserverkey
176155
name: internal-monitoring
177-
- name: PMM_SERVER
178-
value: monitoring-service
179-
- name: PMM_USER
180-
value: api_key
181-
- name: PMM_PASSWORD
182-
valueFrom:
183-
secretKeyRef:
184-
key: pmmserverkey
185-
name: internal-monitoring
186156
- name: PMM_AGENT_LISTEN_PORT
187157
value: "7777"
188158
- name: PMM_AGENT_PORTS_MIN
189159
value: "30100"
190160
- name: PMM_AGENT_PORTS_MAX
191161
value: "30105"
192162
- name: PMM_AGENT_CONFIG_FILE
193-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
163+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
194164
- name: PMM_AGENT_SERVER_INSECURE_TLS
195165
value: "1"
196166
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -205,14 +175,14 @@ spec:
205175
value: "1"
206176
- name: PMM_AGENT_SETUP_NODE_TYPE
207177
value: container
208-
- name: PMM_AGENT_PRERUN_SCRIPT
209-
value: /opt/percona/pmm-prerun.sh
210178
- name: PMM_AGENT_SIDECAR
211179
value: "true"
212180
- name: PMM_AGENT_SIDECAR_SLEEP
213181
value: "5"
214182
- name: PMM_AGENT_PATHS_TEMPDIR
215183
value: "/tmp"
184+
- name: PMM_AGENT_PRERUN_SCRIPT
185+
value: "/opt/percona/pmm-prerun.sh"
216186
- name: DB_CLUSTER
217187
value: monitoring
218188
- name: DB_TYPE

e2e-tests/tests/monitoring/03-assert.yaml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ spec:
2727
fieldPath: metadata.namespace
2828
- name: CLUSTER_NAME
2929
value: monitoring
30-
- name: CLIENT_PORT_LISTEN
31-
value: "7777"
32-
- name: CLIENT_PORT_MIN
33-
value: "30100"
34-
- name: CLIENT_PORT_MAX
35-
value: "30105"
3630
- name: PMM_AGENT_SERVER_ADDRESS
3731
value: monitoring-service
3832
- name: PMM_AGENT_SERVER_USERNAME
@@ -42,23 +36,14 @@ spec:
4236
secretKeyRef:
4337
key: pmmserverkey
4438
name: internal-monitoring
45-
- name: PMM_SERVER
46-
value: monitoring-service
47-
- name: PMM_USER
48-
value: api_key
49-
- name: PMM_PASSWORD
50-
valueFrom:
51-
secretKeyRef:
52-
key: pmmserverkey
53-
name: internal-monitoring
5439
- name: PMM_AGENT_LISTEN_PORT
5540
value: "7777"
5641
- name: PMM_AGENT_PORTS_MIN
5742
value: "30100"
5843
- name: PMM_AGENT_PORTS_MAX
5944
value: "30105"
6045
- name: PMM_AGENT_CONFIG_FILE
61-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
46+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
6247
- name: PMM_AGENT_SERVER_INSECURE_TLS
6348
value: "1"
6449
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -73,14 +58,14 @@ spec:
7358
value: "1"
7459
- name: PMM_AGENT_SETUP_NODE_TYPE
7560
value: container
76-
- name: PMM_AGENT_PRERUN_SCRIPT
77-
value: /opt/percona/pmm-prerun.sh
7861
- name: PMM_AGENT_SIDECAR
7962
value: "true"
8063
- name: PMM_AGENT_SIDECAR_SLEEP
8164
value: "5"
8265
- name: PMM_AGENT_PATHS_TEMPDIR
8366
value: "/tmp"
67+
- name: PMM_AGENT_PRERUN_SCRIPT
68+
value: "/opt/percona/pmm-prerun.sh"
8469
- name: DB_CLUSTER
8570
value: monitoring
8671
- name: DB_TYPE
@@ -158,12 +143,6 @@ spec:
158143
fieldPath: metadata.namespace
159144
- name: CLUSTER_NAME
160145
value: monitoring
161-
- name: CLIENT_PORT_LISTEN
162-
value: "7777"
163-
- name: CLIENT_PORT_MIN
164-
value: "30100"
165-
- name: CLIENT_PORT_MAX
166-
value: "30105"
167146
- name: PMM_AGENT_SERVER_ADDRESS
168147
value: monitoring-service
169148
- name: PMM_AGENT_SERVER_USERNAME
@@ -173,23 +152,14 @@ spec:
173152
secretKeyRef:
174153
key: pmmserverkey
175154
name: internal-monitoring
176-
- name: PMM_SERVER
177-
value: monitoring-service
178-
- name: PMM_USER
179-
value: api_key
180-
- name: PMM_PASSWORD
181-
valueFrom:
182-
secretKeyRef:
183-
key: pmmserverkey
184-
name: internal-monitoring
185155
- name: PMM_AGENT_LISTEN_PORT
186156
value: "7777"
187157
- name: PMM_AGENT_PORTS_MIN
188158
value: "30100"
189159
- name: PMM_AGENT_PORTS_MAX
190160
value: "30105"
191161
- name: PMM_AGENT_CONFIG_FILE
192-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
162+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
193163
- name: PMM_AGENT_SERVER_INSECURE_TLS
194164
value: "1"
195165
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -204,14 +174,14 @@ spec:
204174
value: "1"
205175
- name: PMM_AGENT_SETUP_NODE_TYPE
206176
value: container
207-
- name: PMM_AGENT_PRERUN_SCRIPT
208-
value: /opt/percona/pmm-prerun.sh
209177
- name: PMM_AGENT_SIDECAR
210178
value: "true"
211179
- name: PMM_AGENT_SIDECAR_SLEEP
212180
value: "5"
213181
- name: PMM_AGENT_PATHS_TEMPDIR
214182
value: "/tmp"
183+
- name: PMM_AGENT_PRERUN_SCRIPT
184+
value: "/opt/percona/pmm-prerun.sh"
215185
- name: DB_CLUSTER
216186
value: monitoring
217187
- name: DB_TYPE

e2e-tests/tests/monitoring/03-rotate-pmm-key.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ commands:
99
1010
# add new PMM API key to secret
1111
API_KEY_NEW=$(get_pmm_api_key "operator-new")
12-
kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch '{"stringData": {"pmmserverkey": '$API_KEY_NEW'}}'
12+
kubectl patch -n "${NAMESPACE}" secret test-secrets --type merge --patch "$(jq -n --arg key "$API_KEY_NEW" '{"stringData": {"pmmserverkey": $key}}')"
13+
1314
1415
# delete old PMM key
1516
delete_pmm_api_key "operator"

e2e-tests/vars.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export IMAGE_ORCHESTRATOR=${IMAGE_ORCHESTRATOR:-"perconalab/percona-server-mysql
1717
export IMAGE_ROUTER=${IMAGE_ROUTER:-"perconalab/percona-server-mysql-operator:main-router"}
1818
export IMAGE_TOOLKIT=${IMAGE_TOOLKIT:-"perconalab/percona-server-mysql-operator:main-toolkit"}
1919
export IMAGE_HAPROXY=${IMAGE_HAPROXY:-"perconalab/percona-server-mysql-operator:main-haproxy"}
20-
export PMM_SERVER_VERSION=${PMM_SERVER_VERSION:-"9.9.9"}
21-
export IMAGE_PMM_CLIENT=${IMAGE_PMM_CLIENT:-"perconalab/pmm-client:dev-latest"}
22-
export IMAGE_PMM_SERVER=${IMAGE_PMM_SERVER:-"perconalab/pmm-server:dev-latest"}
20+
export PMM_SERVER_VERSION=${PMM_SERVER_VERSION:-"1.4.0"}
21+
export IMAGE_PMM_CLIENT=${IMAGE_PMM_CLIENT:-"perconalab/pmm-client:3-dev-latest"}
22+
export IMAGE_PMM_SERVER=${IMAGE_PMM_SERVER:-"perconalab/pmm-server:3-dev-latest"}
2323
export CERT_MANAGER_VER="1.16.3"
2424

2525
date=$(which gdate || which date)

pkg/controller/ps/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (r *PerconaServerMySQLReconciler) deleteMySQLPvc(ctx context.Context, cr *a
391391

392392
secretNames := []string{
393393
cr.Spec.SecretsName,
394-
"internal-" + cr.Name,
394+
cr.InternalSecretName(),
395395
}
396396
err = k8s.DeleteSecrets(ctx, r.Client, cr, secretNames)
397397
if err != nil {

0 commit comments

Comments
 (0)