@@ -934,7 +934,7 @@ metadata:
934934 namespace : openshift-multus
935935 annotations :
936936 kubernetes.io/description : |
937- This deamon watches over the whereabouts service account token and CA
937+ This daemon watches over the whereabouts service account token and CA
938938 file for changes and will regenerate a kubeconfig if changes are seen
939939 release.openshift.io/version : " {{.ReleaseVersion}}"
940940spec :
@@ -954,6 +954,7 @@ spec:
954954 labels :
955955 app : whereabouts-token-watcher
956956 spec :
957+ hostNetwork : true
957958 nodeSelector :
958959 kubernetes.io/os : linux
959960 priorityClassName : " system-node-critical"
@@ -971,11 +972,16 @@ spec:
971972
972973 set -u -e
973974
975+ # Helper functions for logging
976+ function log { echo "$(date -Iseconds) $@"; }
977+ function warn { echo "$(date -Iseconds) WARNING: $@" >&2; }
978+ function error { echo "$(date -Iseconds) ERROR: $@" >&2; }
979+
974980 SERVICE_ACCOUNT_PATH=/var/run/secrets/kubernetes.io/serviceaccount
975981 KUBE_CA_FILE=${KUBE_CA_FILE:-$SERVICE_ACCOUNT_PATH/ca.crt}
976- SERVICE_ACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token)
977982 SERVICE_ACCOUNT_TOKEN_PATH=$SERVICE_ACCOUNT_PATH/token
978983 SKIP_TLS_VERIFY=${SKIP_TLS_VERIFY:-false}
984+ WHEREABOUTS_KUBECONFIG=${CNI_CONF_DIR:-/host/etc/cni/net.d}/whereabouts.d/whereabouts.kubeconfig
979985
980986 function generateKubeConfig {
981987 # Check if we're running as a k8s pod.
@@ -1017,7 +1023,7 @@ spec:
10171023 users:
10181024 - name: whereabouts
10191025 user:
1020- token: "${SERVICE_ACCOUNT_TOKEN} "
1026+ token: "$(cat $SERVICE_ACCOUNT_TOKEN_PATH) "
10211027 contexts:
10221028 - name: whereabouts-context
10231029 context:
@@ -1048,20 +1054,20 @@ spec:
10481054 export LAST_SERVICEACCOUNT_MD5SUM="$(get_token_md5sum)"
10491055 export LAST_KUBE_CA_FILE_MD5SUM="$(get_ca_file_md5sum)"
10501056
1051- echo "Sleep and Watching for service account token and CA file changes..."
1057+ log "Sleep and Watching for service account token and CA file changes..."
10521058 # enter sleep/watch loop
10531059 while true; do
10541060 # Check the md5sum of the service account token and ca.
10551061 svcaccountsum="$(get_token_md5sum)"
10561062 casum="$(get_ca_file_md5sum)"
1057- if [ "$svcaccountsum" != "$LAST_SERVICEACCOUNT_MD5SUM" ] || ! [ "$SKIP_TLS_VERIFY" == "true" ] && [ "$casum" != "$LAST_KUBE_CA_FILE_MD5SUM" ]; then
1063+ if [ "$svcaccountsum" != "$LAST_SERVICEACCOUNT_MD5SUM" ] || ( [ "$SKIP_TLS_VERIFY" != "true" ] && [ "$casum" != "$LAST_KUBE_CA_FILE_MD5SUM" ] ) ; then
10581064 log "Detected service account or CA file change, regenerating kubeconfig..."
10591065 generateKubeConfig
10601066 LAST_SERVICEACCOUNT_MD5SUM="$svcaccountsum"
10611067 LAST_KUBE_CA_FILE_MD5SUM="$casum"
10621068 fi
10631069
1064- sleep 1s
1070+ sleep 60s
10651071 done
10661072
10671073 resources :
@@ -1072,6 +1078,8 @@ spec:
10721078 volumeMounts :
10731079 - name : whereabouts-flatfile-configmap
10741080 mountPath : /etc/whereabouts/config
1081+ - mountPath : /host/etc/cni/net.d
1082+ name : cni-net-dir
10751083 env :
10761084 - name : KUBERNETES_SERVICE_PORT
10771085 value : " {{.KUBERNETES_SERVICE_PORT}}"
@@ -1081,13 +1089,15 @@ spec:
10811089 value : " /host/opt/cni/bin/"
10821090 - name : CNI_CONF_DIR
10831091 value : " /host/etc/cni/net.d"
1084- - name : SLEEP
1085- value : " false"
10861092 - name : WHEREABOUTS_NAMESPACE
10871093 value : " openshift-multus"
10881094 volumes :
10891095 - name : whereabouts-flatfile-configmap
10901096 configMap :
10911097 name : whereabouts-flatfile-config
1098+ - name : cni-net-dir
1099+ hostPath :
1100+ path : {{ .SystemCNIConfDir }}
1101+ type : Directory
10921102{{- end}}
10931103---
0 commit comments