Learning Objectives
- Sequence 1. Create clone of tester1 VM
- Sequence 2. Setting up server, tester1 and tester2 for K8s
- Sequence 3. Set up K8s master node; server.
- Sequence 4. Set up K8s worker nodes; tester1 and tester2.
- Sequence 5. Deploy the Kubernetes Dashboard
- Sequence 6. Troubleshooting and Reset
Pre Requisite
- An Oracle Linux 7 VM to install K8s and the required software.
Configuration |
master Node |
worker Node1 |
worker Node2 |
hostname |
server.example.com | tester1.example.com | tester2.example.com |
OS |
CentOS 7/OL7 | CentOS 7/OL7 | CentOS 7/OL7 |
IP Address |
10.10.0.100 | 10.10.0.101 | 10.10.0.102 |
rpms required |
python3 | python3 | python3 |
- Internet access on all VMs.
- Remove all Docker Images and Containers.
Sequence 1. Create clone of tester1 VM
- Shutdown tester1 VM and Create a clone of the VM.
- Right click on the VM Name and select clone.
- Change the Details as given in the screen shot
- In the next screen keep default and click on clone button
- Once the clone is created, start tester2 and make following changes
- Change the hostname in
/etc/hostname
toexample.com
- Change the IP address in
/etc/sysconfig/network-scripts/ifcfg-enp0s8
to 10.10.0.102 - Reboot the VM,
tester2
.
Sequence 2. Install required packages on all three VMs
- Start all three VMs;
server
,tester1
andtester2
and login as root user. - Setup yum repositories for required packages on all three VMs. Configure the Kubernetes repositories by manually creating repo file. Separate text file is available to save time and avoid errors due to control characters.
Note – The gpgkey parameter is in one line with urls as given in screen shot.
- On
teste1
andtester2
, add these to Existing Repo file /etc/yum.repos.d/oracle-linux-ol7.repo
- Run the package update command on all three VMs; server, tester1 and tester2. Note that it may take 15 to 20 Min. If the YUM package installer is busy, don’t panic and interrupt it. This might be due to auto update running.
- Disable swap on all three VMs. K8s will not work with swap on. For permanently disable swap, comment out the last line in /etc/fstab.
- Enable Net packet filter with following command on
three VMs
.
- Verify your /etc/hosts file on all three VMs
- Shutdown all three VMs.
Sequence 3. Setting up master Node, server
- Configure the server with two CPUs. Open the settings of server VM while it is in “poweroff” mode and click on processor tab under System as given in following screen shot.
- Start the server VM and login as root.
- Set the firewall rules with following command.
- Run the following command to install kubeadm.
- Start and enable kubectl and docker service
- Run the following commands to pull images, initialize and setup kubernetes server.
- Execute the following commands to use the cluster as root user.
Take note
of the command to be executed on worker nodes,tester1
andCopy this command in a notepad file. You will need it later. The command is similar to:
- Deploy pod network to the cluster. Try to run below commands to get status of cluster and pods.
- Run the following command to deploy network.
- Now run the following commands to verify the status. Please note that it may take few minutes to change the status to “
ready
”
Sequence 4. Set up worker nodes; tester1 and tester2
- Configure firewall rules on both the nodes;
tester1
andtester2
.
- Install kubeadm and docker package on both nodes
- Start and enable docker service
- Now use the command similar to following, to join the K8s cluster.
- Output of above command would be something like
- Now verify Nodes status from
server
node using kubectl command
- To assign a role to tester1 and tester2, use the following command:
- Verify and Fix. Use the following command to check the status of all nodes on master
- Note that
tester1
andtester2
failed to acquire lease. This means, the pod didn't get the podCIDR. To fix it, from the master-node, first find out your funnel CIDR
- After 2-3 Minutes, use the following command to check the status of all nodes on master
- For a detailed status of nodes use
Sequence 5. Deploy the Kubernetes Dashboard
- Confirm the Namespace by running following command
- On the master node, deploy the Kubernetes Dashboard by running the following command
- Edit Dashboard Deployment and add
- --token-ttl=43200
- Verify that all pods are running with
- Start the Dashboard with
- Open another Tab in the terminal and create the required user (ServiceAccount) for the Kubernetes Dashboard with cluster-admin privileges. Text file is available for directl copy/paste to save time.
- Apply this yaml
- Get a Token to access the Kubernetes Dashboard.
- Open the Dashboard available at
kubectl proxy --help
for more options.- Copy the Token displayed and paste it in the login page by selecting
Token
to login as given below. - Dashboard will open as given below.
- If you lose the token, you can get with following commands.
- List secrets using
- Use kubectl describe to get the access token. Use secret name from above command to get the token.
Sequence 6. Troubleshooting and Reset
- Get a comprehensive report on your nodes with:
- Reset the Cluster on all three VMs with