...

Text file src/k8s.io/kubernetes/test/e2e_node/environment/setup_host.sh

Documentation: k8s.io/kubernetes/test/e2e_node/environment

     1#!/usr/bin/env bash
     2
     3# Copyright 2016 The Kubernetes Authors.
     4#
     5# Licensed under the Apache License, Version 2.0 (the "License");
     6# you may not use this file except in compliance with the License.
     7# You may obtain a copy of the License at
     8#
     9#     http://www.apache.org/licenses/LICENSE-2.0
    10#
    11# Unless required by applicable law or agreed to in writing, software
    12# distributed under the License is distributed on an "AS IS" BASIS,
    13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14# See the License for the specific language governing permissions and
    15# limitations under the License.
    16
    17# Script used to configure node e2e test hosts from gce base images.
    18# DISCLAIMER: This script is not actively tested or maintained.  No guarantees that this will work
    19# on any host environment.  Contributions encouraged!  Send PRs to pwittrock (github.com).
    20#
    21# At some point has successfully configured the following distros:
    22# - ubuntu trusty
    23# - containervm (no-op)
    24# - rhel 7
    25# - centos 7
    26# - debian jessie
    27
    28# On a systemd environment, enable cpu and memory accounting for all processes by default.
    29if [ -d /etc/systemd ]; then
    30  cat <<EOF >kubernetes-accounting.conf
    31[Manager]
    32DefaultCPUAccounting=yes
    33DefaultMemoryAccounting=yes
    34EOF
    35  sudo mkdir -p /etc/systemd/system.conf.d/
    36  sudo cp kubernetes-accounting.conf /etc/systemd/system.conf.d
    37  sudo systemctl daemon-reload
    38fi
    39
    40# For coreos, disable updates
    41if sudo systemctl status update-engine &>/dev/null; then
    42  sudo systemctl mask update-engine locksmithd
    43fi
    44
    45# Fixup sudoers require tty
    46if ! sudo grep -q "# Defaults    requiretty" /etc/sudoers; then
    47  sudo sed -i 's/Defaults    requiretty/# Defaults    requiretty/' /etc/sudoers
    48fi
    49
    50# Install nsenter for ubuntu images
    51if cat /etc/*-release | grep "ID=ubuntu"; then
    52  if ! which nsenter > /dev/null; then
    53     echo "Do not find nsenter. Install it."
    54     NSENTER_BUILD_DIR=$(mktemp -d /tmp/nsenter-build-XXXXXX)
    55     cd "$NSENTER_BUILD_DIR" || exit 1
    56     curl https://www.kernel.org/pub/linux/utils/util-linux/v2.31/util-linux-2.31.tar.gz | tar -zxf-
    57     sudo apt-get update
    58     sudo apt-get --yes install make
    59     sudo apt-get --yes install gcc
    60     cd util-linux-2.31 || exit 1
    61     ./configure --without-ncurses
    62     make nsenter
    63     sudo cp nsenter /usr/local/bin
    64     rm -rf "$NSENTER_BUILD_DIR"
    65   fi
    66fi
    67
    68# Install docker
    69if ! hash containerd 2>/dev/null; then
    70  echo "Please install containerd, see the getting started guide here: https://github.com/containerd/containerd/blob/main/docs/getting-started.md"
    71  echo "For a docker CLI replacement, we suggest nerdctl: https://github.com/containerd/nerdctl#install"
    72fi
    73
    74# Allow jenkins access to docker
    75id jenkins || sudo useradd jenkins -m
    76sudo usermod -a -G docker jenkins
    77
    78# install lxc
    79if ! cat /etc/*-release | grep "ID=debian"; then
    80  hash apt-get 2>/dev/null
    81  if [ $? -ne 1 ]; then
    82    sudo apt-get install lxc -y
    83    lxc-checkconfig
    84    sudo sed -i 's/GRUB_CMDLINE_LINUX="\(.*\)"/GRUB_CMDLINE_LINUX="\1 cgroup_enable=memory"/' /etc/default/grub
    85    sudo update-grub
    86  fi
    87fi
    88
    89# delete init kubelet from containervm so that is doesn't startup
    90if [ -f /etc/init.d/kubelet ]; then
    91  sudo rm /etc/init.d/kubelet
    92fi

View as plain text