openstack-helm-infra/roles/gather-prom-metrics/tasks/main.yaml
Steve Wilkerson 84c6931c98 Fix prometheus metrics gathering in postrun job
This adds '|| true' to the curl command for gathering metrics from
prometheus exporters in the postrun job. After the move to
minikube for single node jobs, the headless services for the
kubernetes components no longer work as intended. The addition of
'|| true' allows the post run job to continue through the list
of services tied to the prometheus exporters without the task
failing outright

Change-Id: I56f0f56b799c3df9b2bd66a2c2044d71473606e3
2019-04-22 12:02:11 +00:00

47 lines
1.7 KiB
YAML

# 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.
- name: "creating directory for helm release descriptions"
file:
path: "{{ logs_dir }}/prometheus"
state: directory
- name: "Get prometheus metrics from exporters in all namespaces"
shell: |-
set -e
NAMESPACES=$(kubectl get namespaces -o json | jq -r '.items[].metadata.name')
for NS in $NAMESPACES; do
SERVICES=$(kubectl get svc -l component=metrics -n $NS -o json | jq -r '.items[].metadata.name')
for SVC in $SERVICES; do
PORT=$(kubectl get svc $SVC -n $NS -o json | jq -r '.spec.ports[].port')
curl "$SVC.$NS:$PORT/metrics" >> "{{ logs_dir }}"/prometheus/$NS-$SVC.txt || true
done
done
args:
executable: /bin/bash
ignore_errors: True
- name: "Get prometheus metrics from tiller-deploy"
shell: |-
set -e
curl tiller-deploy.kube-system:44135/metrics >> "{{ logs_dir }}"/prometheus/kube-system-tiller-deploy.txt
args:
executable: /bin/bash
ignore_errors: True
- name: "Downloads logs to executor"
synchronize:
src: "{{ logs_dir }}/prometheus"
dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}"
mode: pull
ignore_errors: True