Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group pods under aerogear-metrics application and use deploy instead of deploymentConfig #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions roles/deprovision-metrics-apb/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
- name: Delete all prometheus resources by app label (limited to buildconfig,deploymentconfig,service,imagestream,route and pod)
shell: oc delete all -l app=prometheus -n '{{ namespace }}'
- name: Scaling down grafana deployment
k8s_extensions_v1beta1_deployment:
name: grafana
namespace: '{{ namespace }}'
replicas: 0
state: present

- name: Removing grafana deployment
k8s_extensions_v1beta1_deployment:
name: grafana
namespace: '{{ namespace }}'
state: absent

- name: Scaling down prometheus deployment
k8s_extensions_v1beta1_deployment:
name: prometheus
namespace: '{{ namespace }}'
replicas: 0
state: present

- name: Delete all grafana resources by app label (limited to buildconfig,deploymentconfig,service,imagestream,route and pod)
shell: oc delete all -l app=grafana -n '{{ namespace }}'
- name: Removing prometheus deployment
k8s_extensions_v1beta1_deployment:
name: prometheus
namespace: '{{ namespace }}'
state: absent

- name: Delete all aerogear-app-metrics resources by app label (limited to buildconfig,deploymentconfig,service,imagestream,route and pod)
shell: oc delete all -l app=aerogear-app-metrics -n '{{ namespace }}'
- name: Scaling down aerogear-app-metrics deployment
k8s_extensions_v1beta1_deployment:
name: aerogear-app-metrics
namespace: '{{ namespace }}'
replicas: 0
state: present

- name: Removing aerogear-app-metrics deployment
k8s_extensions_v1beta1_deployment:
name: aerogear-app-metrics
namespace: '{{ namespace }}'
state: absent

- name: Scaling down postgres deployment
k8s_extensions_v1beta1_deployment:
name: postgres
namespace: '{{ namespace }}'
replicas: 0
state: present

- name: Delete all postgres resources by app label (limited to buildconfig,deploymentconfig,service,imagestream,route and pod)
shell: oc delete all -l app=postgres -n '{{ namespace }}'
- name: Removing postgres deployment
k8s_extensions_v1beta1_deployment:
name: postgres
namespace: '{{ namespace }}'
state: absent

- k8s_v1_secret:
name: '{{ prometheus_secret_name }}'
Expand Down
46 changes: 20 additions & 26 deletions roles/provision-metrics-apb/tasks/provision-app-metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,25 @@
name: "{{ postgres_claim_name}}"
namespace: "{{ namespace }}"
labels:
app: aerogear-app-metrics
service: aerogear-app-metrics
app: aerogear-metrics
service: postgres
access_modes:
- ReadWriteMany
resources_requests:
storage: '{{ POSTGRES_STORAGE_SIZE }}Gi'
state: present

- name: create postgres deployment config
openshift_v1_deployment_config:
k8s_extensions_v1beta1_deployment:
name: postgres
namespace: '{{ namespace }}'
labels:
app: postgres
service: aerogear-app-metrics
app: aerogear-metrics
service: postgres
replicas: 1
selector:
app: postgres
service: aerogear-app-metrics
spec_template_metadata_labels:
app: postgres
service: aerogear-app-metrics
app: aerogear-metrics
service: postgres
containers:
- name: postgresql
image: "{{ postgres_image }}:{{ postgres_version }}"
Expand All @@ -51,29 +48,26 @@
name: postgres-internal
namespace: '{{ namespace }}'
labels:
app: postgres
service: aerogear-app-metrics
app: aerogear-metrics
service: postgres
selector:
app: postgres
service: aerogear-app-metrics
app: aerogear-metrics
service: postgres
ports:
- name: postgres
port: "{{ postgres_port }}"
target_port: "{{ postgres_port }}"

- name: Create api server deployment config
openshift_v1_deployment_config:
k8s_extensions_v1beta1_deployment:
name: aerogear-app-metrics
namespace: '{{ namespace }}'
labels:
app: aerogear-app-metrics
app: aerogear-metrics
service: aerogear-app-metrics
replicas: 1
selector:
app: aerogear-app-metrics
service: aerogear-app-metrics
spec_template_metadata_labels:
app: aerogear-app-metrics
app: aerogear-metrics
service: aerogear-app-metrics
containers:
- name: aerogear-app-metrics
Expand All @@ -100,10 +94,10 @@
name: aerogear-app-metrics
namespace: '{{ namespace }}'
labels:
app: aerogear-app-metrics
app: aerogear-metrics
service: aerogear-app-metrics
selector:
app: aerogear-app-metrics
app: aerogear-metrics
service: aerogear-app-metrics
ports:
- name: web
Expand All @@ -115,24 +109,24 @@
name: aerogear-app-metrics
namespace: '{{ namespace }}'
labels:
app: aerogear-app-metrics
app: aerogear-metrics
service: aerogear-app-metrics
to_name: aerogear-app-metrics
spec_port_target_port: web
register: app_metrics_route


