Last active
February 10, 2019 15:19
-
-
Save r0mdau/20037dcd7c535aff03adc8ec04f8ad7b to your computer and use it in GitHub Desktop.
Cluster Kubernetes using virtualbox with Debian Stretch
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
##On the first VM | |
apt-get install -y apt-transport-https ca-certificates curl software-properties-common gnupg2 | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | |
apt-get update | |
apt-cache madison docker-ce | |
apt-get install docker-ce=18.06.0~ce~3-0~debian | |
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 https://apt.kubernetes.io/ kubernetes-xenial main | |
EOF | |
apt-get update | |
apt-get install -y kubelet kubeadm kubectl | |
apt-mark hold kubelet kubeadm kubectl | |
swapoff -a | |
vi /etc/fstab | |
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
sed -i "s/\$KUBELET_EXTRA_ARGS/\$KUBELET_EXTRA_ARGS\ --cgroup-driver=systemd/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
cat <<EOF >/etc/docker/daemon.json | |
{ | |
"exec-opts": ["native.cgroupdriver=systemd"] | |
} | |
EOF | |
systemctl daemon-reload | |
systemctl restart kubelet | |
systemctl restart docker | |
## CLONE VM | |
#ip and uuid have to be different | |
cat /sys/class/dmi/id/product_uuid | |
ip a | |
kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.1.20 | |
cp /etc/kubernetes/admin.conf $HOME/ | |
chown $(id -u):$(id -g) $HOME/admin.conf | |
export KUBECONFIG=$HOME/admin.conf | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.11.0/Documentation/kube-flannel.yml | |
##DONE | |
kubectl get nodes --all-namespaces |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment