Skip to content

Commit 22f9176

Browse files
committed
K8SPS-393
1 parent d7aa0be commit 22f9176

File tree

13 files changed

+123
-84
lines changed

13 files changed

+123
-84
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: 41 additions & 10 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
114-
115-
if [[ -z $key_name ]]; then
116-
key_name="operator"
117-
fi
118-
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
122+
local key_name=$1
123+
124+
if [[ -z $key_name ]]; then
125+
key_name="operator"
126+
fi
127+
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() {

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: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,14 @@ spec:
4242
secretKeyRef:
4343
key: pmmserverkey
4444
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
5445
- name: PMM_AGENT_LISTEN_PORT
5546
value: "7777"
5647
- name: PMM_AGENT_PORTS_MIN
5748
value: "30100"
5849
- name: PMM_AGENT_PORTS_MAX
5950
value: "30105"
6051
- name: PMM_AGENT_CONFIG_FILE
61-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
52+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
6253
- name: PMM_AGENT_SERVER_INSECURE_TLS
6354
value: "1"
6455
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -73,8 +64,6 @@ spec:
7364
value: "1"
7465
- name: PMM_AGENT_SETUP_NODE_TYPE
7566
value: container
76-
- name: PMM_AGENT_PRERUN_SCRIPT
77-
value: /opt/percona/pmm-prerun.sh
7867
- name: PMM_AGENT_SIDECAR
7968
value: "true"
8069
- name: PMM_AGENT_SIDECAR_SLEEP
@@ -174,23 +163,14 @@ spec:
174163
secretKeyRef:
175164
key: pmmserverkey
176165
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
186166
- name: PMM_AGENT_LISTEN_PORT
187167
value: "7777"
188168
- name: PMM_AGENT_PORTS_MIN
189169
value: "30100"
190170
- name: PMM_AGENT_PORTS_MAX
191171
value: "30105"
192172
- name: PMM_AGENT_CONFIG_FILE
193-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
173+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
194174
- name: PMM_AGENT_SERVER_INSECURE_TLS
195175
value: "1"
196176
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -205,8 +185,6 @@ spec:
205185
value: "1"
206186
- name: PMM_AGENT_SETUP_NODE_TYPE
207187
value: container
208-
- name: PMM_AGENT_PRERUN_SCRIPT
209-
value: /opt/percona/pmm-prerun.sh
210188
- name: PMM_AGENT_SIDECAR
211189
value: "true"
212190
- name: PMM_AGENT_SIDECAR_SLEEP

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,14 @@ spec:
4444
name: internal-monitoring
4545
- name: PMM_SERVER
4646
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
5447
- name: PMM_AGENT_LISTEN_PORT
5548
value: "7777"
5649
- name: PMM_AGENT_PORTS_MIN
5750
value: "30100"
5851
- name: PMM_AGENT_PORTS_MAX
5952
value: "30105"
6053
- name: PMM_AGENT_CONFIG_FILE
61-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
54+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
6255
- name: PMM_AGENT_SERVER_INSECURE_TLS
6356
value: "1"
6457
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -73,8 +66,6 @@ spec:
7366
value: "1"
7467
- name: PMM_AGENT_SETUP_NODE_TYPE
7568
value: container
76-
- name: PMM_AGENT_PRERUN_SCRIPT
77-
value: /opt/percona/pmm-prerun.sh
7869
- name: PMM_AGENT_SIDECAR
7970
value: "true"
8071
- name: PMM_AGENT_SIDECAR_SLEEP
@@ -175,21 +166,14 @@ spec:
175166
name: internal-monitoring
176167
- name: PMM_SERVER
177168
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
185169
- name: PMM_AGENT_LISTEN_PORT
186170
value: "7777"
187171
- name: PMM_AGENT_PORTS_MIN
188172
value: "30100"
189173
- name: PMM_AGENT_PORTS_MAX
190174
value: "30105"
191175
- name: PMM_AGENT_CONFIG_FILE
192-
value: /usr/local/percona/pmm2/config/pmm-agent.yaml
176+
value: /usr/local/percona/pmm/config/pmm-agent.yaml
193177
- name: PMM_AGENT_SERVER_INSECURE_TLS
194178
value: "1"
195179
- name: PMM_AGENT_LISTEN_ADDRESS
@@ -204,8 +188,6 @@ spec:
204188
value: "1"
205189
- name: PMM_AGENT_SETUP_NODE_TYPE
206190
value: container
207-
- name: PMM_AGENT_PRERUN_SCRIPT
208-
value: /opt/percona/pmm-prerun.sh
209191
- name: PMM_AGENT_SIDECAR
210192
value: "true"
211193
- name: PMM_AGENT_SIDECAR_SLEEP

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)