$OSM_DEVOPS/installers/install_cluster_addons.sh ${K8SCLUSTER_ADDONS_INSTALL_OPTS} || \
FATAL_TRACK k8scluster "install_cluster_addons.sh failed for kubeadm cluster"
elif [ "${K8S_CLUSTER_ENGINE}" == "k3s" ]; then
- K3S_INSTALL_OPTS="-D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
+ K3S_INSTALL_OPTS="-i ${OSM_DEFAULT_IP} -D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
# The K3s installation script will automatically take the HTTP_PROXY, HTTPS_PROXY and NO_PROXY,
# as well as the CONTAINERD_HTTP_PROXY, CONTAINERD_HTTPS_PROXY and CONTAINERD_NO_PROXY variables
# from the shell, if they are present, and write them to the environment file of k3s systemd service,
[ -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
}
# Initializes kubeconfig file
-function kube_config_dir() {
+function save_kubeconfig() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
K8S_MANIFEST_DIR="/etc/kubernetes/manifests"
[ ! -d $K8S_MANIFEST_DIR ] && FATAL_TRACK k8scluster "Kubernetes folder $K8S_MANIFEST_DIR was not found"
- mkdir -p $HOME/.kube
- sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
+ KUBEDIR="${HOME}/.kube"
+ KUBEFILE="$KUBEDIR/config"
+ mkdir -p "${KUBEDIR}"
+ KUBEADM_KUBECONFIG="/etc/kubernetes/admin.conf"
+ sudo cp "${KUBEADM_KUBECONFIG}" "${KUBEFILE}"
+ sudo chown $(id -u):$(id -g) "${KUBEFILE}"
+ echo
+ echo "Credentials saved at ${KUBEFILE}"
+ echo
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
# main
-while getopts ":D:d:i:-: " o; do
+OSM_CLUSTER_WORK_DIR="/etc/osm"
+OSM_DEVOPS="/usr/share/osm-devops"
+DEBUG_INSTALL=""
+
+while getopts ":D:d:-: " o; do
case "${o}" in
- i)
- DEFAULT_IP="${OPTARG}"
- ;;
d)
OSM_CLUSTER_WORK_DIR="${OPTARG}"
;;
check_and_track_kube_install
init_kubeadm $OSM_CLUSTER_WORK_DIR/kubeadm-config.yaml
-kube_config_dir
+save_kubeconfig
check_and_track_init_k8s
deploy_cni_provider