mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-25 19:44:28 +00:00
entrypoint.sh: add timestamps to log messages; log autogenerated config file
Example: 2019-05-09T15:41:20-05:00 Generating Multus configuration file ... 2019-05-09T15:41:20-05:00 Attemping to find master plugin configuration, attempt 0 2019-05-09T15:41:20-05:00 Attemping to find master plugin configuration, attempt 1 2019-05-09T15:41:20-05:00 Attemping to find master plugin configuration, attempt 10 2019-05-09T15:41:20-05:00 Attemping to find master plugin configuration, attempt 15 2019-05-09T15:41:20-05:00 Attemping to find master plugin configuration, attempt 20 2019-05-09T15:41:20-05:00 Config file created @ /host/etc/cni/net.d/00-multus.conf { "name": "multus-cni-network", "type": "multus", "namespaceIsolation": true, "logLevel": "verbose", "kubeconfig": "/etc/kubernetes/cni/net.d/multus.d/multus.kubeconfig", "delegates": [ { "cniVersion": "0.3.1", "name": "openshift-sdn", "type": "openshift-sdn" } ] } 2019-05-09T15:41:20-05:00 Entering sleep... (success)
This commit is contained in:
parent
381db908a2
commit
41160c62d6
@ -37,6 +37,21 @@ function usage()
|
|||||||
echo -e "\t--multus-log-file=$MULTUS_LOG_FILE (empty by default, used only with --multus-conf-file=auto)"
|
echo -e "\t--multus-log-file=$MULTUS_LOG_FILE (empty by default, used only with --multus-conf-file=auto)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function log()
|
||||||
|
{
|
||||||
|
echo "$(date --iso-8601=seconds) ${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function error()
|
||||||
|
{
|
||||||
|
log "ERR: {$1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function warn()
|
||||||
|
{
|
||||||
|
log "WARN: {$1}"
|
||||||
|
}
|
||||||
|
|
||||||
# Parse parameters given as arguments to this script.
|
# Parse parameters given as arguments to this script.
|
||||||
while [ "$1" != "" ]; do
|
while [ "$1" != "" ]; do
|
||||||
PARAM=`echo $1 | awk -F= '{print $1}'`
|
PARAM=`echo $1 | awk -F= '{print $1}'`
|
||||||
@ -74,7 +89,7 @@ while [ "$1" != "" ]; do
|
|||||||
MULTUS_AUTOCONF_DIR=$VALUE
|
MULTUS_AUTOCONF_DIR=$VALUE
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "WARNING: unknown parameter \"$PARAM\""
|
warn "unknown parameter \"$PARAM\""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
@ -92,7 +107,7 @@ fi
|
|||||||
for i in "${arr[@]}"
|
for i in "${arr[@]}"
|
||||||
do
|
do
|
||||||
if [ ! -e "$i" ]; then
|
if [ ! -e "$i" ]; then
|
||||||
echo "Location $i does not exist"
|
warn "Location $i does not exist"
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -121,10 +136,10 @@ SKIP_TLS_VERIFY=${SKIP_TLS_VERIFY:-false}
|
|||||||
if [ -f "$SERVICE_ACCOUNT_PATH/token" ]; then
|
if [ -f "$SERVICE_ACCOUNT_PATH/token" ]; then
|
||||||
# We're running as a k8d pod - expect some variables.
|
# We're running as a k8d pod - expect some variables.
|
||||||
if [ -z ${KUBERNETES_SERVICE_HOST} ]; then
|
if [ -z ${KUBERNETES_SERVICE_HOST} ]; then
|
||||||
echo "KUBERNETES_SERVICE_HOST not set"; exit 1;
|
error "KUBERNETES_SERVICE_HOST not set"; exit 1;
|
||||||
fi
|
fi
|
||||||
if [ -z ${KUBERNETES_SERVICE_PORT} ]; then
|
if [ -z ${KUBERNETES_SERVICE_PORT} ]; then
|
||||||
echo "KUBERNETES_SERVICE_PORT not set"; exit 1;
|
error "KUBERNETES_SERVICE_PORT not set"; exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$SKIP_TLS_VERIFY" == "true" ]; then
|
if [ "$SKIP_TLS_VERIFY" == "true" ]; then
|
||||||
@ -161,7 +176,7 @@ current-context: multus-context
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "WARNING: Doesn't look like we're running in a kubernetes environment (no serviceaccount token)"
|
warn "Doesn't look like we're running in a kubernetes environment (no serviceaccount token)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---------------------- end Generate a "kube-config".
|
# ---------------------- end Generate a "kube-config".
|
||||||
@ -169,7 +184,7 @@ fi
|
|||||||
# ------------------------------- Generate "00-multus.conf"
|
# ------------------------------- Generate "00-multus.conf"
|
||||||
|
|
||||||
if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
||||||
echo "Generating Multus configuration file ..."
|
log "Generating Multus configuration file ..."
|
||||||
found_master=false
|
found_master=false
|
||||||
tries=0
|
tries=0
|
||||||
while [ $found_master == false ]; do
|
while [ $found_master == false ]; do
|
||||||
@ -177,12 +192,12 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
|||||||
if [ "$MASTER_PLUGIN" == "" ]; then
|
if [ "$MASTER_PLUGIN" == "" ]; then
|
||||||
if [ $tries -lt 600 ]; then
|
if [ $tries -lt 600 ]; then
|
||||||
if ! (($tries % 5)); then
|
if ! (($tries % 5)); then
|
||||||
echo "Attemping to find master plugin configuration, attempt $tries"
|
log "Attemping to find master plugin configuration, attempt $tries"
|
||||||
fi
|
fi
|
||||||
let "tries+=1"
|
let "tries+=1"
|
||||||
sleep 1;
|
sleep 1;
|
||||||
else
|
else
|
||||||
echo "Error: Multus could not be configured: no master plugin was found."
|
error "Multus could not be configured: no master plugin was found."
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -206,7 +221,7 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
|||||||
verbose)
|
verbose)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "ERROR: Log levels should be one of: debug/verbose/error/panic, did not understand $MULTUS_LOG_LEVEL"
|
error "Log levels should be one of: debug/verbose/error/panic, did not understand $MULTUS_LOG_LEVEL"
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
@ -234,14 +249,15 @@ if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
|||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
echo $CONF > $CNI_CONF_DIR/00-multus.conf
|
echo $CONF > $CNI_CONF_DIR/00-multus.conf
|
||||||
echo "Config file created @ $CNI_CONF_DIR/00-multus.conf"
|
log "Config file created @ $CNI_CONF_DIR/00-multus.conf"
|
||||||
|
echo $CONF
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ---------------------- end Generate "00-multus.conf".
|
# ---------------------- end Generate "00-multus.conf".
|
||||||
|
|
||||||
echo "Entering sleep... (success)"
|
log "Entering sleep... (success)"
|
||||||
|
|
||||||
# Sleep forever.
|
# Sleep forever.
|
||||||
sleep infinity
|
sleep infinity
|
||||||
|
Loading…
Reference in New Issue
Block a user