Skip to content

Commit

Permalink
Add kubernetes manifests that create a kubernetes cronjob and necessa…
Browse files Browse the repository at this point in the history
…ry secrets

to collect daily metrics and put them in an s3 bucket.
  • Loading branch information
naved001 committed Feb 28, 2024
1 parent 2bcfede commit 76b6b57
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
39 changes: 39 additions & 0 deletions k8s/base/daily-openshift-metrics-collector-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: daily-openshift-metrics-collector
spec:
schedule: "0 15 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: daily-openshift-metrics-collector
image: ghcr.io/cci-moc/openshift-usage-scripts:main
env:
- name: OPENSHIFT_PROMETHEUS_URL
value: "https://thanos-querier-openshift-monitoring.apps.shift.nerc.mghpcc.org"
- name: OPENSHIFT_TOKEN
valueFrom:
secretKeyRef:
name: metrics-reader
key: token
- name: S3_OUTPUT_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: openshift-metrics-b2-bucket
key: access-key-id
- name: S3_OUTPUT_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: openshift-metrics-b2-bucket
key: secret-access-key
volumeMounts:
- name: data-volume
mountPath: /data
command: ["/bin/sh", "-c", "cd /data && python /app/openshift_metrics/openshift_prometheus_metrics.py --upload-to-s3"]
volumes:
- name: data-volume
emptyDir: {}
restartPolicy: OnFailure
2 changes: 2 additions & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- daily-openshift-metrics-collector-cronjob.yaml
5 changes: 5 additions & 0 deletions k8s/overlay/dev/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources:
- ../../base
- openshift-metrics-b2-bucket.yaml
- metrics-reader-token.yaml
namespace: xdmod-reader
8 changes: 8 additions & 0 deletions k8s/overlay/dev/metrics-reader-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: metrics-reader
type: Opaque
data:
token: <b64-encoded-token>

8 changes: 8 additions & 0 deletions k8s/overlay/dev/openshift-metrics-b2-bucket.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: openshift-metrics-b2-bucket
type: Opaque
data:
access-key-id: 1234
secret-access-key: secret

0 comments on commit 76b6b57

Please sign in to comment.