Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
3690f62
[patch] First pass at approach to pinning cli image tag
tomklapiscak Feb 5, 2025
dc22030
Attempt to standardise job name generation
tomklapiscak Feb 6, 2025
a5b829d
fix
tomklapiscak Feb 6, 2025
e85245c
set-cli-image-tag.sh helper script
tomklapiscak Feb 6, 2025
8da9670
remove comment
tomklapiscak Feb 6, 2025
d49cbe0
fix for darwin
tomklapiscak Feb 6, 2025
5f94108
fix comment
tomklapiscak Feb 6, 2025
6e17e92
WIP: verify-job-definitions.sh script
tomklapiscak Feb 6, 2025
9e4f0ff
improve job validation
tomklapiscak Feb 7, 2025
c8d45f6
improve validator
tomklapiscak Feb 7, 2025
e36f63f
wip: allow naming restrictions to be relaxed for certain files
tomklapiscak Feb 7, 2025
685f830
start updating jobs to conform to new requirements
tomklapiscak Feb 7, 2025
6c25808
allow relax-list to be specified in a config file
tomklapiscak Feb 7, 2025
87ec280
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Feb 10, 2025
04e41ff
updating jobs...
tomklapiscak Feb 10, 2025
62abe6f
more jobs...
tomklapiscak Feb 10, 2025
a9a052d
check that there is valid reason for a given file to be on the relax …
tomklapiscak Feb 10, 2025
721d971
determine dynamically if a naming restrictions should be applied for …
tomklapiscak Feb 10, 2025
acd0b8c
... more jobs
tomklapiscak Feb 10, 2025
f77d6dd
improve job name: {{ $_jo _name }} validation using awk
tomklapiscak Feb 10, 2025
d2ddf5e
more jobs
tomklapiscak Feb 10, 2025
595bfdf
more jobs
tomklapiscak Feb 10, 2025
58d7b92
more jobs
tomklapiscak Feb 10, 2025
3e759f3
more jobs
tomklapiscak Feb 10, 2025
eeb8103
all jobs done
tomklapiscak Feb 10, 2025
140b614
fix
tomklapiscak Feb 11, 2025
728bac9
Add verify-job-definitions.sh to lint action
tomklapiscak Feb 11, 2025
bb1a113
deliberate make job invalid to check if action fails
tomklapiscak Feb 11, 2025
1abe890
deliberate invalidate another job
tomklapiscak Feb 11, 2025
233c11c
Revert "deliberate make job invalid to check if action fails"
tomklapiscak Feb 11, 2025
a4c0724
Revert "deliberate invalidate another job"
tomklapiscak Feb 11, 2025
17aebf7
testing cli_image_tag update
tomklapiscak Feb 11, 2025
8fbaa5a
Add pre-commit hook
tomklapiscak Feb 11, 2025
9922087
docs
tomklapiscak Feb 11, 2025
494d83b
docs
tomklapiscak Feb 11, 2025
dc99a7c
break jobs on purpose
tomklapiscak Feb 11, 2025
eeef018
break jobs on purpose
tomklapiscak Feb 11, 2025
eeece3b
beak jobs on purpose
tomklapiscak Feb 11, 2025
61f8773
fix jobs
tomklapiscak Feb 11, 2025
a02028e
set-cli-image-tag 13.4.0
tomklapiscak Feb 12, 2025
5504517
cli-image-tag 13.4.1
tomklapiscak Feb 12, 2025
c41736b
cli-image-tag 13.3.0
tomklapiscak Feb 12, 2025
08d94a6
cli-image-tag 13.2.0
tomklapiscak Feb 12, 2025
7c9db74
testing argocd.argoproj.io/sync-options: Replace=true behaviour
tomklapiscak Feb 12, 2025
ebd1ebc
testing update to immutable job field with replace=True
tomklapiscak Feb 12, 2025
a7d3cfe
add job label
tomklapiscak Feb 12, 2025
971367a
testing update to immutable job field with Replace = True
tomklapiscak Feb 12, 2025
603c7ca
experimenting with helm hook annotations instead
tomklapiscak Feb 12, 2025
9624bf4
test immutable field update with helm hook annots
tomklapiscak Feb 12, 2025
f818a11
Revert "test immutable field update with helm hook annots"
tomklapiscak Feb 12, 2025
913a602
test immutable job field update with helm hook annots
tomklapiscak Feb 12, 2025
b85a2a7
update to cli 13.4.1 ahead of tonight's fvtsaas run
tomklapiscak Feb 12, 2025
06d13d0
do helm hook jobs influence app health?
tomklapiscak Feb 12, 2025
f9e0efa
experiment with ttlSecondsAfterFinished approach
tomklapiscak Feb 13, 2025
7c99453
sync not creating job when updating with ttlSecondsAfterFinished, try…
tomklapiscak Feb 13, 2025
ede350f
remove ttlSecondsAfterFinished
tomklapiscak Feb 13, 2025
26784d9
try configmap-based approach to tracking current job name
tomklapiscak Feb 13, 2025
d3a7933
update cli image tag to test configmap approach
tomklapiscak Feb 13, 2025
2ce1f83
change label
tomklapiscak Feb 13, 2025
c186798
make some orphaned jobs for testing
tomklapiscak Feb 13, 2025
3b46758
make some orphaned jobs for testing
tomklapiscak Feb 13, 2025
f1dede6
add independent $_job_cleanup_group constant
tomklapiscak Feb 13, 2025
38215e4
establish some more job-cleanup-groups for testing
tomklapiscak Feb 13, 2025
adcd1e9
fix manage post sync db2 job
tomklapiscak Feb 13, 2025
eb3b20f
make some orphaned jobs for testing
tomklapiscak Feb 13, 2025
accd527
fix
tomklapiscak Feb 13, 2025
cee96d5
fix image name
tomklapiscak Feb 13, 2025
3354001
fix image name
tomklapiscak Feb 13, 2025
31037bd
testing cli-image-tag update in fvtsaas
tomklapiscak Feb 14, 2025
567f229
Merge branch 'mascore5516' into mascore5637
tomklapiscak Feb 17, 2025
bb36df7
remove unnecessary configmap
tomklapiscak Feb 17, 2025
58726f5
improve job validation script
tomklapiscak Feb 18, 2025
0eec38d
Add cleanup-group label to all relevant jobs
tomklapiscak Feb 18, 2025
71d8165
fix
tomklapiscak Feb 18, 2025
f1f884a
fix
tomklapiscak Feb 18, 2025
d14eb0f
fix
tomklapiscak Feb 18, 2025
d08e189
Add job-cleaner CronJob
tomklapiscak Feb 18, 2025
4ba4d26
fix
tomklapiscak Feb 18, 2025
eef21c0
fix
tomklapiscak Feb 18, 2025
4d8acba
fix
tomklapiscak Feb 18, 2025
55d4b0d
fix
tomklapiscak Feb 18, 2025
71c1d38
remove --dry-run
tomklapiscak Feb 18, 2025
7310491
update cli image tag to test job-cleaner
tomklapiscak Feb 18, 2025
8a1685f
ensure db2 postsync jobs land in different cleanup groups
tomklapiscak Feb 18, 2025
139e147
inc version to update label
tomklapiscak Feb 18, 2025
5e446ae
temporarily suspend job cleaner CronJob so we can run it once after u…
tomklapiscak Feb 21, 2025
3a19a89
testing cli image tag update in fvtsaas
tomklapiscak Feb 21, 2025
f187e24
re-enable job cleaner in fvtsaas
tomklapiscak Feb 21, 2025
9d0ff59
Merge remote-tracking branch 'origin/main' into mascore5637
tomklapiscak Feb 24, 2025
6d8720d
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Feb 24, 2025
d9e16b6
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Feb 24, 2025
b97d8c7
suspend job-cleaner so we can choose when to run it when testing on S…
tomklapiscak Feb 24, 2025
2bf687c
updating docs
tomklapiscak Feb 24, 2025
b8fee5f
doc updates
tomklapiscak Feb 24, 2025
c3ea9dd
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Mar 3, 2025
3a25e87
update job with new conventions
tomklapiscak Mar 3, 2025
6551872
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Mar 3, 2025
30227a9
update new job to conform to new conventions
tomklapiscak Mar 3, 2025
230ab6f
bump job version
tomklapiscak Mar 3, 2025
ae56c98
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Mar 3, 2025
92ad4e5
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Mar 3, 2025
4211dc7
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Mar 3, 2025
65decff
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Mar 4, 2025
4a4c906
update job to conform to new conventions
tomklapiscak Mar 4, 2025
2597b62
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Mar 4, 2025
b0f4836
add cleanup_group, update _cli_image_tag
tomklapiscak Mar 4, 2025
eb146e1
resume job-cleaner for SRE staging test
tomklapiscak Mar 6, 2025
3d01573
update cli image tag for test in SRE staging
tomklapiscak Mar 6, 2025
f43a8a0
Merge remote-tracking branch 'origin/main' into mascore5516
tomklapiscak Mar 20, 2025
8c9d01f
Merge branch 'mascore5516' into mascore5637
tomklapiscak Mar 20, 2025
0d42df7
Merge branch 'main' into mascore5516
tomklapiscak Mar 27, 2025
9ada068
Merge remote-tracking branch 'origin/mascore5516' into mascore5637
tomklapiscak Mar 27, 2025
ee027f1
update CLI image tag
tomklapiscak Mar 28, 2025
4332773
[minor] first pass at initial user creation job
tomklapiscak Mar 28, 2025
0e7d69b
fix
tomklapiscak Mar 28, 2025
2adddb4
fix
tomklapiscak Mar 28, 2025
0e311de
fix
tomklapiscak Mar 28, 2025
4c3eda7
fix
tomklapiscak Mar 28, 2025
ed6a0fc
fix (add aws secret)
tomklapiscak Mar 28, 2025
9771e8d
fix (aws creds path)
tomklapiscak Mar 28, 2025
09f7147
temporary change imagePullPolicy to Always
tomklapiscak Mar 28, 2025
bf41372
fix rb ns
tomklapiscak Mar 28, 2025
56ff646
update image tag ahead of merge
tomklapiscak Apr 17, 2025
316e3e7
Merge remote-tracking branch 'origin/main' into mascore6072
tomklapiscak Apr 17, 2025
0ec8a6a
use cli pre-release for users job
tomklapiscak Apr 17, 2025
b2e658a
Merge branch 'main' into mascore6072
tomklapiscak May 1, 2025
386f47c
use CLI image that has user creation script
tomklapiscak May 1, 2025
2a81df4
imagePullPolicy: IfNotPresent
tomklapiscak May 1, 2025
00b1d70
Merge remote-tracking branch 'origin/main' into mascore6072
tomklapiscak May 6, 2025
9e7fe96
use CLI image with latest merge of python-devops (13.21.0-pre.mascore…
tomklapiscak May 6, 2025
7078787
13.22.0-pre.mascore6072-amd64
tomklapiscak May 8, 2025
acb778a
cli 13.22.0-pre.mascore6072-amd64
tomklapiscak May 9, 2025
a1960d5
Merge remote-tracking branch 'origin/main' into mascore6072
tomklapiscak May 13, 2025
718d03c
Merge remote-tracking branch 'origin/main' into mascore6072
tomklapiscak May 14, 2025
f20ad17
CLI 13.22.0-amd64 where needed
tomklapiscak May 14, 2025
38fc689
cli 13.22.1 (actually incudes new script)
tomklapiscak May 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ spec:
containers:
- name: run
image: quay.io/ibmmas/cli@{{ $_cli_image_digest }}
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 200m
Expand Down
12 changes: 12 additions & 0 deletions instance-applications/600-ibm-post-sync-jobs/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v2
name: ibm-post-sync-jobs
description: |
Jobs that perform various tasks AFTER all MAS applications are synced and healthy
type: application
version: 1.0.0

dependencies:
- name: junitreporter
version: 1.0.0
repository: "file://../../sub-charts/junitreporter/"
condition: junitreporter.devops_mongo_uri != ""
5 changes: 5 additions & 0 deletions instance-applications/600-ibm-post-sync-jobs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
IBM MAS Post Sync Jobs
===============================================================================
Instantiated by the /gitops/root-applications/ibm-mas-instance-root/templates/600-ibm-post-sync-jobs.yaml root application.

Defines Jobs to perform various tasks that need to happen after MAS applications are installed and ready.
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
{{- if not (empty .Values.mas_workspace_id) }}
{{- if .Values.mas_is_active }}

{{- /*
Meaningful prefix for the job resource name. Must be under 52 chars in length to leave room for the 11 chars reserved for '-' and $_job_hash.
*/}}
{{- $_job_name_prefix := "ibm-create-initial-users" }}

{{- /*
Use the build/bin/set-cli-image-tag.sh script to update this value across all charts.
Included in $_job_hash (see below).
13.22.1-amd64 - includes mas-devops-create-initial-users script from https://github.com/ibm-mas/python-devops/pull/66
*/}}
{{- $_cli_image_digest := "sha256:3735885b3b9d46fcf6408c008768cc04faf2e28c1fa5f6da7c5f969931e2d3cd" }}

{{- /*
A dict of values that influence the behaviour of the job in some way.
Any changes to values in this dict will trigger a rerun of the job.
Since jobs must be idemopotent, it's generally safe to pass in values here that are not
strictly necessary (i.e. including some values that don't actually influence job behaviour).
We may want to refine this further though for jobs that can take a long time to complete.
Included in $_job_hash (see below).
*/}}
{{- $_job_config_values := omit .Values "junitreporter" }}

{{- /*
Increment this value whenever you make a change to an immutable field of the Job resource.
E.g. passing in a new environment variable.
Included in $_job_hash (see below).
*/}}
{{- $_job_version := "v4" }}

{{- /*
10 char hash appended to the job name taking into account $_job_config_values, $_job_version and $_cli_image_digest
This is to ensure ArgoCD will create a new job resource intead of attempting (and failing) to update an
immutable field of any existing Job resource.
*/}}
{{- $_job_hash := print ($_job_config_values | toYaml) $_cli_image_digest $_job_version | adler32sum }}

{{- $_job_name := join "-" (list $_job_name_prefix $_job_hash )}}

{{- /*
Set as the value for the mas.ibm.com/job-cleanup-group label on the Job resource.

When the auto_delete flag is not set on the root application, a CronJob in the cluster uses this label
to identify old Job resources that should be pruned on behalf of ArgoCD.

Any Job resources in the same namespace that have the mas.ibm.com/job-cleanup-group with this value
will be considered to belong to the same cleanup group. All but the most recent (i.e. with the latest "creation_timestamp")
Jobs will be automatically deleted.

$_job_cleanup_group can usually just be based on $_job_name_prefix. There are some special cases
where multiple Jobs are created in our templates using a Helm loop. In those cases, additional descriminators
must be added to $_job_cleanup_group.

By convention, we sha1sum this value to guarantee we never exceed the 63 char limit regardless of which discriminatorstest python-devops bui
are required here.

*/}}
{{- $_job_cleanup_group := cat $_job_name_prefix | sha1sum }}



{{ $ns := printf "mas-%s-postsyncjobs" .Values.instance_id }}
{{ $ns_core := printf "mas-%s-core" .Values.instance_id }}
{{ $ns_manage := printf "mas-%s-manage" .Values.instance_id }}
{{ $aws_secret := "aws"}}
{{ $np_name := printf "%s-np" $_job_name_prefix }}
{{ $role_core_name := printf "%s-r-core" $_job_name_prefix }}
{{ $role_manage_name := printf "%s-r-manage" $_job_name_prefix }}
{{ $sa_name := printf "%s-sa" $_job_name_prefix }}
{{ $rb_core_name := printf "%s-rb-core" $_job_name_prefix }}
{{ $rb_manage_name := printf "%s-rb-manage" $_job_name_prefix }}
{{ $job_label := printf "%s-l" $_job_name_prefix }}




---
kind: Secret
apiVersion: v1
metadata:
name: {{ $aws_secret }}
namespace: {{ $ns }}
annotations:
argocd.argoproj.io/sync-wave: "000"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
stringData:
aws_access_key_id: {{ .Values.sm_aws_access_key_id }}
aws_secret_access_key: {{ .Values.sm_aws_secret_access_key }}
aws_default_region: {{ .Values.sm_aws_region }}
type: Opaque


---
# Permit outbound communication by the Job pods
# (Needed to communicate with the K8S HTTP API, AWS SM and internal services)
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
name: {{ $np_name }}
namespace: {{ $ns }}
annotations:
argocd.argoproj.io/sync-wave: "000"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
app: {{ $job_label }}
egress:
- {}
policyTypes:
- Egress


---
# needs to read the following secrets
# mas-{i}-core
# {i}-credentials-superuser in
# {i}-admindashboard-cert-internal
# {i}-coreapi-cert-internal
# mas-{i}-manage
# {i}-internal-manage-tls
kind: ServiceAccount
apiVersion: v1
metadata:
name: {{ $sa_name }}
namespace: {{ $ns }}
annotations:
argocd.argoproj.io/sync-wave: "000"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}



