From 996b50d99b3b891ae495a18909b8837d9fe49943 Mon Sep 17 00:00:00 2001 From: Ashley Felton Date: Tue, 31 Oct 2023 13:14:58 +0800 Subject: [PATCH] Refactor Kustomize cronjob template and overlays. --- .../ascender-csv-upload/kustomization.yaml | 9 +- .../cronjobs/ascender-csv-upload/patch.yaml | 50 +++++++- .../deptusers-audit-email/kustomization.yaml | 9 +- .../cronjobs/deptusers-audit-email/patch.yaml | 45 ++++++- .../kustomization.yaml | 7 ++ .../deptusers-audit-employeeid/patch.yaml | 59 +++++++++ .../kustomization.yaml | 9 +- .../deptusers-check-ascender/patch.yaml | 100 ++++++++++++++- .../deptusers-check-azure/kustomization.yaml | 9 +- .../cronjobs/deptusers-check-azure/patch.yaml | 45 ++++++- .../deptusers-check-onprem/kustomization.yaml | 9 +- .../deptusers-check-onprem/patch.yaml | 30 ++++- .../deptusers-clean/kustomization.yaml | 12 -- .../prod/cronjobs/deptusers-clean/patch.yaml | 6 - .../cronjobs/deptusers-sync-ad/patch.yaml | 45 ++++++- .../kustomization.yaml | 9 +- .../deptusers-sync-freshservice/patch.yaml | 35 +++++- .../deptusers-sync-onprem/kustomization.yaml | 12 -- .../cronjobs/deptusers-sync-onprem/patch.yaml | 6 - .../m365-licence-check/kustomization.yaml | 9 +- .../cronjobs/m365-licence-check/patch.yaml | 45 ++++++- .../cronjobs/storage-usage/kustomization.yaml | 9 +- .../prod/cronjobs/storage-usage/patch.yaml | 45 ++++++- .../cronjobs/update-ccm/kustomization.yaml | 9 +- .../prod/cronjobs/update-ccm/patch.yaml | 75 ++++++++++- kustomize/overlays/prod/kustomization.yaml | 3 +- kustomize/template/cronjob.yaml | 117 +----------------- 27 files changed, 542 insertions(+), 276 deletions(-) create mode 100644 kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/kustomization.yaml create mode 100644 kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/patch.yaml delete mode 100644 kustomize/overlays/prod/cronjobs/deptusers-clean/kustomization.yaml delete mode 100644 kustomize/overlays/prod/cronjobs/deptusers-clean/patch.yaml delete mode 100644 kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/kustomization.yaml delete mode 100644 kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/ascender-csv-upload/kustomization.yaml b/kustomize/overlays/prod/cronjobs/ascender-csv-upload/kustomization.yaml index 35d40de3..073a047d 100644 --- a/kustomize/overlays/prod/cronjobs/ascender-csv-upload/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/ascender-csv-upload/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -ascender-csv-upload patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/ascender-csv-upload/patch.yaml b/kustomize/overlays/prod/cronjobs/ascender-csv-upload/patch.yaml index 0371a7b0..e8ef7e95 100644 --- a/kustomize/overlays/prod/cronjobs/ascender-csv-upload/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/ascender-csv-upload/patch.yaml @@ -1,6 +1,44 @@ -- op: replace - path: /spec/schedule - value: "22 18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "department_users_upload_ascender_sftp", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "22 18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "department_users_upload_ascender_sftp"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: ASCENDER_SFTP_HOSTNAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_SFTP_HOSTNAME + - name: ASCENDER_SFTP_PORT + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_SFTP_PORT + - name: ASCENDER_SFTP_USERNAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_SFTP_USERNAME + - name: ASCENDER_SFTP_PASSWORD + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_SFTP_PASSWORD + - name: ASCENDER_SFTP_DIRECTORY + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_SFTP_DIRECTORY diff --git a/kustomize/overlays/prod/cronjobs/deptusers-audit-email/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-audit-email/kustomization.yaml index 8e8d3ab5..41ac030b 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-audit-email/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-audit-email/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -deptusers-audit-email patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-audit-email/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-audit-email/patch.yaml index da32567c..530f6c1e 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-audit-email/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-audit-email/patch.yaml @@ -1,6 +1,39 @@ -- op: replace - path: /spec/schedule - value: "7 19 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "department_users_audit_emails", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "7 19 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "department_users_audit_emails"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET + - name: AZURE_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_CONNECTION_STRING diff --git a/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/kustomization.yaml new file mode 100644 index 00000000..bfa633b1 --- /dev/null +++ b/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../../template +nameSuffix: -deptusers-audit-employeeid +patches: + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/patch.yaml new file mode 100644 index 00000000..e6fd1843 --- /dev/null +++ b/kustomize/overlays/prod/cronjobs/deptusers-audit-employeeid/patch.yaml @@ -0,0 +1,59 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "33 18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "department_users_audit_employee_ids"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: FOREIGN_DB_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_HOST + - name: FOREIGN_DB_PORT + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PORT + - name: FOREIGN_DB_NAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_NAME + - name: FOREIGN_DB_USERNAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_USERNAME + - name: FOREIGN_DB_PASSWORD + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PASSWORD + - name: FOREIGN_SCHEMA + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SCHEMA + - name: FOREIGN_SERVER + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SERVER + - name: FOREIGN_TABLE + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_TABLE diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/kustomization.yaml index eb869d8c..af853124 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -deptusers-check-ascender patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/patch.yaml index c7985c40..4113e5f6 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-ascender/patch.yaml @@ -1,6 +1,94 @@ -- op: replace - path: /spec/schedule - value: "10,40 8-18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_ascender_accounts", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "10,40 8-18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "check_ascender_accounts"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: EMAIL_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: EMAIL_HOST + - name: ADMIN_EMAILS + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ADMIN_EMAILS + - name: ASCENDER_CREATE_AZURE_AD + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_CREATE_AZURE_AD + - name: ASCENDER_CREATE_AZURE_AD_LIMIT_DAYS + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ASCENDER_CREATE_AZURE_AD_LIMIT_DAYS + - name: FOREIGN_DB_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_HOST + - name: FOREIGN_DB_PORT + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PORT + - name: FOREIGN_DB_NAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_NAME + - name: FOREIGN_DB_USERNAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_USERNAME + - name: FOREIGN_DB_PASSWORD + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PASSWORD + - name: FOREIGN_SCHEMA + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SCHEMA + - name: FOREIGN_SERVER + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SERVER + - name: FOREIGN_TABLE + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_TABLE + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-azure/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-azure/kustomization.yaml index 5555884e..ce8036be 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-azure/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-azure/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -deptusers-check-azure patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-azure/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-azure/patch.yaml index 1f1fd37e..c18e7b64 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-azure/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-azure/patch.yaml @@ -1,6 +1,39 @@ -- op: replace - path: /spec/schedule - value: "15,45 8-18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_azure_accounts", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "15,45 8-18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "check_azure_accounts"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET + - name: AZURE_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_CONNECTION_STRING diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/kustomization.yaml index ccbd889f..6f839c8b 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -deptusers-check-onprem patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/patch.yaml index b542c11e..570ccf43 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-check-onprem/patch.yaml @@ -1,6 +1,24 @@ -- op: replace - path: /spec/schedule - value: "20,50 8-18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_onprem_accounts", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "20,50 8-18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "check_onprem_accounts", "--container", "azuread", "--path", "adusers.json"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: AZURE_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_CONNECTION_STRING diff --git a/kustomize/overlays/prod/cronjobs/deptusers-clean/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-clean/kustomization.yaml deleted file mode 100644 index 207bae81..00000000 --- a/kustomize/overlays/prod/cronjobs/deptusers-clean/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- ../../../../template -nameSuffix: -deptusers-clean -patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-clean/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-clean/patch.yaml deleted file mode 100644 index e99cd9c5..00000000 --- a/kustomize/overlays/prod/cronjobs/deptusers-clean/patch.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- op: replace - path: /spec/schedule - value: "33 18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "department_users_audit_employee_ids", "--help"] diff --git a/kustomize/overlays/prod/cronjobs/deptusers-sync-ad/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-sync-ad/patch.yaml index 06654393..149b2062 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-sync-ad/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-sync-ad/patch.yaml @@ -1,6 +1,39 @@ -- op: replace - path: /spec/schedule - value: "5,35 8-18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "department_users_check_link_fields", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "25 8,10,12,14,16,18 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "department_users_sync_ad_data"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET + - name: AZURE_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_CONNECTION_STRING diff --git a/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/kustomization.yaml index 370cc06c..bb867959 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -deptusers-sync-freshservice patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/patch.yaml index d1bec3c6..ec3b33f7 100644 --- a/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/deptusers-sync-freshservice/patch.yaml @@ -1,6 +1,29 @@ -- op: replace - path: /spec/schedule - value: "5 19 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "it_system_register_sync_freshservice", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "5 19 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "department_users_sync_freshservice"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: FRESHSERVICE_ENDPOINT + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FRESHSERVICE_ENDPOINT + - name: FRESHSERVICE_API_KEY + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FRESHSERVICE_API_KEY diff --git a/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/kustomization.yaml b/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/kustomization.yaml deleted file mode 100644 index 91a8e950..00000000 --- a/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/kustomization.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: -- ../../../../template -nameSuffix: -deptusers-sync-onprem -patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/patch.yaml b/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/patch.yaml deleted file mode 100644 index b542c11e..00000000 --- a/kustomize/overlays/prod/cronjobs/deptusers-sync-onprem/patch.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- op: replace - path: /spec/schedule - value: "20,50 8-18 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_onprem_accounts", "--help"] diff --git a/kustomize/overlays/prod/cronjobs/m365-licence-check/kustomization.yaml b/kustomize/overlays/prod/cronjobs/m365-licence-check/kustomization.yaml index 8666cdeb..dac4371a 100644 --- a/kustomize/overlays/prod/cronjobs/m365-licence-check/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/m365-licence-check/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -m365-licence-check patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/m365-licence-check/patch.yaml b/kustomize/overlays/prod/cronjobs/m365-licence-check/patch.yaml index f7f75c21..4c6846a5 100644 --- a/kustomize/overlays/prod/cronjobs/m365-licence-check/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/m365-licence-check/patch.yaml @@ -1,6 +1,39 @@ -- op: replace - path: /spec/schedule - value: "55 11 * * 1,4" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_m365_licence_count", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "55 11 * * 1,4" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "check_m365_licence_count"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: EMAIL_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: EMAIL_HOST + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET diff --git a/kustomize/overlays/prod/cronjobs/storage-usage/kustomization.yaml b/kustomize/overlays/prod/cronjobs/storage-usage/kustomization.yaml index d2a45d91..c18a226a 100644 --- a/kustomize/overlays/prod/cronjobs/storage-usage/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/storage-usage/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -storage-usage patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/storage-usage/patch.yaml b/kustomize/overlays/prod/cronjobs/storage-usage/patch.yaml index be14d985..07e8e9e6 100644 --- a/kustomize/overlays/prod/cronjobs/storage-usage/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/storage-usage/patch.yaml @@ -1,6 +1,39 @@ -- op: replace - path: /spec/schedule - value: "1 2 * * 3,6" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "site_storage_upload", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "1 2 * * 3,6" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "site_storage_upload"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: AZURE_TENANT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_TENANT_ID + - name: MS_GRAPH_API_CLIENT_ID + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_ID + - name: MS_GRAPH_API_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: MS_GRAPH_API_CLIENT_SECRET + - name: AZURE_CONNECTION_STRING + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: AZURE_CONNECTION_STRING diff --git a/kustomize/overlays/prod/cronjobs/update-ccm/kustomization.yaml b/kustomize/overlays/prod/cronjobs/update-ccm/kustomization.yaml index 792f440f..67189931 100644 --- a/kustomize/overlays/prod/cronjobs/update-ccm/kustomization.yaml +++ b/kustomize/overlays/prod/cronjobs/update-ccm/kustomization.yaml @@ -1,12 +1,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- ../../../../template + - ../../../../template nameSuffix: -update-ccm patches: -- target: - group: batch - version: v1 - kind: CronJob - name: itassets-cronjob - path: patch.yaml + - path: patch.yaml diff --git a/kustomize/overlays/prod/cronjobs/update-ccm/patch.yaml b/kustomize/overlays/prod/cronjobs/update-ccm/patch.yaml index 31a47f1b..f39f488b 100644 --- a/kustomize/overlays/prod/cronjobs/update-ccm/patch.yaml +++ b/kustomize/overlays/prod/cronjobs/update-ccm/patch.yaml @@ -1,6 +1,69 @@ -- op: replace - path: /spec/schedule - value: "0 21 * * 1-5" -- op: replace - path: /spec/jobTemplate/spec/template/spec/containers/0/args - value: ["manage.py", "check_cost_centre_managers", "--help"] +apiVersion: batch/v1 +kind: CronJob +metadata: + name: itassets-cronjob +spec: + schedule: "0 21 * * 1-5" + jobTemplate: + spec: + template: + spec: + containers: + - name: itassets-cronjob + args: ["manage.py", "check_cost_centre_managers"] + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: DATABASE_URL + - name: EMAIL_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: EMAIL_HOST + - name: ADMIN_EMAILS + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: ADMIN_EMAILS + - name: FOREIGN_DB_HOST + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_HOST + - name: FOREIGN_DB_PORT + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PORT + - name: FOREIGN_DB_NAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_NAME + - name: FOREIGN_DB_USERNAME + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_USERNAME + - name: FOREIGN_DB_PASSWORD + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_DB_PASSWORD + - name: FOREIGN_SCHEMA + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SCHEMA + - name: FOREIGN_SERVER + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_SERVER + - name: FOREIGN_TABLE_CC_MANAGER + valueFrom: + secretKeyRef: + name: itassets-env-prod + key: FOREIGN_TABLE_CC_MANAGER diff --git a/kustomize/overlays/prod/kustomization.yaml b/kustomize/overlays/prod/kustomization.yaml index 072a667d..8d697278 100644 --- a/kustomize/overlays/prod/kustomization.yaml +++ b/kustomize/overlays/prod/kustomization.yaml @@ -11,13 +11,12 @@ resources: - ingress.yaml - cronjobs/ascender-csv-upload - cronjobs/deptusers-audit-email + - cronjobs/deptusers-audit-employeeid - cronjobs/deptusers-check-ascender - cronjobs/deptusers-check-azure - cronjobs/deptusers-check-onprem - - cronjobs/deptusers-clean - cronjobs/deptusers-sync-ad - cronjobs/deptusers-sync-freshservice - - cronjobs/deptusers-sync-onprem - cronjobs/m365-licence-check - cronjobs/storage-usage - cronjobs/update-ccm diff --git a/kustomize/template/cronjob.yaml b/kustomize/template/cronjob.yaml index f1407e96..f7da5780 100644 --- a/kustomize/template/cronjob.yaml +++ b/kustomize/template/cronjob.yaml @@ -18,121 +18,8 @@ spec: command: ["python"] args: ["--version"] env: - - name: DATABASE_URL - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: DATABASE_URL - - name: EMAIL_HOST - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: EMAIL_HOST - - name: ADMIN_EMAILS - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ADMIN_EMAILS - - name: AZURE_CONNECTION_STRING - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: AZURE_CONNECTION_STRING - - name: AZURE_TENANT_ID - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: AZURE_TENANT_ID - - name: MS_GRAPH_API_CLIENT_ID - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: MS_GRAPH_API_CLIENT_ID - - name: MS_GRAPH_API_CLIENT_SECRET - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: MS_GRAPH_API_CLIENT_SECRET - - name: FOREIGN_DB_HOST - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_DB_HOST - - name: FOREIGN_DB_PORT - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_DB_PORT - - name: FOREIGN_DB_NAME - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_DB_NAME - - name: FOREIGN_DB_USERNAME - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_DB_USERNAME - - name: FOREIGN_DB_PASSWORD - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_DB_PASSWORD - - name: FOREIGN_SCHEMA - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_SCHEMA - - name: FOREIGN_SERVER - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_SERVER - - name: FOREIGN_TABLE - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_TABLE - - name: FOREIGN_TABLE_CC_MANAGER - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FOREIGN_TABLE_CC_MANAGER - - name: FRESHSERVICE_ENDPOINT - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FRESHSERVICE_ENDPOINT - - name: FRESHSERVICE_API_KEY - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: FRESHSERVICE_API_KEY - - name: ASCENDER_SFTP_HOSTNAME - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ASCENDER_SFTP_HOSTNAME - - name: ASCENDER_SFTP_PORT - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ASCENDER_SFTP_PORT - - name: ASCENDER_SFTP_USERNAME - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ASCENDER_SFTP_USERNAME - - name: ASCENDER_SFTP_PASSWORD - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ASCENDER_SFTP_PASSWORD - - name: ASCENDER_SFTP_DIRECTORY - valueFrom: - secretKeyRef: - name: itassets-env-prod - key: ASCENDER_SFTP_DIRECTORY + - name: TZ + value: "Australia/Perth" securityContext: runAsNonRoot: true privileged: false