2018-07-27 06:51:51 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Always exit on errors.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Set our known directories.
|
|
|
|
CNI_CONF_DIR="/host/etc/cni/net.d"
|
|
|
|
CNI_BIN_DIR="/host/opt/cni/bin"
|
|
|
|
MULTUS_CONF_FILE="/usr/src/multus-cni/images/70-multus.conf"
|
2019-04-30 15:10:39 -04:00
|
|
|
MULTUS_AUTOCONF_DIR="/host/etc/cni/net.d"
|
2018-07-27 06:51:51 -04:00
|
|
|
MULTUS_BIN_FILE="/usr/src/multus-cni/bin/multus"
|
2018-10-03 11:28:15 -07:00
|
|
|
MULTUS_KUBECONFIG_FILE_HOST="/etc/cni/net.d/multus.d/multus.kubeconfig"
|
2019-01-15 11:21:18 -05:00
|
|
|
MULTUS_NAMESPACE_ISOLATION=false
|
2019-03-07 11:01:03 -05:00
|
|
|
MULTUS_LOG_LEVEL=""
|
|
|
|
MULTUS_LOG_FILE=""
|
2018-07-27 06:51:51 -04:00
|
|
|
|
|
|
|
# Give help text for parameters.
|
|
|
|
function usage()
|
|
|
|
{
|
2018-10-03 11:28:15 -07:00
|
|
|
echo -e "This is an entrypoint script for Multus CNI to overlay its binary and "
|
|
|
|
echo -e "configuration into locations in a filesystem. The configuration & binary file "
|
|
|
|
echo -e "will be copied to the corresponding configuration directory. When "
|
2019-03-07 11:01:03 -05:00
|
|
|
echo -e "'--multus-conf-file=auto' is used, 00-multus.conf will be automatically "
|
2018-10-03 11:28:15 -07:00
|
|
|
echo -e "generated from the CNI configuration file of the master plugin (the first file "
|
|
|
|
echo -e "in lexicographical order in cni-conf-dir)."
|
2018-07-27 06:51:51 -04:00
|
|
|
echo -e ""
|
|
|
|
echo -e "./entrypoint.sh"
|
|
|
|
echo -e "\t-h --help"
|
|
|
|
echo -e "\t--cni-conf-dir=$CNI_CONF_DIR"
|
|
|
|
echo -e "\t--cni-bin-dir=$CNI_BIN_DIR"
|
|
|
|
echo -e "\t--multus-conf-file=$MULTUS_CONF_FILE"
|
|
|
|
echo -e "\t--multus-bin-file=$MULTUS_BIN_FILE"
|
2018-10-03 11:28:15 -07:00
|
|
|
echo -e "\t--multus-kubeconfig-file-host=$MULTUS_KUBECONFIG_FILE_HOST"
|
2019-01-15 11:21:18 -05:00
|
|
|
echo -e "\t--namespace-isolation=$MULTUS_NAMESPACE_ISOLATION"
|
2019-04-30 15:10:39 -04:00
|
|
|
echo -e "\t--multus-autoconfig-dir=$MULTUS_AUTOCONF_DIR (used only with --multus-conf-file=auto)"
|
2019-03-07 11:01:03 -05:00
|
|
|
echo -e "\t--multus-log-level=$MULTUS_LOG_LEVEL (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)"
|
2018-07-27 06:51:51 -04: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)
2019-05-09 14:38:02 -05:00
|
|
|
function log()
|
|
|
|
{
|
|
|
|
echo "$(date --iso-8601=seconds) ${1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function error()
|
|
|
|
{
|
|
|
|
log "ERR: {$1}"
|
|
|
|
}
|
|
|
|
|
|
|
|
function warn()
|
|
|
|
{
|
|
|
|
log "WARN: {$1}"
|
|
|
|
}
|
|
|
|
|
2018-07-27 06:51:51 -04:00
|
|
|
# Parse parameters given as arguments to this script.
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
PARAM=`echo $1 | awk -F= '{print $1}'`
|
|
|
|
VALUE=`echo $1 | awk -F= '{print $2}'`
|
|
|
|
case $PARAM in
|
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
exit
|
|
|
|
;;
|
2019-05-30 16:36:13 +09:00
|
|
|
--cni-version)
|
|
|
|
CNI_VERSION=$VALUE
|
|
|
|
;;
|
2018-07-27 06:51:51 -04:00
|
|
|
--cni-conf-dir)
|
|
|
|
CNI_CONF_DIR=$VALUE
|
|
|
|
;;
|
|
|
|
--cni-bin-dir)
|
|
|
|
CNI_BIN_DIR=$VALUE
|
|
|
|
;;
|
|
|
|
--multus-conf-file)
|
|
|
|
MULTUS_CONF_FILE=$VALUE
|
|
|
|
;;
|
|
|
|
--multus-bin-file)
|
|
|
|
MULTUS_BIN_FILE=$VALUE
|
|
|
|
;;
|
2018-10-03 11:28:15 -07:00
|
|
|
--multus-kubeconfig-file-host)
|
|
|
|
MULTUS_KUBECONFIG_FILE_HOST=$VALUE
|
|
|
|
;;
|
2019-01-15 11:21:18 -05:00
|
|
|
--namespace-isolation)
|
|
|
|
MULTUS_NAMESPACE_ISOLATION=$VALUE
|
|
|
|
;;
|
2019-03-07 11:01:03 -05:00
|
|
|
--multus-log-level)
|
|
|
|
MULTUS_LOG_LEVEL=$VALUE
|
|
|
|
;;
|
|
|
|
--multus-log-file)
|
|
|
|
MULTUS_LOG_FILE=$VALUE
|
|
|
|
;;
|
2019-04-30 15:10:39 -04:00
|
|
|
--multus-autoconfig-dir)
|
|
|
|
MULTUS_AUTOCONF_DIR=$VALUE
|
|
|
|
;;
|
2018-07-27 06:51:51 -04: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)
2019-05-09 14:38:02 -05:00
|
|
|
warn "unknown parameter \"$PARAM\""
|
2018-07-27 06:51:51 -04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
# Create array of known locations
|
2018-10-03 11:28:15 -07:00
|
|
|
declare -a arr=($CNI_CONF_DIR $CNI_BIN_DIR $MULTUS_BIN_FILE)
|
|
|
|
if [ "$MULTUS_CONF_FILE" != "auto" ]; then
|
2018-12-17 10:54:16 -08:00
|
|
|
arr+=($MULTUS_CONF_FILE)
|
2018-10-03 11:28:15 -07:00
|
|
|
fi
|
|
|
|
|
2018-07-27 06:51:51 -04:00
|
|
|
|
|
|
|
# Loop through and verify each location each.
|
|
|
|
for i in "${arr[@]}"
|
|
|
|
do
|
|
|
|
if [ ! -e "$i" ]; then
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
warn "Location $i does not exist"
|
2018-07-27 06:51:51 -04:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2019-01-22 10:38:02 -05:00
|
|
|
# Copy files into place and atomically move into final binary name
|
|
|
|
cp -f $MULTUS_BIN_FILE $CNI_BIN_DIR/_multus
|
|
|
|
mv -f $CNI_BIN_DIR/_multus $CNI_BIN_DIR/multus
|
2018-10-03 11:28:15 -07:00
|
|
|
if [ "$MULTUS_CONF_FILE" != "auto" ]; then
|
|
|
|
cp -f $MULTUS_CONF_FILE $CNI_CONF_DIR
|
|
|
|
fi
|
2018-07-27 06:51:51 -04:00
|
|
|
|
|
|
|
# Make a multus.d directory (for our kubeconfig)
|
|
|
|
|
|
|
|
mkdir -p $CNI_CONF_DIR/multus.d
|
|
|
|
MULTUS_KUBECONFIG=$CNI_CONF_DIR/multus.d/multus.kubeconfig
|
|
|
|
|
|
|
|
# ------------------------------- Generate a "kube-config"
|
|
|
|
# Inspired by: https://tinyurl.com/y7r2knme
|
|
|
|
SERVICE_ACCOUNT_PATH=/var/run/secrets/kubernetes.io/serviceaccount
|
|
|
|
KUBE_CA_FILE=${KUBE_CA_FILE:-$SERVICE_ACCOUNT_PATH/ca.crt}
|
|
|
|
SERVICEACCOUNT_TOKEN=$(cat $SERVICE_ACCOUNT_PATH/token)
|
|
|
|
SKIP_TLS_VERIFY=${SKIP_TLS_VERIFY:-false}
|
|
|
|
|
|
|
|
|
|
|
|
# Check if we're running as a k8s pod.
|
|
|
|
if [ -f "$SERVICE_ACCOUNT_PATH/token" ]; then
|
|
|
|
# We're running as a k8d pod - expect some variables.
|
|
|
|
if [ -z ${KUBERNETES_SERVICE_HOST} ]; then
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
error "KUBERNETES_SERVICE_HOST not set"; exit 1;
|
2018-07-27 06:51:51 -04:00
|
|
|
fi
|
|
|
|
if [ -z ${KUBERNETES_SERVICE_PORT} ]; then
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
error "KUBERNETES_SERVICE_PORT not set"; exit 1;
|
2018-07-27 06:51:51 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$SKIP_TLS_VERIFY" == "true" ]; then
|
|
|
|
TLS_CFG="insecure-skip-tls-verify: true"
|
|
|
|
elif [ -f "$KUBE_CA_FILE" ]; then
|
|
|
|
TLS_CFG="certificate-authority-data: $(cat $KUBE_CA_FILE | base64 | tr -d '\n')"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Write a kubeconfig file for the CNI plugin. Do this
|
|
|
|
# to skip TLS verification for now. We should eventually support
|
|
|
|
# writing more complete kubeconfig files. This is only used
|
|
|
|
# if the provided CNI network config references it.
|
|
|
|
touch $MULTUS_KUBECONFIG
|
|
|
|
chmod ${KUBECONFIG_MODE:-600} $MULTUS_KUBECONFIG
|
|
|
|
cat > $MULTUS_KUBECONFIG <<EOF
|
|
|
|
# Kubeconfig file for Multus CNI plugin.
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Config
|
|
|
|
clusters:
|
|
|
|
- name: local
|
|
|
|
cluster:
|
|
|
|
server: ${KUBERNETES_SERVICE_PROTOCOL:-https}://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT}
|
|
|
|
$TLS_CFG
|
|
|
|
users:
|
|
|
|
- name: multus
|
|
|
|
user:
|
|
|
|
token: "${SERVICEACCOUNT_TOKEN}"
|
|
|
|
contexts:
|
|
|
|
- name: multus-context
|
|
|
|
context:
|
|
|
|
cluster: local
|
|
|
|
user: multus
|
|
|
|
current-context: multus-context
|
|
|
|
EOF
|
|
|
|
|
|
|
|
else
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
warn "Doesn't look like we're running in a kubernetes environment (no serviceaccount token)"
|
2018-07-27 06:51:51 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ---------------------- end Generate a "kube-config".
|
|
|
|
|
2018-10-03 11:28:15 -07:00
|
|
|
# ------------------------------- Generate "00-multus.conf"
|
|
|
|
|
|
|
|
if [ "$MULTUS_CONF_FILE" == "auto" ]; then
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
log "Generating Multus configuration file ..."
|
2019-02-28 13:56:08 -05:00
|
|
|
found_master=false
|
|
|
|
tries=0
|
|
|
|
while [ $found_master == false ]; do
|
2019-04-30 15:10:39 -04:00
|
|
|
MASTER_PLUGIN="$(ls $MULTUS_AUTOCONF_DIR | grep -E '\.conf(list)?$' | grep -Ev '00-multus\.conf' | head -1)"
|
2019-02-28 13:56:08 -05:00
|
|
|
if [ "$MASTER_PLUGIN" == "" ]; then
|
|
|
|
if [ $tries -lt 600 ]; then
|
|
|
|
if ! (($tries % 5)); then
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
log "Attemping to find master plugin configuration, attempt $tries"
|
2019-02-28 13:56:08 -05:00
|
|
|
fi
|
|
|
|
let "tries+=1"
|
|
|
|
sleep 1;
|
|
|
|
else
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
error "Multus could not be configured: no master plugin was found."
|
2019-02-28 13:56:08 -05:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
else
|
2019-03-07 11:01:03 -05:00
|
|
|
|
2019-02-28 13:56:08 -05:00
|
|
|
found_master=true
|
2019-03-07 11:01:03 -05:00
|
|
|
|
|
|
|
ISOLATION_STRING=""
|
|
|
|
if [ "$MULTUS_NAMESPACE_ISOLATION" == true ]; then
|
|
|
|
ISOLATION_STRING="\"namespaceIsolation\": true,"
|
|
|
|
fi
|
|
|
|
|
|
|
|
LOG_LEVEL_STRING=""
|
|
|
|
if [ ! -z "${MULTUS_LOG_LEVEL// }" ]; then
|
|
|
|
case "$MULTUS_LOG_LEVEL" in
|
|
|
|
debug)
|
|
|
|
;;
|
|
|
|
error)
|
|
|
|
;;
|
|
|
|
panic)
|
|
|
|
;;
|
|
|
|
verbose)
|
|
|
|
;;
|
|
|
|
*)
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
error "Log levels should be one of: debug/verbose/error/panic, did not understand $MULTUS_LOG_LEVEL"
|
2019-03-07 11:01:03 -05:00
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
LOG_LEVEL_STRING="\"logLevel\": \"$MULTUS_LOG_LEVEL\","
|
|
|
|
fi
|
|
|
|
|
|
|
|
LOG_FILE_STRING=""
|
|
|
|
if [ ! -z "${MULTUS_LOG_FILE// }" ]; then
|
|
|
|
LOG_FILE_STRING="\"logFile\": \"$MULTUS_LOG_FILE\","
|
|
|
|
fi
|
|
|
|
|
2019-05-30 16:36:13 +09:00
|
|
|
CNI_VERSION_STRING=""
|
|
|
|
if [ ! -z "${CNI_VERSION// }" ]; then
|
|
|
|
CNI_VERSION_STRING="\"cniVersion\": \"$CNI_VERSION\","
|
|
|
|
fi
|
|
|
|
|
2019-04-30 15:10:39 -04:00
|
|
|
MASTER_PLUGIN_JSON="$(cat $MULTUS_AUTOCONF_DIR/$MASTER_PLUGIN)"
|
2019-02-28 13:56:08 -05:00
|
|
|
CONF=$(cat <<-EOF
|
2019-03-07 11:01:03 -05:00
|
|
|
{
|
2019-05-30 16:36:13 +09:00
|
|
|
$CNI_VERSION_STRING
|
2019-03-07 11:01:03 -05:00
|
|
|
"name": "multus-cni-network",
|
|
|
|
"type": "multus",
|
|
|
|
$ISOLATION_STRING
|
|
|
|
$LOG_LEVEL_STRING
|
|
|
|
$LOG_FILE_STRING
|
|
|
|
"kubeconfig": "$MULTUS_KUBECONFIG_FILE_HOST",
|
|
|
|
"delegates": [
|
|
|
|
$MASTER_PLUGIN_JSON
|
|
|
|
]
|
|
|
|
}
|
2019-02-28 13:56:08 -05:00
|
|
|
EOF
|
2019-03-07 11:01:03 -05:00
|
|
|
)
|
2019-02-28 13:56:08 -05:00
|
|
|
echo $CONF > $CNI_CONF_DIR/00-multus.conf
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
log "Config file created @ $CNI_CONF_DIR/00-multus.conf"
|
|
|
|
echo $CONF
|
2019-01-15 11:21:18 -05:00
|
|
|
fi
|
2019-02-28 13:56:08 -05:00
|
|
|
done
|
2018-10-03 11:28:15 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ---------------------- end Generate "00-multus.conf".
|
|
|
|
|
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)
2019-05-09 14:38:02 -05:00
|
|
|
log "Entering sleep... (success)"
|
2018-07-27 06:51:51 -04:00
|
|
|
|
|
|
|
# Sleep forever.
|
|
|
|
sleep infinity
|