---

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ $role_core_name }}
namespace: {{ $ns_core }}
annotations:
argocd.argoproj.io/sync-wave: "000"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
rules:
- verbs:
- get
apiGroups:
- ""
resources:
- secrets

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $rb_core_name }}
namespace: {{ $ns_core }}
annotations:
argocd.argoproj.io/sync-wave: "001"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ $sa_name }}
namespace: {{ $ns }}
roleRef:
kind: Role
name: {{ $role_core_name }}
apiGroup: rbac.authorization.k8s.io


---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ $role_manage_name }}
namespace: {{ $ns_manage }}
annotations:
argocd.argoproj.io/sync-wave: "000"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
rules:
- verbs:
- get
apiGroups:
- ""
resources:
- secrets

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $rb_manage_name }}
namespace: {{ $ns_manage }}
annotations:
argocd.argoproj.io/sync-wave: "001"
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ $sa_name }}
namespace: {{ $ns }}
roleRef:
kind: Role
name: {{ $role_manage_name }}
apiGroup: rbac.authorization.k8s.io


---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ $_job_name }}
namespace: {{ $ns }}
annotations:
argocd.argoproj.io/sync-wave: "002"
labels:
mas.ibm.com/job-cleanup-group: {{ $_job_cleanup_group }}
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
spec:
template:
metadata:
labels:
app: {{ $job_label }}
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
spec:
containers:
- name: {{ $_job_name_prefix }}
image: quay.io/ibmmas/cli@{{ $_cli_image_digest }}
imagePullPolicy: IfNotPresent

