Skip to content

Add root checks and given an appropriate message if not running as root and improve swap checks #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions setup-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# script that runs
# https://kubernetes.io/docs/setup/production-environment/container-runtime

if [ $(id -u) != 0 ]; then
echo "Please run as root or use sudo."
exit 1
fi

yum install -y vim yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Expand Down
13 changes: 10 additions & 3 deletions setup-kubetools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# kubeadm installation instructions as on
# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

if [ $(id -u) != 0 ]; then
echo "Please run as root or use sudo."
exit 1
fi

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
Expand All @@ -16,9 +21,11 @@ EOF
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

# disable swap (assuming that the name is /dev/centos/swap
sed -i 's/^\/dev\/mapper\/centos-swap/#\/dev\/mapper\/centos-swap/' /etc/fstab
swapoff /dev/mapper/centos-swap
# disable swap (assuming that the name is /dev/centos*/swap)
for device in $(sed -e 's/#.*//' /etc/fstab | awk '$2 == "swap" { print $1 }' | grep ^/dev/); do
swapoff $device
sed -i -e "s,$device,#$device," /etc/fstab
done

yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

Expand Down