# Check the containers in the aerogear-app-metrics pod and make sure they are all ready
- name: "Wait for all aerogear-app-metrics containers to become ready"
shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=aerogear-app-metrics" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
shell: oc get pods --namespace={{ namespace }} --selector="service=aerogear-app-metrics" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
register: aerogear_app_metrics_result
until: aerogear_app_metrics_result.stdout.find("1") != -1
retries: 30
delay: 5

# Check the containers in the postgres pod and make sure they are all ready
- name: "Wait for all postgres containers to become ready"
shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=postgres" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
shell: oc get pods --namespace={{ namespace }} --selector="service=postgres" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
register: postgres_result
until: postgres_result.stdout.find("1") != -1
retries: 30
Expand Down
39 changes: 18 additions & 21 deletions roles/provision-metrics-apb/tasks/provision-grafana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,25 @@
name: '{{ grafana_claim_name }}'
namespace: "{{ namespace }}"
labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
access_modes:
- ReadWriteMany
resources_requests:
storage: "{{ GRAFANA_STORAGE_SIZE }}Gi"
state: present

- name: create grafana deployment config
openshift_v1_deployment_config:
k8s_extensions_v1beta1_deployment:
name: grafana
namespace: '{{ namespace }}'
labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
replicas: 1
selector:
app: grafana
service: prometheus
spec_template_metadata_labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
spec_template_spec_service_account_name: '{{ proxy_serviceaccount_name }}'
containers:
- name: grafana-oauth-proxy
Expand Down Expand Up @@ -115,11 +112,11 @@
name: '{{ grafana_service_name }}'
namespace: '{{ namespace }}'
labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
selector:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
ports:
- name: web
port: 443
Expand All @@ -130,11 +127,11 @@
name: '{{ grafana_internal_service_name }}'
namespace: '{{ namespace }}'
labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
selector:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
ports:
- name: web
port: 80
Expand All @@ -145,16 +142,16 @@
name: '{{ grafana_route_name }}'
namespace: '{{ namespace }}'
labels:
app: grafana
service: prometheus
app: aerogear-metrics
service: grafana
to_name: grafana
spec_port_target_port: web
spec_tls_termination: edge
register: grafana_route

# Check the containers in the grafana pod and make sure they are all ready
- name: "Wait for all grafana containers to become ready"
shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=grafana" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
shell: oc get pods --namespace={{ namespace }} --selector="service=grafana" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
register: grafana_result
until: grafana_result.stdout.find("2") != -1
retries: 30
Expand Down
23 changes: 10 additions & 13 deletions roles/provision-metrics-apb/tasks/provision-prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
name: '{{ prometheus_claim_name }}'
namespace: "{{ namespace }}"
labels:
app: prometheus
app: aerogear-metrics
service: prometheus
access_modes:
- ReadWriteOnce
Expand All @@ -20,18 +20,15 @@
state: present

- name: create prometheus deployment config
openshift_v1_deployment_config:
k8s_extensions_v1beta1_deployment:
name: prometheus
namespace: '{{ namespace }}'
labels:
app: prometheus
app: aerogear-metrics
service: prometheus
replicas: 1
selector:
app: prometheus
service: prometheus
spec_template_metadata_labels:
app: prometheus
app: aerogear-metrics
service: prometheus
spec_template_spec_service_account_name: '{{ proxy_serviceaccount_name }}'
containers:
Expand Down Expand Up @@ -75,10 +72,10 @@
name: '{{ prometheus_service_name }}'
namespace: '{{ namespace }}'
labels:
app: prometheus
app: aerogear-metrics
service: prometheus
selector:
app: prometheus
app: aerogear-metrics
service: prometheus
ports:
- name: web
Expand All @@ -90,10 +87,10 @@
name: '{{ prometheus_internal_service_name }}'
namespace: '{{ namespace }}'
labels:
app: prometheus
app: aerogear-metrics
service: prometheus
selector:
app: prometheus
app: aerogear-metrics
service: prometheus
ports:
- name: web
Expand All @@ -105,7 +102,7 @@
name: '{{ prometheus_route_name }}'
namespace: '{{ namespace }}'
labels:
app: prometheus
app: aerogear-metrics
service: prometheus
to_name: prometheus
spec_port_target_port: web
Expand All @@ -122,7 +119,7 @@

# Check the containers in the prometheus pod and make sure they are all ready
- name: "Wait for all prometheus containers to become ready"
shell: oc get pods --namespace={{ namespace }} --selector="deploymentconfig=prometheus" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
shell: oc get pods --namespace={{ namespace }} --selector="service=prometheus" -o jsonpath='{.items[*].status.containerStatuses[?(@.ready==true)].ready}'| wc -w
register: prometheus_result
until: prometheus_result.stdout.find("2") != -1
retries: 30
Expand Down