| garciadeblas | cf603f5 | 2025-06-04 11:57:28 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| 15 | |
| 16 | set -e -o pipefail |
| 17 | |
| 18 | HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")") |
| 19 | source "${HERE}/../library/functions.sh" |
| 20 | source "${HERE}/../library/trap.sh" |
| 21 | source "${HERE}/../library/logging" |
| 22 | source "${HERE}/../library/track" |
| 23 | |
| 24 | source "${HERE}/00-default-install-options.rc" |
| 25 | [ ! -f "${OSM_HOME_DIR}/user-install-options.rc" ] || source "${OSM_HOME_DIR}/user-install-options.rc" |
| 26 | |
| 27 | export K8SCLUSTER_CONFIG_FOLDER=${K8SCLUSTER_CONFIG_FOLDER:-"/etc/osm"} |
| 28 | export DEFAULT_IP=${OSM_DEFAULT_IP:-"127.0.0.1"} |
| 29 | |
| 30 | echo "K8S_CLUSTER_ENGINE=$K8S_CLUSTER_ENGINE" |
| 31 | if [ "${K8S_CLUSTER_ENGINE}" == "kubeadm" ]; then |
| 32 | KUBEADM_INSTALL_OPTS="--debug" |
| 33 | ${HERE}/cluster/kubeadm/install_kubeadm_cluster.sh ${KUBEADM_INSTALL_OPTS} || \ |
| 34 | FATAL_TRACK k8scluster "install_kubeadm_cluster.sh failed" |
| 35 | K8SCLUSTER_ADDONS_INSTALL_OPTS="--all" |
| 36 | ${HERE}/cluster/addons/install_cluster_addons.sh ${K8SCLUSTER_ADDONS_INSTALL_OPTS} || \ |
| 37 | FATAL_TRACK k8scluster "install_cluster_addons.sh failed for kubeadm cluster" |
| 38 | elif [ "${K8S_CLUSTER_ENGINE}" == "k3s" ]; then |
| 39 | export K3S_PUBLIC_IP= |
| 40 | [ "${OSM_K8S_EXTERNAL_IP}" != "${OSM_DEFAULT_IP}" ] && K3S_PUBLIC_IP=${OSM_K8S_EXTERNAL_IP} |
| 41 | # The K3s installation script will automatically take the HTTP_PROXY, HTTPS_PROXY and NO_PROXY, |
| 42 | # as well as the CONTAINERD_HTTP_PROXY, CONTAINERD_HTTPS_PROXY and CONTAINERD_NO_PROXY variables |
| 43 | # from the shell, if they are present, and write them to the environment file of k3s systemd service, |
| 44 | ${HERE}/cluster/k3s/install_k3s_cluster.sh || \ |
| 45 | FATAL_TRACK k8scluster "install_k3s_cluster.sh failed" |
| 46 | K8SCLUSTER_ADDONS_INSTALL_OPTS="--certmgr --nginx" |
| 47 | ${HERE}/cluster/addons/install_cluster_addons.sh ${K8SCLUSTER_ADDONS_INSTALL_OPTS} || \ |
| 48 | FATAL_TRACK k8scluster "install_cluster_addons.sh failed for k3s cluster" |
| 49 | fi |
| 50 | echo "Updating fsnotify settings of the system kernel" |
| 51 | sudo bash -c "sysctl -w fs.inotify.max_user_watches=699050 > /etc/sysctl.d/99-custom-osm-sysctl.conf" |
| 52 | sudo bash -c "sysctl -w fs.inotify.max_user_instances=10922 >> /etc/sysctl.d/99-custom-osm-sysctl.conf" |
| 53 | sudo bash -c "sysctl -w fs.inotify.max_queued_events=1398101 >> /etc/sysctl.d/99-custom-osm-sysctl.conf" |
| 54 | |
| 55 | echo "K8s cluster installed" |