Skip to content

Commit

Permalink
fix k8s setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
mhewedy committed May 25, 2020
1 parent 60e4020 commit b458c95
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Set hostname and disable swap
# HW requirements: 2 CPUS 2 RAM
# OS: Ubuntu focal

# Set hostname and disable swap
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
sudo swapoff -a && sudo sed -i '/ swap / s/^/#/' /etc/fstab

## Fix IP Addr

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y

sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.dhcp4 false
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.gateway4 192.168.100.1
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4

sudo add-apt-repository ppa:rmescandon/yq -y
sudo apt-get update -y
sudo apt-get install yq -y
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.dhcp4 false
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.gateway4 "$(hostname -I | cut -d "." -f 1-3).1"
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4
sudo netplan apply

############# start k8s installation
Expand All @@ -29,18 +28,14 @@ cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

###

sudo apt-get update -y
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl

###

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

###
####### configure kubeadm

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 &> ~/kubeadm.log
mkdir -p $HOME/.kube
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Set hostname and disable swap
# HW requirements: 2 CPUS 2 RAM
# OS: Ubuntu focal

# Set hostname and disable swap
sudo hostnamectl set-hostname "$(hostname -I | awk '{print $1}')"
sudo swapoff -a && sudo sed -i '/ swap / s/^/#/' /etc/fstab

## Fix IP Addr

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys CC86BB64
sudo add-apt-repository ppa:rmescandon/yq
sudo apt update
sudo apt install yq -y

sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.dhcp4 false
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.gateway4 192.168.100.1
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
sudo yq w -i /etc/netplan/50-cloud-init.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4

sudo add-apt-repository ppa:rmescandon/yq -y
sudo apt-get update -y
sudo apt-get install yq -y
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.dhcp4 false
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.addresses[+] "$(hostname -I | awk '{print $1}')/24"
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.gateway4 "$(hostname -I | cut -d "." -f 1-3).1"
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.8.8
sudo yq w -i /etc/netplan/00-installer-config.yaml network.ethernets.enp0s3.nameservers.addresses[+] 8.8.4.4
sudo netplan apply

############# start k8s installation
Expand All @@ -29,14 +28,9 @@ cat << EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF

###

sudo apt-get update -y
sudo apt-get install -y docker-ce=18.06.1~ce~3-0~ubuntu kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00
sudo apt-mark hold docker-ce kubelet kubeadm kubectl

###

echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

0 comments on commit b458c95

Please sign in to comment.