env:
- name: ACCOUNT_ID
value: "{{ .Values.account_id }}"
- name: CLUSTER_ID
value: "{{ .Values.cluster_id }}"
- name: MAS_INSTANCE_ID
value: "{{ .Values.instance_id }}"
- name: MAS_WORKSPACE_ID
value: "{{ .Values.mas_workspace_id }}"

- name: SECRETS_KEY_SEPERATOR
value: "/"

- name: SM_AWS_REGION
value: "{{ .Values.sm_aws_region }}"

# Hard-coded for now:
- name: AVP_TYPE
value: "aws"

volumeMounts:
- name: "aws"
mountPath: /etc/mas/creds/aws
command:
- /bin/sh
- -c
- |

set -e

export SM_AWS_ACCESS_KEY_ID=$(cat /etc/mas/creds/aws/aws_access_key_id)
export SM_AWS_SECRET_ACCESS_KEY=$(cat /etc/mas/creds/aws/aws_secret_access_key)
source /mascli/functions/gitops_utils
sm_login

mas-devops-create-initial-users-for-saas \
--mas-instance-id "${MAS_INSTANCE_ID}" \
--mas-workspace-id "${MAS_WORKSPACE_ID}" \
--initial-users-secret-name "${ACCOUNT_ID}/${CLUSTER_ID}/${MAS_INSTANCE_ID}/initial_users"
rc=$?
exit $rc

restartPolicy: Never

serviceAccountName: "{{ $sa_name }}"
volumes:
- name: "aws"
secret:
secretName: "{{ $aws_secret }}"
defaultMode: 420
optional: false

backoffLimit: 4

{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions instance-applications/600-ibm-post-sync-jobs/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Loading
Loading