Kubernets Aws PDF
Kubernets Aws PDF
co/devops
Step 2:
1. Run the following command:
nano /etc/hostname
2. Edit the name to “kmaster” for kmaster VM, and “knode” for knode VM
Step 3:
2. Enter the IP address of the kmaster VM and the knode VM both in this file. (This has to be
done in both the VMs). In front of the IP address of master write, “kmaster”. Similarly, in
front of the Node IP address write “knode”.
Step 4: Now we will ssh from one machine to another. Run the below command:
1. su - ubuntu
2. sudo service ufw stop
3. sudo service ssh start
4. eval `ssh-agent -s`
Note: Where ` in the above command refers to grave(`) and it is not a single quote(')
5. chmod 400 file_name.pem
6. ssh-add file_name.pem
Note: The file_name.pem is the file which you have transferred using Filezilla software in the
first step.
7. ssh ubuntu@<private_IP_of_the_other_instance>
Step 6: Next, we will install kubeadm, kubelet and kubectl. Run the following commands:
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 http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
Step 7:
1. Next, we will change the configuration file of Kubernetes. Run the following command:
nano /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
2. This will open a text editor, enter the following line after the last “Environment” Variable.
Environment="cgroup-driver=systemd/cgroup-driver=cgroupfs"
Note: These steps will only be executed on the master node (kmaster VM).
Step 1: We will now Initialize our Master VM. For that execute the following command
kubeadm init --apiserver-advertise-address=<ip-address-of-kmaster-vm>
1. You will get the below output. The commands marked as (1), execute them as a non-root user. This will
enable you to use kubectl from the CLI
2. The command marked as (2) should also be saved for future. This will be used to join nodes to your
cluster.
Step 2:
1. Like mentioned before, run the commands from the above output as a nonroot user.
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
Step 3:
1. You will notice from the previous command, all the pods are not running. For resolving this
we will install a pod network. To install the pod network, run the following command:
Step 4:
Next, we will install the dashboard. To install the Dashboard, run the following command:
kubectl create -f
https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/k
ubernetes-dashboard.yaml
Step 5: Your dashboard is now ready with it’s the pod in the running state.
Step 7:
1. By default dashboard will not be visible on the Master VM. Run the following command in the
command line:
curl 127.0.0.1:8001
4. Edit the file svc file for kubernetes dashboard using the below command and change the
type to NodePort.
kubectl edit svc kubernetes-dashboard –namespaces=kube-system
You will get the port on which kubernetes dashboard is running as shown in the below
screenshot.
6. To view the dashboard in the browser, navigate to the following address in the browser of
your Master VM and use mozilla firefox and any other browser other than chrome.
https://External_IP_of_Instance:Port_Number
Step 8: In this step, we will create the service account for the dashboard and get it’s
credentials. Run the following commands:
Note: Run all these commands in a new terminal, or your kubectl proxy command will stop.
1. This command will create service account for dashboard in the default namespace.
kubectl create serviceaccount dashboard -n default
2. This command will add the cluster binding rules to your dashboard account.
3. This command will give you the token required for your dashboard login.
4. Copy this token and paste it in Dashboard Login Page, by selecting token option.
Step 1: It is time to join your node to the cluster! This is probably the only step that you will
be doing on the node, after installing kubernetes on it. Run the join command that you
saved, when you ran kubeadm init command on the master.