Last active
March 3, 2018 12:07
-
-
Save coder36/f12606e2102fed47e2ecbcc831d8dcde to your computer and use it in GitHub Desktop.
Set up a kubernates cluster on Virtualbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting up a kubernetes cluster on Virtual Box | |
## Server/Node setup | |
### Install ubuntu 16.04 | |
Login as root using | |
``` | |
sudo su - | |
``` | |
### Enable root login | |
Edit /etc/ssh/sshd_config setting | |
``` | |
PermitRootLogin yes | |
``` | |
### Disable Swap: | |
kubeadm requires that swap is disabled. Remove any swap entires from /etc/fstab and run | |
``` | |
swap off -a | |
``` | |
### Set up static ip by editing /etc/network/interfaces | |
``` | |
# The primary network interface | |
auto enp0s3 | |
iface enp0s3 inet static | |
address 192.168.0.141 | |
netmask 255.255.255.0 | |
gateway 192.168.0.1 | |
dns-nameservers 8.8.8.8 8.8.4.4 | |
``` | |
### Install kubernetes dependencies | |
Create /root/install | |
``` | |
apt-get update | |
apt-get install -y docker.io | |
apt-get update && apt-get install -y apt-transport-https | |
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - | |
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list | |
deb http://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
apt-get update | |
apt-get install -y kubelet kubeadm kubectl | |
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /root/.bashrc | |
``` | |
And run | |
``` | |
chmod +x /root/install | |
/root/install | |
``` | |
### Setup hostname (if needed) | |
Edit /etc/hostname | |
Edit /etc/hosts | |
Restart | |
``` | |
shutdown -r | |
``` | |
## Kubernetes cluster setup | |
### Master: | |
``` | |
kubeadm init --pod-network-cidr=10.244.0.0/16 | |
sysctl net.bridge.bridge-nf-call-iptables=1 | |
>kubeadm join --token 1ca6e9.d7ac2d9997bf060c 192.168.0.141:6443 --discovery-token-ca-cert-hash sha256:1eeb98e1f6d92948465450ab075a1472a99f260d093666930ace6e5b855b19cf | |
export KUBECONFIG=/etc/kubernetes/admin.conf | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml | |
==== | |
check its up, and after adding each node | |
kubectl get nodes | |
kubectl get pods --all-namespaces | |
### Node | |
``` | |
kubeadm join --token 1ca6e9.d7ac2d9997bf060c 192.168.0.141:6443 --discovery-token-ca-cert-hash sha256:1eeb98e1f6d92948465450ab075a1472a99f260d093666930ace6e5b855b19cf | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment