This blog post is intended to walk you through a guide on how to get started with Kuberenetes by creating a single cluster with one or more nodes on a single physical machine.
Running Kubernetes with Vagrant is a better way to be familiar with Kubernetes. Kubernetes getting started guide provides a way to install Kubernetes with Fedora.
As an alternative, this post will guide you through a Kubernetes vagrant setup with core-os. Initially, you have to install vagrant and virtual box to proceed with.
As the first step, clone this Kubernetes core-os vagrant setup.
$git clone https://github.com/pires/kubernetes-vagrant-coreos-cluster.git
This vagrant setup sets some default values to the properties like number of nodes, memory of master, memory of nodes, enabling of Kubernetes UI and etc. If you need to set custom values for these properties, you can set them by setting the environment variables as below;
$export NODES=1
$export USE_KUBE_UI=true
Now, that all are ready to run the Kuberenetes cluster. The following command will create and configure the guest machines according to the vagrant file specification. In order to run this command you need to go inside the cloned folder.
$vagrant up
$kubectl cluster-info
In trying to run kubectl cluster info command, there's a possibility in getting the following error due to the incorrect master IP.
Thus to avoid that error we need to set the master IP as an environment variable. As per the above vagrant setup, the IP of the Kubernetes cluster is as follows;
$export KUBERNETES_MASTER=172.17.8.101:8080
With the proper installation of Kuberenetes, it would provide cluster information to the kubectl cluster info command as follows;
What is kubectl?
Kubectl is the command line interface that helps the user to run command against the Kubernetes cluster.Creating a pod
$kubectl create -f FILE
A pod can be created with create command and the properties of the pod definition can be defined via a YAML or JSON formatted configuration file. The direct use of this command to create a pod does not create a replication controller which watches over the failures.
Viewing a pod
$kubectl get pod NAME
$kubectl describe pod NAME
$kubectl get pods
Deleting a pod
$kubectl delete pod NAME
Creating a replication controller
$kubectl create -f FILE
Viewing a replication controller
$kubectl get rc
$kubectl describe rc NAME
Deleting a replication controller
$kubectl delete rc NAME
Deploying a Sample Tomcat Application on Kubernetes
In order to deploy a sample tomcat application on Kubernetes, we can use the provided sample examples in Kubernetes code base.
What you have to do is clone the Kubernetes code base, as follows;
$git clone https://github.com/kubernetes/kubernetes.git
$kubectl create -f <kubernetes home>/examples/javaweb-tomcat-sidecar/javaweb-2.yaml
We can view the status of the pod by running
$kubectl get pods
Once the pod is in the running status, we can access the sample deployed application through
http://172.17.8.102:8001/sample/index.html
as this port is defined in the configuration YAML file.
References : https://cloud.google.com/container-engine/docs/
Nice posting!!!good information
ReplyDeleteDocker and Kubernetes Training
Docker and Kubernetes Online Training
Docker and Kubernetes Training in Hyderabad
Kubernetes Online Training
Docker Online Training
Docker Training in Hyderabad
Docker Training
Kubernetes Training in Hyderabad