-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding support for ansible metrics-utility (#1754)
- Adding metadata, storage_class, and pullsecret for metrics-utility - Updating crd, csv and defaults - Adding metrics-utility cronjob
- Loading branch information
Showing
9 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ rules: | |
- apiGroups: | ||
- batch | ||
resources: | ||
- cronjobs | ||
- jobs | ||
verbs: | ||
- get | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# Check to make sure provided pvc exists, error loudly if not. Otherwise, the management pod will just stay in pending state forever. | ||
- name: Check provided PVC claim exists | ||
kubernetes.core.k8s_info: | ||
name: "{{ _metrics_utility_pvc_claim }}" | ||
kind: PersistentVolumeClaim | ||
namespace: "{{ ansible_operator_meta.namespace }}" | ||
when: | ||
- _metrics_utility_pvc_claim | length | ||
|
||
- name: Create PVC for metrics-utility | ||
kubernetes.core.k8s: | ||
kind: PersistentVolumeClaim | ||
definition: "{{ lookup('template', 'storage/metrics-utility.yaml.j2') }}" | ||
|
||
- name: Create Kubernetes CronJobs for metrics-utility | ||
kubernetes.core.k8s: | ||
definition: "{{ lookup('template', item) }}" | ||
apply: true | ||
wait: true | ||
loop: | ||
- cronjobs/metrics-utility-gather.yaml.j2 | ||
- cronjobs/metrics-utility-report.yaml.j2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
roles/installer/templates/cronjobs/metrics-utility-gather.yaml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ ansible_operator_meta.name }}-metrics-utility-gather | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
labels: | ||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-metrics-utility-gather' | ||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} | ||
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }} | ||
spec: | ||
schedule: "{{ _metrics_utility_cronjob_gather_schedule }}" | ||
jobTemplate: | ||
spec: | ||
backoffLimit: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-metrics-utility-gather' | ||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=12) | trim }} | ||
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=12) | trim }} | ||
spec: | ||
{% if image_pull_secret is defined %} | ||
imagePullSecrets: | ||
- name: {{ image_pull_secret }} | ||
{% elif image_pull_secrets | length > 0 %} | ||
imagePullSecrets: | ||
{% for secret in image_pull_secrets %} | ||
- name: {{ secret }} | ||
{% endfor %} | ||
{% endif %} | ||
containers: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility-gather | ||
image: "{{ _metrics_utility_image }}" | ||
imagePullPolicy: "{{ image_pull_policy }}" | ||
resources: | ||
requests: | ||
memory: "100Mi" | ||
cpu: "100m" | ||
command: | ||
- /bin/sh | ||
- -c | ||
- metrics-utility gather_automation_controller_billing_data --ship --until=10m | ||
envFrom: | ||
- configMapRef: | ||
name: {{ _metrics_utility_configmap }} | ||
volumeMounts: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility | ||
mountPath: /metrics-utility | ||
readOnly: false | ||
- name: "{{ ansible_operator_meta.name }}-application-credentials" | ||
mountPath: "/etc/tower/conf.d/credentials.py" | ||
subPath: credentials.py | ||
readOnly: true | ||
- name: {{ ansible_operator_meta.name }}-settings | ||
mountPath: /etc/tower/settings.py | ||
subPath: settings.py | ||
readOnly: true | ||
volumes: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility | ||
persistentVolumeClaim: | ||
claimName: {{ _metrics_utility_pvc_claim }} | ||
readOnly: false | ||
- name: "{{ ansible_operator_meta.name }}-application-credentials" | ||
secret: | ||
secretName: "{{ ansible_operator_meta.name }}-app-credentials" | ||
items: | ||
- key: credentials.py | ||
path: 'credentials.py' | ||
- name: {{ ansible_operator_meta.name }}-settings | ||
configMap: | ||
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap' | ||
items: | ||
- key: settings | ||
path: settings.py | ||
restartPolicy: OnFailure |
76 changes: 76 additions & 0 deletions
76
roles/installer/templates/cronjobs/metrics-utility-report.yaml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ ansible_operator_meta.name }}-metrics-utility-report | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
labels: | ||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-metrics-utility-report' | ||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} | ||
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }} | ||
spec: | ||
schedule: "{{ _metrics_utility_cronjob_report_schedule }}" | ||
jobTemplate: | ||
spec: | ||
backoffLimit: 2 | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-metrics-utility-report' | ||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=12) | trim }} | ||
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=12) | trim }} | ||
spec: | ||
{% if image_pull_secret is defined %} | ||
imagePullSecrets: | ||
- name: {{ image_pull_secret }} | ||
{% elif image_pull_secrets | length > 0 %} | ||
imagePullSecrets: | ||
{% for secret in image_pull_secrets %} | ||
- name: {{ secret }} | ||
{% endfor %} | ||
{% endif %} | ||
containers: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility-report | ||
image: "{{ _metrics_utility_image }}" | ||
imagePullPolicy: "{{ image_pull_policy }}" | ||
resources: | ||
requests: | ||
memory: "100Mi" | ||
cpu: "100m" | ||
command: | ||
- /bin/sh | ||
- -c | ||
- metrics-utility build_report | ||
envFrom: | ||
- configMapRef: | ||
name: {{ _metrics_utility_configmap }} | ||
volumeMounts: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility | ||
mountPath: /metrics-utility | ||
readOnly: false | ||
- name: "{{ ansible_operator_meta.name }}-application-credentials" | ||
mountPath: "/etc/tower/conf.d/credentials.py" | ||
subPath: credentials.py | ||
readOnly: true | ||
- name: {{ ansible_operator_meta.name }}-settings | ||
mountPath: /etc/tower/settings.py | ||
subPath: settings.py | ||
readOnly: true | ||
volumes: | ||
- name: {{ ansible_operator_meta.name }}-metrics-utility | ||
persistentVolumeClaim: | ||
claimName: {{ _metrics_utility_pvc_claim }} | ||
readOnly: false | ||
- name: "{{ ansible_operator_meta.name }}-application-credentials" | ||
secret: | ||
secretName: "{{ ansible_operator_meta.name }}-app-credentials" | ||
items: | ||
- key: credentials.py | ||
path: 'credentials.py' | ||
- name: {{ ansible_operator_meta.name }}-settings | ||
configMap: | ||
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-configmap' | ||
items: | ||
- key: settings | ||
path: settings.py | ||
restartPolicy: OnFailure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: {{ _metrics_utility_pvc_claim }} | ||
namespace: {{ ansible_operator_meta.namespace }} | ||
ownerReferences: null | ||
labels: | ||
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: {{ _metrics_utility_pvc_claim_size }} | ||
{% if metrics_utility_pvc_claim_storage_class is defined %} | ||
storageClassName: {{ metrics_utility_pvc_claim_storage_class }} | ||
{% endif %} |