Skip to content
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (38 sloc) 1.8 KB
- name: Install Runtime Docker CE
include_role:
name: install-docker-ce
- name: Create a single k8s master cluster by kubeadm
shell:
cmd: |
set -x
set -e
# Installing kubeadm, kubelet and kubectl.
apt-get update && apt-get install -y apt-transport-https curl
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
if [[ "{{ kubernetes_version }}" == "latest" ]]; then
apt-get install -y kubelet kubeadm kubectl
else
install_version=$(apt-cache madison kubelet |grep "{{ kubernetes_version }}" | head -n 1 | awk '{print $3}')
apt-get install -y kubelet=$install_version kubeadm=$install_version kubectl=$install_version
fi
kubelet --version
apt-mark hold kubelet kubeadm kubectl
# Creating a single master cluster with kubeadm:
## to avoid coredns crashloopbackoff, we set nameserver to 8.8.8.8 instead of 127.0.0.1
cat /etc/resolv.conf
sed -i 's/nameserver 127.0.0.1/nameserver 8.8.8.8/' /etc/resolv.conf
cat /etc/resolv.conf
## Initializing master
sysctl net.bridge.bridge-nf-call-iptables=1
kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version="{{ kubernetes_version }}"
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
## Installing a pod network add-on.
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.yml
# make sure we can schedule pods on the master.
kubectl taint nodes --all node-role.kubernetes.io/master-
executable: /bin/bash
You can’t perform that action at this time.