Created
October 25, 2018 14:28
-
-
Save germainlefebvre4/c28bd456112fe34bc64cdd27b2b0a4b6 to your computer and use it in GitHub Desktop.
This file contains 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
# Install Kubernetes Cluster | |
# Targets: Master + Workers | |
# Prepare system | |
# Disable SELinuw | |
setenforce 0 | |
sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config | |
# Disable Swap | |
swapoff `cat /etc/fstab | grep swap | awk '{print $1}'` | |
sed -i 's/^\([^#].*swap.*\)$/#\1/g' /etc/fstab | |
mount -a | |
# Enable IPv4 Forwarding | |
sed -i 's/^\(net.ipv4.ip_forward\).*/\1 = 1/g' /etc/sysctl.conf | |
sysctl -p | |
cat <<EOF > /etc/sysctl.d/k8s.conf | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.bridge.bridge-nf-call-iptables = 1 | |
EOF | |
sysctl --system | |
# Install Docker CE 17.03 | |
yum install -y yum-utils | |
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo | |
yum install -y --setopt=obsoletes=0 \ | |
docker-ce-17.03.2.ce-1.el7.centos \ | |
docker-ce-selinux-17.03.2.ce-1.el7.centos | |
systemctl enable docker | |
systemctl start docker | |
systemctl status docker | |
# Install Kubernetes 1.9.7 | |
cat <<EOF > /etc/yum.repos.d/kubernetes.repo | |
[kubernetes] | |
name=Kubernetes | |
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 | |
enabled=1 | |
gpgcheck=1 | |
repo_gpgcheck=0 | |
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | |
EOF | |
yum install -y kubelet-1.9.7 kubeadm-1.9.7 kubectl-1.9.7 | |
# Configuration for K8s 1.9.7 | |
sed -i 's/^\(Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=\).*/\1cgroupfs"/g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf | |
systemctl daemon-reload | |
systemctl enable kubelet | |
systemctl restart kubelet | |
systemctl status kubelet | |
# Targets: Master | |
# Create K8s Cluster with network 10.244.0.0/16 : internal docker network scope | |
kubeadm init --pod-network-cidr 10.244.0.0/16 | |
mkdir -p $HOME/.kube | |
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
chown $(id -u):$(id -g) $HOME/.kube/config | |
# Install Network : Calico | |
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/etcd.yaml | |
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/rbac.yaml | |
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/calico.yaml | |
# Allow deploying pods on Master Node. Beware! Not in Production! | |
kubectl taint nodes --all node-role.kubernetes.io/master- | |
# Print Jion CMD to run on Workers (see cmd below) | |
kubeadm token create --print-join-command | |
# Targets: Workers | |
# Join K8s Nodes to Cluster : command given through 'kubeadm init' | |
kubeadm join --token b26bb6.e040d60287e35dc7 192.168.248.166:6443 --discovery-token-ca-cert-hash sha256:0a7dfc557cc247b630ec20e58e3f367f53c27b1411d491542a9395ba2dc48e3a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment