Cluster in Kubernetes



Cluster creation using Minikube:

             It’s a opensource and will handle highly available cluster of systems that are ready to work together as connected. It will allow you to deploy containerized applications on individual systems. Containerized applications are flexible and available comparing to the old deployment methods.
               Kubernetes will automates scheduling and distributing applications across the cluster in the way of more efficient.

This cluster type consists of below resources:

1. Master – Cluster coordinator
2. Nodes – Where the applications run

Master:

Master will coordinate such as scheduling, managing, Scaling, Updating and roll out applications.
Kubernetes cluster will handle of production traffic with three nodes.

Nodes:

           This might be physical/ VM nodes where the application are running. This has kubelet agent which will help to manage and communicate with Kubernetes master server and also nodes have Docker and rkt which will help to handling the containers.

            On deployment of applications, master will schedule and start the application containers on nodes. Nodes will communicate with masters using Kubernetes API. Users also will user Kubernetes API to interact with cluster.

Kubernetes cluster can be deployed on your local or VM machines. We can use Minikube which will create a VM and implement one node cluster on your local machine. Minikube CLI will provide basic operations on your cluster like start, stop, status and delete.

To install Minikube on Linux box, we must need Virtual box/ KVM.

Minikube Installation

# curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.17.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

If you are totally new to Kubernetes, you also need to download kubectl client, This is will communicate with Kubernetes API to manage containers.

Kubectl Installation:

#curl -Lo kubectl http://storage.googleapis.com/kubernetesrelease/release/v1.3.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/

Note: Here I’m using Kubernetes interactive tutorials. So, required package has been already installed.

Now you were ready to use Minikube/ Kubernetes. First we must enter below command to start VM and Kubernetes cluster

#minikube start
Starting local Kubernetes cluster…
Kubectl is now configured to use the cluster.


To check the status enter below command:

#Minikube status
Running

Use the below command to check kubectl is configured or not to comminucate Minikube VM.

 # kubectl get nodes
NAME      STATUS    AGE
host01    Ready     33s


Command to check Kubectl which  command line interface version

  #kubectl version
Client Version: version.Info{Major:”1″, Minor:”5″, GitVersion:”v1.5.2″, GitCommit:”08
e099554f3c31f6e6f07b448ab3ed78d0520507″, GitTreeState:”clean”, BuildDate:”2017-01-12T
04:57:25Z”, GoVersion:”go1.7.4″, Compiler:”gc”, Platform:”linux/amd64″}
Server Version: version.Info{Major:”1″, Minor:”5″, GitVersion:”v1.5.2″, GitCommit:”08
e099554f3c31f6e6f07b448ab3ed78d0520507″, GitTreeState:”clean”, BuildDate:”1970-01-01T
00:00:00Z”, GoVersion:”go1.7.1″, Compiler:”gc”, Platform:”linux/amd64″}


Use the below command to view the cluster details:

#kubectl cluster-info
Kubernetes master is running at http://host01:8080
heapster is running at http://host01:8080/api/v1/proxy/namespaces/kube-system/service
s/heapster
kubernetes-dashboard is running at http://host01:8080/api/v1/proxy/namespaces/kube-sy
stem/services/kubernetes-dashboard
monitoring-grafana is running at http://host01:8080/api/v1/proxy/namespaces/kube-syst
em/services/monitoring-grafana
monitoring-influxdb is running at http://host01:8080/api/v1/proxy/namespaces/kube-sys
tem/services/monitoring-influxdb

To further debug and diagnose cluster problems, use ‘kubectl cluster-info dump’.

To view the nodes in the cluster:

#kubectl get nodes
NAME      STATUS    AGE
host01    Ready     2m



           

Introduction to kubernetes

                 Using this will automate the deployment, scaling, management of containerized applications and etc.
             
                It will create containers which will help to easy management and discovering applications as logical units.

                As its a cloud system, it can be accessible from anywhere. It will support on-premise, hybrid and public cloud infrastructure. It will reduce ops count for operations.

Features:

Automatic binpacking
Self-healing
Horizontal scaling
Service discovery and load balancing
Automated rollouts and rollbacks
Secret and configuration management
Storage orchestration
Batch execution

         We will help you to know the basic of kubernetes cluster system with background, concepts of kubernetes, Deploy a containerized application, Scale the deployment, Update and debug the applications.

Modules of Kubernetes:

1. Create a kubernetes cluster
2. Deploy a application
3. Explore your application
4. Explore your application publicly
5. Scale up your application
6. Update your application

Configuring syslogd in linux

Will see Configuring syslogd in Linux in this post

Follow the below steps on server:

Required services for syslogd

1. portmap
2 xinetd
3. syslog

Run the below command to keep on running above mentioned service after server reboot

#chkconfig portmap on
#chkconfig xinetd on
#chkconfig syslog on

Start portmap and xinetd services

#service portmap start
#service xinetd start

Check the service status

#service portmap status
#service xinetd status

Now edit “/etc/sysconfig/syslog” file using vi editor

#vi /etc/sysconfig/syslog

find for SYSLOGD_OPTIONS=”-m 0″

and add -r option to accept the logs from system

SYSLOGD_OPTIONS=”-r -m 0″

save and quit from the file :wq

-x disable DNS lookups on messages with -r option
-m 0 disabled MARK messages
-r enables logging

Once edited the file restart the syslog service

#service syslog retsrat

Follow the steps on client

Edit /etc/syslog.conf file and add a entry at end of file for server as shown below.

:Lets assume server ip as 192.168.1.10

#vi /etc/syslog.conf
user.* @192.168.1.10

Save and quit from the file :wq

now restart the syslog service on client

#service syslog restart

Now restart the client and check log entry in server. it will generate logs in server.

Checking logs on server

#less /var/log/messages

end of this log file you can see the recent logs.

Log analysis in Linux

We have lots of default and third-party tool/commands for log analysis in Linux.
Will see some default commands which is used in Linux for log analysis.
 
Awk
Cut
Grep
Tail
Syslogd
 
Usage of  awk command
 
   We can find and replace text and will sort the output of this command.  It will search for a given pattern by us and if any text matches for that pattern then it will do the further action which given in the command.
 
For example, if we need to the second item from an output of the command will use in below format
 
#ls -l | ask '{print $2}'

12
5
13
 
Likewise will use ask command Wherever we need a specific value from a log file/output of command or text file.