Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-1.32] Update contract downgrade script to be standalone (#2555)
* Update script to allow namespace specification and to include names of main contract configmaps already. * Remove suppressing errors * Unset ingress.enableAutoCreateEventTypes in downgrade.sh too * Update test/upgrade/installation/downgrade.sh Co-authored-by: Calum Murray <cmurray@redhat.com> * Trigger update of volume with mounted contract configmap * kafka-source-receiver -> kafka-sink-receiver --------- Co-authored-by: Calum Murray <cmurray@redhat.com> Co-authored-by: Pierangelo Di Pilato <pierangelodipilato@gmail.com>
- Loading branch information
1 parent
1d312db
commit 5a25a16
Showing
2 changed files
with
28 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
for cm_name in "$@"; do | ||
cmdata=$(kubectl get cm "$cm_name" -n knative-eventing -ojson) | ||
# Removes the `trustBundles` key from contract configmaps. | ||
# | ||
# Usage | ||
# downgrade.sh <namespace> <additional-configmaps> | ||
# Example: | ||
# downgrade.sh knative-eventing kafka-source-dispatcher-0 kafka-source-dispatcher-1 | ||
# | ||
# namespace: Optional - The namespace in which to update the configmaps. Defaults to "knative-eventing" | ||
# additional-configmaps: Optional - List of additional contract configmaps to patch | ||
# (in addition to kafka-broker-brokers-triggers, kafka-channel-channels-subscriptions and kafka-sink-sinks) | ||
|
||
target_namespace="${1:-"knative-eventing"}" | ||
declare -a contract_configmaps=("kafka-broker-brokers-triggers" "kafka-channel-channels-subscriptions" "kafka-sink-sinks") | ||
|
||
for additional_cm in "${@:2}"; do | ||
contract_configmaps+=("$additional_cm") | ||
done | ||
|
||
for cm_name in "${contract_configmaps[@]}"; do | ||
cmdata=$(kubectl get cm "$cm_name" -n "$target_namespace" -ojson || true) | ||
if [ -n "$cmdata" ]; then | ||
new_data=$(echo "$cmdata" | jq -r .binaryData.data | base64 --decode | jq 'del(.trustBundles)' -c | base64 -w 0) | ||
new_data=$(echo "$cmdata" | jq -r .binaryData.data | base64 --decode | jq 'del(.trustBundles, .resources[].ingress.enableAutoCreateEventTypes)' -c | base64 -w 0) | ||
echo "$cmdata" | jq --arg new_data "$new_data" '.binaryData.data = $new_data' | kubectl apply -f - | ||
fi | ||
done | ||
|
||
# Trigger a reconcile of the related pods (see https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#mounted-configmaps-are-updated-automatically) | ||
declare -a pods_app_labels=("kafka-broker-dispatcher" "kafka-broker-receiver" "kafka-channel-dispatcher" "kafka-channel-receiver" "kafka-source-dispatcher" "kafka-sink-receiver") | ||
for app_label in "${pods_app_labels[@]}"; do | ||
kubectl -n "$target_namespace" annotate pod -l=app="$app_label" why="to trigger a reconcile" --overwrite || true | ||
done |
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