Created
August 19, 2020 11:29
-
-
Save kiranchavala/7e4cda9bff5e141bd7601c870191e051 to your computer and use it in GitHub Desktop.
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
********************************************************************************************* | |
# 1. Create 4 VMs - master(1) and worker(3) nodes | |
Node Reqs (varies depending on usage) | |
------------------------------------- | |
Master: 2 vCPUs - 6GB Ram | |
Worker: 1 vCPUs - 3GB RAM | |
OS: CentOS/RHEL 7 | |
*********************************************************************************************************************************************** | |
# 2. PRE-Reqs: Disable - Firewall | Swap | SELinux | |
# Note: Execute on all nodes (master & worker) | |
# Disable Firewall | |
systemctl stop firewalld | |
systemctl disable firewalld | |
# OR - ensure ports [6443 10250] are open | |
# Disable Swap | |
swapoff -a | |
sed -i.bak -r 's/(.+ swap .+)/#\1/' /etc/fstab | |
# Disable SELinux | |
setenforce 0 | |
sed -i 's/enforcing/disabled/g' /etc/selinux/config | |
*********************************************************************************************************************************************** | |
3. Download & Install - Docker | Kubelet | Kubeadm | Kubectl | |
# Note: Execute on all nodes (master & worker) | |
# Kubernetes Repository | |
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=1 | |
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | |
exclude=kube* | |
EOF | |
# Installing Docker | Kubelet | Kubeadm | Kubectl | |
yum update -y | |
yum install -y docker kubeadm kubelet kubectl --disableexcludes=kubernetes | |
# Start and enable docker and kubectl | |
systemctl enable docker && systemctl start docker | |
systemctl enable kubelet && systemctl start kubelet | |
# For CentOS and RHEL | |
cat <<EOF > /etc/sysctl.d/k8s.conf | |
net.bridge.bridge-nf-call-ip6tables = 1 | |
net.bridge.bridge-nf-call-iptables = 1 | |
EOF | |
sysctl net.bridge.bridge-nf-call-iptables=1 | |
sysctl net.ipv4.ip_forward=1 | |
sysctl --system | |
echo "1" > /proc/sys/net/ipv4/ip_forward | |
# Restart the systemd daemon and the kubelet service with the commands: | |
systemctl daemon-reload | |
systemctl restart kubelet | |
Reboot the mastr and worker nodes | |
iptables --policy FORWARD ACCEPT | |
*********************************************************************************************************************************************** | |
4. Configure Kubernetes "master" node | |
# Initializing master node | |
kubeadm init --pod-network-cidr=10.240.0.0/16 | |
--------------------------------------------------------------------- | |
# If you want to run kubectl as "regular" user. Then, execute below. | |
mkdir -p $HOME/.kube | |
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | |
sudo chown $(id -u):$(id -g) $HOME/.kube/config | |
# Note down Join command in below step. | |
-------------------------------------------------------------------- | |
# Installing Flannel network-plug-in for cluster network | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml | |
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | |
kubectl get pods --all-namespaces | |
************************************************************************************************************************************************ | |
5. Join "worker" nodes to the cluster | |
# Get exact join command from previous kubeadm init command output. | |
kubeadm join 10.142.0.40:6443 --token 9xii6e.avuik4ciqrl1yacw --discovery-token-ca-cert-hash sha256:f7902e7a474d33b54f4f2fbdb4fd5e74163817e683333187736b65189ff36b7a | |
************************************************************************************************************************************************ | |
kubeadm token create --print-join-command | |
6. Testing | |
# Display nodes status | |
kubectl get no | |
# Deploying sample application | |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/controllers/nginx-deployment.yaml | |
# Displaying Pod status | |
kubectl get po -o wide | |
************************************************************************************************************************************************ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment