How to install Kubernetes and How to add worker-nodes to Kubernetes-Master
Kubernetes
worker-nodes
Kubernetes-Master
2
Let's consider 1 Kubernetes-Cluster and 2 Worker-Nodes
t2.large
t2.micro
sudo su yum install docker -y systemctl enable docker && systemctl start docker
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 exclude=kube* EOF
cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system setenforce 0
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes systemctl enable kubelet && systemctl start kubelet
vi /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"] }
sudo systemctl daemon-reload sudo systemctl restart docker sudo systemctl restart kubelet
Only on the Master Node:
kubeadm init --ignore-preflight-errors all
export KUBECONFIG=/etc/kubernetes/admin.conf
export PATH
.bash_profile
ls -al vi .bash_profile
On All Worker nodes :
<kubeadm join command copied from master node> # kubeadm join 172.31.37.128:6443 --token sttk5b.vco0jw5bkkf1toa4 --discovery-token-ca-cert-hash sha256:d77b5f865c1e30b73ea4dd7ea458f79f56da94f9de9c8d7a26b226d94fd0c49e
On the Master Node :
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d 'n')"
kubectl get nodes
That's it :)
The easiest way to start Kubernetes on Amazon Linux AMI (or any other Linux AMI) is to use Microk8s (a lightweight distribution of Kubernetes).
The following steps will help you get started with Kubernetes on EC2 instance:
Install Microk8s on EC2 instance
sudo snap install microk8s --classic
Check the status while Kubernetes starts
microk8s status --wait-ready
Turn on the services you want
microk8s enable dashboard dns registry istio
Start using Kubernetes
microk8s kubectl get all --all-namespaces
Access the Kubernetes dashboard
microk8s dashboard-proxy
Start and stop Kubernetes to save battery microk8s start and microk8s stop
microk8s start
microk8s stop
This way you can install a local version of Kubernetes with Microk8s. You can also follow this tutorial for detailed instructions on the above steps.
Click here to cancel reply.
2
Answers
Let's consider 1 Kubernetes-Cluster and 2 Worker-Nodes
t2.large
t2.micro
Run the following Commands on both K8-Cluster and Worker-nodes
Only on the Master Node:
export KUBECONFIG=/etc/kubernetes/admin.conf
afterexport PATH
in.bash_profile
On All Worker nodes :
On the Master Node :
That's it :)
The easiest way to start Kubernetes on Amazon Linux AMI (or any other Linux AMI) is to use Microk8s (a lightweight distribution of Kubernetes).
The following steps will help you get started with Kubernetes on EC2 instance:
Install Microk8s on EC2 instance
sudo snap install microk8s --classic
Check the status while Kubernetes starts
microk8s status --wait-ready
Turn on the services you want
microk8s enable dashboard dns registry istio
Start using Kubernetes
microk8s kubectl get all --all-namespaces
Access the Kubernetes dashboard
microk8s dashboard-proxy
Start and stop Kubernetes to save battery
microk8s start
andmicrok8s stop
This way you can install a local version of Kubernetes with Microk8s. You can also follow this tutorial for detailed instructions on the above steps.