blob: d0f2c4bad46b08ea46b8e7680925019da9d65536 [file] [log] [blame]
garciadeblascf603f52025-06-04 11:57:28 +02001#!/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
16set -e -o pipefail
17
18HERE=$(dirname "$(readlink --canonicalize "$BASH_SOURCE")")
19source "${HERE}/../library/functions.sh"
20source "${HERE}/../library/trap.sh"
21source "${HERE}/../library/logging"
22source "${HERE}/../library/track"
23
24source "${HERE}/00-default-install-options.rc"
25[ ! -f "${OSM_HOME_DIR}/user-install-options.rc" ] || source "${OSM_HOME_DIR}/user-install-options.rc"
26
27export K8SCLUSTER_CONFIG_FOLDER=${K8SCLUSTER_CONFIG_FOLDER:-"/etc/osm"}
28export DEFAULT_IP=${OSM_DEFAULT_IP:-"127.0.0.1"}
29
30echo "K8S_CLUSTER_ENGINE=$K8S_CLUSTER_ENGINE"
31if [ "${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"
38elif [ "${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"
49fi
50echo "Updating fsnotify settings of the system kernel"
51sudo bash -c "sysctl -w fs.inotify.max_user_watches=699050 > /etc/sysctl.d/99-custom-osm-sysctl.conf"
52sudo bash -c "sysctl -w fs.inotify.max_user_instances=10922 >> /etc/sysctl.d/99-custom-osm-sysctl.conf"
53sudo bash -c "sysctl -w fs.inotify.max_queued_events=1398101 >> /etc/sysctl.d/99-custom-osm-sysctl.conf"
54
55echo "K8s cluster installed"