Skip to content

Commit 3afaf8d

Browse files
committed
capture remaining resources in migration script
1 parent b30b93f commit 3afaf8d

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

migrations/standardize-labels.sh

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,25 @@ function klabel_app_name() {
4040
"app.kubernetes.io/name=${app}"
4141
}
4242

43+
function k_get_app_names() {
44+
kind=${1}
45+
app=${2}
46+
kubectl get "${kind}" \
47+
-n "${NAMESPACE}" \
48+
-l "vendor=stackstorm" \
49+
-l "release=${RELEASE_NAME}" \
50+
| jq -r '.items[] | select(.metadata.name | test("'"${app}"'")).metadata.labels.app'
51+
}
52+
53+
echo "Adding label app.kubernetes.io/instance=${RELEASE_NAME} (which will replace release=${RELEASE_NAME}) ..."
54+
4355
for kind in ConfigMap Secret Ingress Service ServiceAccount Deployment ReplicaSet Pod Job; do
4456
klabel_app_instance ${kind}
4557
done
4658

59+
echo
60+
echo "Adding label app.kubernetes.io/name=<app> (which will replace app=<app>) ..."
61+
4762
klabel_app_name ConfigMap st2
4863
klabel_app_name Secret st2
4964
klabel_app_name Secret st2chatops
@@ -53,17 +68,46 @@ klabel_app_name ServiceAccount ${CHART_NAME}
5368

5469
klabel_app_name Ingress ingress
5570

56-
for app in st2actionrunner st2api st2auth st2chatops st2client st2garbagecollector st2notifier st2rulesengine st2scheduler st2stream st2timersengine st2web st2workflowengine; do
71+
deployment_apps=(
72+
st2actionrunner
73+
st2api
74+
st2auth
75+
st2chatops
76+
st2client
77+
st2garbagecollector
78+
st2notifier
79+
st2rulesengine
80+
st2scheduler
81+
$(k_get_app_names Deployment st2sensorcontainer)
82+
st2stream
83+
st2timersengine
84+
st2web
85+
st2workflowengine
86+
)
87+
for app in "${deployment_apps[@]}"; do
5788
klabel_app_name Deployment ${app}
5889
klabel_app_name ReplicaSet ${app}
5990
klabel_app_name Pod ${app}
6091
done
6192

62-
for app in st2api st2auth st2chatops st2stream st2web; do
93+
service_apps=(
94+
st2api
95+
st2auth
96+
st2chatops
97+
st2stream
98+
st2web
99+
)
100+
for app in "${service_apps[@]}"; do
63101
klabel_app_name Service ${app}
64102
done
65103

66-
for app in st2 st2-apply-rbac-definitions st2-register-content; do
104+
job_apps=(
105+
st2
106+
st2-apply-rbac-definitions
107+
st2-register-content
108+
$(k_get_app_names Job extra-helm-hook)
109+
)
110+
for app in "${job_apps[@]}"; do
67111
klabel_app_name Job ${app}
68112
klabel_app_name Pod ${app}
69113
done

0 commit comments

Comments
 (0)