[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
-# Retrieves and saves the credentials
-function save_credentials() {
+# Initializes kubeconfig file
+function save_kubeconfig() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
KUBEDIR="${HOME}/.kube"
KUBEFILE="$KUBEDIR/config"
mkdir -p "${KUBEDIR}"
- sudo cp /etc/rancher/k3s/k3s.yaml "${KUBEFILE}"
+ K3S_KUBECONFIG="/etc/rancher/k3s/k3s.yaml"
+ sudo cp "${K3S_KUBECONFIG}" "${KUBEFILE}"
sudo chown $(id -u):$(id -g) "${KUBEFILE}"
+ sed -i "s#server: https://127.0.0.1#server: https://${DEFAULT_IP}#g" "${KUBEFILE}"
chmod 700 "${KUBEFILE}"
echo
echo "Credentials saved at ${KUBEFILE}"
}
# main
-while getopts ":D:-: " o; do
+DEFAULT_IP="127.0.0.1"
+OSM_DEVOPS="/usr/share/osm-devops"
+DEBUG_INSTALL=""
+
+while getopts ":D:i:-: " o; do
case "${o}" in
+ i)
+ DEFAULT_IP="${OPTARG}"
+ ;;
D)
OSM_DEVOPS="${OPTARG}"
;;
source $OSM_DEVOPS/common/logging
source $OSM_DEVOPS/common/track
-echo "DEBUG_INSTALL=$DEBUG_INSTALL"
-echo "OSM_DEVOPS=$OSM_DEVOPS"
+echo "DEBUG_INSTALL=${DEBUG_INSTALL}"
+echo "DEFAULT_IP=${DEFAULT_IP}"
+echo "OSM_DEVOPS=${OSM_DEVOPS}"
echo "HOME=$HOME"
install_k3s
# update_service_nodeport_range
# check_for_readiness
# track k8scluster k3s_update_nodeport_range_ok
-save_credentials
+save_kubeconfig
track k8scluster k3s_creds_ok