File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ source lib.sh
1717
1818# -------------------Generate a "kube-config"
1919generateKubeConfig
20+ export LAST_SERVICEACCOUNT_MD5SUM=" $( get_token_md5sum) "
21+ if ! [ " $SKIP_TLS_VERIFY " == " true" ]; then
22+ export LAST_KUBE_CA_FILE_MD5SUM=" $( get_ca_file_md5sum) "
23+ fi
2024# ------------------ end Generate a "kube-config"
2125
2226# ----------------- Generate a whereabouts conf
Original file line number Diff line number Diff line change @@ -107,3 +107,15 @@ function generateWhereaboutsConf {
107107EOF
108108
109109}
110+
111+ function get_token_md5sum {
112+ md5sum " $SERVICE_ACCOUNT_TOKEN_PATH " | awk ' {print $1}'
113+ }
114+
115+ function get_ca_file_md5sum {
116+ if [ ! -f " $KUBE_CA_FILE " ]; then
117+ echo " "
118+ return
119+ fi
120+ md5sum " $KUBE_CA_FILE " | awk ' {print $1}'
121+ }
Original file line number Diff line number Diff line change @@ -9,11 +9,17 @@ echo "Sleep and Watching for service account token and CA file changes..."
99while true ; do
1010 # Check the md5sum of the service account token and ca.
1111 svcaccountsum=$( md5sum $SERVICE_ACCOUNT_TOKEN_PATH | awk ' {print $1}' )
12- casum=$( md5sum $KUBE_CA_FILE | awk ' {print $1}' )
13- if [ " $svcaccountsum " != " $LAST_SERVICEACCOUNT_MD5SUM " ] || [ " $casum " != " $LAST_KUBE_CA_FILE_MD5SUM " ]; then
12+ if [ -f " $KUBE_CA_FILE " ]; then
13+ casum=$( md5sum $KUBE_CA_FILE | awk ' {print $1}' )
14+ fi
15+ if [ " $svcaccountsum " != " $LAST_SERVICEACCOUNT_MD5SUM " ] || ! [ " $SKIP_TLS_VERIFY " == " true" ] && [ " $casum " != " $LAST_KUBE_CA_FILE_MD5SUM " ]; then
1416 # log "Detected service account or CA file change, regenerating kubeconfig..."
1517 generateKubeConfig
18+ LAST_SERVICEACCOUNT_MD5SUM=" $( get_token_md5sum) "
19+ if [ -f " $KUBE_CA_FILE " ]; then
20+ LAST_KUBE_CA_FILE_MD5SUM=" $( get_ca_file_md5sum) "
21+ fi
1622 fi
1723
18- sleep 1h
24+ sleep 1s
1925done
You can’t perform that action at this time.
0 commit comments