Getting started with Kubernetes

by Ismail.EL
0 comment

1- Introduction?

Learn the basics of using the open source container management system with this easy tutorial.

One of today’s most promising emerging technologies is paring containers with cluster management software like Docker Swarm, Apache Mesos, and therefore the popular Kubernetes. Kubernetes allows you to make a transportable and scalable application deployment which will be scheduled, managed, and maintained easily. As an open source project, Kubernetes is continually being updated and improved, and it leads the way among container cluster management software.

Kubernetes uses various architectural components to describe the deployments it manages.

  • Pods are a group of one or more containers that share network and storage. The containers in a pod are considered “tightly coupled,” and they are managed and deployed as a single unit. If an application were deployed in a more traditional model, the contents of the pod would always be deployed together on the same machine.
  • Nodes represents a worker machine in a Kubernetes cluster. The worker machine can be either physical or (more likely) virtual. A node contains all the required services to host a pod.
  • A cluster always requires a master node, where the controlling services (known as the master components) are installed. These services can be distributed on a single machine or across multiple machines for redundancy. They control communications, workload, and scheduling.
  • Deployments are a way to declaratively set a state for your pods or ReplicaSets (groups of pods to be deployed together). Deployments use a “desired state” format to describe how the deployment should look, and Kubernetes handles the actual deployment tasks. Deployments can be updated, rolled back, scaled, and paused at will.

The following tutorial will explain the basics of creating a cluster, deploying an app, and creating a proxy, then send you on your way to learning even more about Kubernetes.

2. Create a cluster

Begin by using the Kubernetes-provided tutorial to create a cluster and deploy an app. This cluster will consist of a master and one or more nodes. In the first scenario, you’ll create a cluster using a utility called “Minkube,” which creates and runs a cluster on a local machine. Minikube is great for testing and development. You will also use the kubectl command, which is installed as part of the Kubernetes API.

In the interactive terminal, Start the cluster, by running the minikube start command:

View the cluster information with the command:

To view the nodes in the cluster, run the kubectl get nodes command::

The screenshot above shows the output from these commands. Note the only available node is host01, which is operating as the master (as seen in the cluster-info output).

3. Deploy an app

Let’s deploy our first app on Kubernetes with the kubectl create deployment command. We need to provide the deployment name and app image location (include the full repository url for images hosted outside Docker hub).

Great! You just deployed your first application by creating a deployment. This performed a few things for you:

  • searched for a suitable node where an instance of the application could be run (we have only 1 available node)
  • scheduled the application to run on that Node
  • configured the cluster to reschedule the instance on a new Node when needed

To list your deployments use the get deployments command:

We see that there is 1 deployment running a single instance of your app. The instance is running inside a Docker container on your node.

4. Create a proxy

In the third part of the tutorial, you will create a proxy into your deployed app. A pod runs on an isolated private network that cannot be accessed from outside. The kubectl command uses an API to communicate with the application, and a proxy is needed to expose the application for use by other services.

Open a new terminal window and start the proxy server with the command:

This creates a connection between your cluster and the virtual terminal window. Notice it’s running on port 8001 on the local host.

Return to the first terminal window and run a curl command to see this in action:

curl http://localhost:8001/version

The JSON output, shown in the screenshot above, displays the version information from the cluster itself.

Follow the online tutorial to find the internal name of the deployed pod and then query that pod directly. You can also get a detailed output of your pod by using the command:

This output includes very important information, like the pod name, local IP address, state, and restart count.

5. Moving forward

Kubernetes is a full-fledged deployment, scheduling, and scaling manager and is capable of deciding all of the myriad details of how to deploy an app on your cluster. The few commands explored here are just the beginning of interacting with and understanding a Kubernetes deployment. The crucial takeaway is how fast and easy it is to do and how few details you need to provide to use Kubernetes.

6. Conclusion

In this post, i have explained How To Getting started with Kubernetes.
If you have any questions or feedback, feel free to leave a comment.
As always, if you found this post useful, then click like and share it 🙂

20870cookie-checkGetting started with Kubernetes

Related Posts

Leave a Comment