python3 -m pip install -r /usr/lib/python3/dist-packages/osmclient/requirements.txt
fi
echo -e "\nOSM client installed"
- echo -e "OSM client assumes that OSM host is running in localhost (127.0.0.1)."
- echo -e "In case you want to interact with a different OSM host, you will have to configure this env variable in your .bashrc file:"
- echo " export OSM_HOSTNAME=nbi.${OSM_DEFAULT_IP}.nip.io"
+ echo "You can get the OSM NBI endpoint using the following command"
+ echo ' kubectl -n osm get ingress nbi-ingress -o jsonpath="{.spec.rules[0].host}"'
+ echo "You will have to configure this env variable in your .bashrc file:"
+ echo " export OSM_HOSTNAME=nbi.${OSM_K8S_EXTERNAL_IP}.nip.io"
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
return 0
}
[ ! "$OSM_DOCKER_TAG" == "testing-daily" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set-string global.image.tag=${OSM_DOCKER_TAG}"
[ ! "$OSM_DOCKER_TAG" == "testing-daily" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.server.sidecarContainers.prometheus-config-sidecar.image=${DOCKER_REGISTRY_URL}${DOCKER_USER}/prometheus:${OSM_DOCKER_TAG}"
- OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.hostname=${OSM_DEFAULT_IP}.nip.io"
- OSM_HELM_OPTS="${OSM_HELM_OPTS} --set grafana.ingress.hosts={grafana.${OSM_DEFAULT_IP}.nip.io}"
- OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.server.ingress.hosts={prometheus.${OSM_DEFAULT_IP}.nip.io}"
- # OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.alertmanager.ingress.hosts={alertmanager.${OSM_DEFAULT_IP}.nip.io}"
+ OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.hostname=${OSM_K8S_EXTERNAL_IP}.nip.io"
+ OSM_HELM_OPTS="${OSM_HELM_OPTS} --set grafana.ingress.hosts={grafana.${OSM_K8S_EXTERNAL_IP}.nip.io}"
+ OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.server.ingress.hosts={prometheus.${OSM_K8S_EXTERNAL_IP}.nip.io}"
+ # OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.alertmanager.ingress.hosts={alertmanager.${OSM_K8S_EXTERNAL_IP}.nip.io}"
if [ -z "${INSTALL_MGMT_CLUSTER}" ]; then
OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.enabled=false"
else
function install_osm_ngsa_service() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- NGSA_OPTS="-i ${OSM_DEFAULT_IP} -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}"
+ NGSA_OPTS="-i ${OSM_K8S_EXTERNAL_IP} -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}"
[ -n "${DOCKER_REGISTRY_URL}" ] && NGSA_OPTS="${NGSA_OPTS} -r ${DOCKER_REGISTRY_URL}"
$OSM_DEVOPS/installers/install_ngsa.sh ${NGSA_OPTS} || \
FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed"
function add_local_k8scluster() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
# OSM_HOSTNAME=$(kubectl get --namespace osm -o jsonpath="{.spec.rules[0].host}" ingress nbi-ingress)
- OSM_HOSTNAME="nbi.${OSM_DEFAULT_IP}.nip.io:443"
+ OSM_HOSTNAME="nbi.${OSM_K8S_EXTERNAL_IP}.nip.io:443"
/usr/bin/osm --hostname ${OSM_HOSTNAME} --all-projects vim-create \
--name _system-osm-vim \
--account_type dummy \
FATAL_TRACK k8scluster "install_cluster_addons.sh failed for kubeadm cluster"
elif [ "${K8S_CLUSTER_ENGINE}" == "k3s" ]; then
K3S_INSTALL_OPTS="-i ${OSM_DEFAULT_IP} -D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
+ [ "${OSM_K8S_EXTERNAL_IP}" != "${OSM_DEFAULT_IP}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -e ${OSM_K8S_EXTERNAL_IP}"
[ -n "${DOCKER_PROXY_URL}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -p ${DOCKER_PROXY_URL}"
[ -n "${DOCKER_REGISTRY_URL}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -d ${DOCKER_REGISTRY_URL}"
[ -n "${DOCKER_REGISTRY_USER}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -u ${DOCKER_REGISTRY_USER}"
[ -z "$OSM_DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
OSM_DEFAULT_IP=`ip -o -4 a s ${OSM_DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]; exit}'`
[ -z "$OSM_DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
+ OSM_K8S_EXTERNAL_IP=${OSM_K8S_EXTERNAL_IP:-${OSM_DEFAULT_IP}}
# configure apt proxy
[ -n "$APT_PROXY_URL" ] && configure_apt_proxy $APT_PROXY_URL
echo "OPENSTACK_VM_NAME"="$OPENSTACK_VM_NAME"
echo "OSM_DEVOPS=$OSM_DEVOPS"
echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
+ echo "OSM_K8S_EXTERNAL_IP=$OSM_K8S_EXTERNAL_IP"
echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
echo "OSM_NAMESPACE=$OSM_NAMESPACE"
echo "OSM_VCA_HOST=$OSM_VCA_HOST"
MODULE_DOCKER_TAG=
OSM_INSTALLATION_TYPE="Default"
-while getopts ":a:c:r:n:k:u:R:D:o:O:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:G:M:-: hy" o; do
+while getopts ":a:c:e:r:n:k:u:R:D:o:O:N:H:S:s:t:U:P:A:l:L:K:d:p:T:f:F:G:M:-: hy" o; do
case "${o}" in
a)
APT_PROXY_URL=${OPTARG}
echo -e "Invalid argument for -c : ' ${K8S_CLUSTER_ENGINE}'\n" >&2
usage && exit 1
;;
+ e)
+ OSM_K8S_EXTERNAL_IP="${OPTARG}"
+ ;;
r)
REPOSITORY="${OPTARG}"
REPO_ARGS+=(-r "$REPOSITORY")
function install_k3s() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
export INSTALL_K3S_EXEC="--disable traefik"
+
+ # Regular installation of K3s
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=${K8S_VERSION} sh -s -
+
+ # If specified a public IP, K3s service is updated accordingly and restarted
+ if [ -n "${K3S_PUBLIC_IP}" ]; then
+ # Back-up service config file to home
+ cp /etc/systemd/system/k3s.service ~/BASE-k3s.service
+
+ # Generate new service config file with additions for using a public IP
+ (
+ cat ~/BASE-k3s.service | sed '${/^$/d}'
+ echo -e "\t'--node-external-ip' \\"
+ echo -e "\t'${K3S_PUBLIC_IP}' \\"
+ echo
+ )| \
+ tee ~/PUBLIC-k3s.service
+
+ # Replace service config and apply
+ sudo cp ~/PUBLIC-k3s.service /etc/systemd/system/k3s.service
+ sudo systemctl daemon-reload
+ sudo systemctl restart k3s
+
+ # Cleanup
+ rm ~/BASE-k3s.service ~/PUBLIC-k3s.service
+ fi
+
+ # Make kubeconfig permissions less restrictive
sudo chmod 644 /etc/rancher/k3s/k3s.yaml
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
}
# main
-while getopts ":D:i:p:d:u:P:-: " o; do
+while getopts ":D:i:e:p:d:u:P:-: " o; do
case "${o}" in
i)
DEFAULT_IP="${OPTARG}"
;;
+ e)
+ K3S_PUBLIC_IP="${OPTARG}"
+ ;;
D)
OSM_DEVOPS="${OPTARG}"
;;
DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL=-}
DOCKER_REGISTRY_USER=${DOCKER_REGISTRY_USER=-}
DOCKER_REGISTRY_PASSWORD=${DOCKER_REGISTRY_PASSWORD=-}
+K3S_PUBLIC_IP=${K3S_PUBLIC_IP:-}
echo "DEBUG_INSTALL=${DEBUG_INSTALL}"
echo "DEFAULT_IP=${DEFAULT_IP}"
echo "OSM_DEVOPS=${OSM_DEVOPS}"
echo "DOCKER_PROXY_URL=${DOCKER_PROXY_URL}"
echo "DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL}"
echo "DOCKER_REGISTRY_USER=${DOCKER_REGISTRY_USER}"
+echo "K3S_PUBLIC_IP=${K3S_PUBLIC_IP}"
echo "HOME=$HOME"
source $OSM_DEVOPS/common/logging