Skip to content
Merged
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
10 changes: 10 additions & 0 deletions example-config/dev/cluster1/instance1/ibm-mas-instance-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ instance:
sm:
aws_access_key_id: "<path:arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:dev/cluster1/aws#sm_aws_access_key_id>"
aws_secret_access_key: "<path:arn:aws:secretsmanager:us-east-1:xxxxxxxxxxxx:secret:dev/cluster1/aws#sm_aws_secret_access_key>"

# Additional Resources Configuration Example
additional_resources:
instances:
- name: instance-name-1
cost: 100
reasonCode: 101
- name: instance-name-2
cost: 250
reasonCode: 102
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ rules:
- "config.mas.ibm.com"
resources:
- "*"
- verbs:
- delete
- get
- list
- watch
apiGroups:
- addons.mas.ibm.com
resources:
- genericaddons

---
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.additional_resources }}
---
apiVersion: addons.mas.ibm.com/v1
kind: GenericAddon
metadata:
name: "{{ .Values.instance_id }}-addons-additional-resources"
namespace: mas-{{ .Values.instance_id }}-core
annotations:
argocd.argoproj.io/sync-wave: "559"
labels:
mas.ibm.com/configScope: system
mas.ibm.com/instanceId: {{ .Values.instance_id }}
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
spec:
displayName: "{{ .Values.instance_id }}-AdditionalResources"
addonType: additional-resources
config:
addonIdentifier: {{ .Values.instance_id }}
instances:
{{- if .Values.additional_resources.instances }}
{{- range .Values.additional_resources.instances }}
- name: {{ .name }}
cost: {{ .cost }}
reasonCode: {{ .reasonCode }}
{{- end }}
{{- else }}
[]
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{{- if .Values.use_postdelete_hooks }}

{{- /*
Use the build/bin/set-cli-image-digest.sh script to update this value across all charts.
*/}}
{{- $_cli_image_digest := "sha256:55b5d6dd185503f14c112836a9a4899347d28e7b6545e0b9cf21d87f9526fb40" }}

{{- $_addon_type := "additional-resources" }}
{{- $_addon_cr_name := printf "%s-addons-%s" .Values.instance_id $_addon_type }}

{{ $job_name := printf "postdelete-delete-cr-job-%s" $_addon_cr_name }}

# NOTE: depends on resources created in ibm-mas-suite chart (01-postdelete-crs-resources)
# The values below must align with the values in that file
{{ $role_name := "postdelete-delete-cr-r" }}
{{ $sa_name := "postdelete-delete-cr-sa" }}
{{ $rb_name := "postdelete-delete-cr-rb" }}
{{ $np_name := "postdelete-delete-cr-np" }}
{{ $job_label := "postdelete-delete-cr-job" }}
{{ $ns := printf "mas-%s-core" .Values.instance_id }}

---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ $job_name }}
namespace: {{ $ns }}
annotations:
argocd.argoproj.io/hook: PostDelete
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
{{- if .Values.custom_labels }}
labels:
{{ .Values.custom_labels | toYaml | indent 4 }}
{{- end }}
spec:
ttlSecondsAfterFinished: 300
template:
metadata:
labels:
app: {{ $job_label }}
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
spec:
containers:
- name: run
image: {{ .Values.cli_image_repo | default "quay.io/ibmmas/cli" }}@{{ $_cli_image_digest }}
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 10m
memory: 64Mi
env:
- name: CR_NAMESPACE
value: {{ $ns }}
- name: CR_NAME
value: {{ $_addon_cr_name }}
- name: CR_API_VERSION
value: addons.mas.ibm.com/v1
- name: CR_KIND
value: GenericAddon
command:
- /bin/sh
- -c
- |
set -e
function delete_oc_resource(){
RESOURCE=$1
NAMESPACE=$2
echo
echo "------------------------------------------------------------------"
echo "Check if resource $RESOURCE is present in namespace $NAMESPACE "
# don't want a non-zero rc from oc delete to cause the job to fail
# so, temporarily set +e
set +e
RESOURCE_NAME=$(oc get $RESOURCE -n $NAMESPACE -o=jsonpath="{.metadata.name}")
set -e
if [[ -z "${RESOURCE_NAME}" ]]; then
echo "$RESOURCE not found, skipping"
return 0
fi
echo "oc delete resource $RESOURCE in namespace $NAMESPACE "
# don't want a non-zero rc from oc delete to cause the job to fail (since we then want to try patching out the finalizers)
# so, temporarily set +e
set +e
oc delete $RESOURCE -n $NAMESPACE --timeout=300s --wait=true
return_code=$?
set -e
echo "Verify that resource $RESOURCE is now absent in namespace $NAMESPACE "
# don't want a non-zero rc from oc delete to cause the job to fail
# so, temporarily set +e
set +e
RESOURCE_NAME=$(oc get $RESOURCE -n $NAMESPACE -o=jsonpath="{.metadata.name}")
set -e
if [[ -n "${RESOURCE_NAME}" ]]; then
echo "$RESOURCE still present, failing job"
exit 1
fi
echo "... verified"
return 0

}
delete_oc_resource "${CR_KIND} ${CR_NAME}" "${CR_NAMESPACE}"
restartPolicy: Never
serviceAccountName: {{ $sa_name }}
backoffLimit: 4
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ spec:
syncOptions:
- CreateNamespace=false
- RespectIgnoreDifferences=true
- ServerSideApply=true
retry:
limit: -1
ignoreDifferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,4 @@ spec:
syncOptions:
- CreateNamespace=false
- RespectIgnoreDifferences=true
- ServerSideApply=true
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ spec:
- CreateNamespace=true
- RespectIgnoreDifferences=true
- Validate=false
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ spec:
limit: 20
syncOptions:
- CreateNamespace=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ spec:
syncOptions:
- CreateNamespace=true
- ServerSideApply=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ spec:
syncOptions:
- CreateNamespace=false
- RespectIgnoreDifferences=true
- ServerSideApply=true
retry:
limit: -1
ignoreDifferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ spec:
syncOptions:
- CreateNamespace=false
- RespectIgnoreDifferences=true
- ServerSideApply=true
retry:
limit: -1
ignoreDifferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ spec:
syncOptions:
- CreateNamespace=false
- RespectIgnoreDifferences=true
- ServerSideApply=true
retry:
limit: -1
ignoreDifferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ spec:
syncOptions:
- CreateNamespace=true
- RespectIgnoreDifferences=true
- ServerSideApply=true
{{- if .Values.custom_labels }}
managedNamespaceMetadata:
labels:
{{- if .Values.custom_labels }}
{{ .Values.custom_labels | toYaml | indent 8 }}
{{- end }}
Loading
Loading