arrow left
Back to Developer Education

Getting Started with Kubernetes Clusters

Getting Started with Kubernetes Clusters

A Kubernetes Cluster manages containers that consist of many nodes that are working together to perform a particular operation. Several cloud-based service providers allows us to create Kubernetes clusters using few commands. <!--more--> This option is recommended if one is getting started with Kubernetes because it allows us to get things up and running faster. Furthermore, the minikube tool only creates a single-node cluster. Single node clusters do not have all features of a Kubernetes cluster making cloud providers a better option.

Installing in Public Cloud Providers

In this section, we will look at how to install Kubernetes in these Cloud Providers:

  • Google Cloud Platform.
  • Microsoft Azure
  1. Google Cloud Platform

To use it, one needs to sign up for the Platform account and install the gcloud tool.

NOTE: We have to enable Billing for us to use this platform.

Once everything is in place, we set our default zone:

     $ gcloud config set compute/zone <timezone>

And create our cluster:

     $ gcloud container clusters create <cluster>

It may take a few minutes

We can get the cluster's credentials using this command:

     $ gcloud auth application-default login

For detailed instructions, read the documentation here.

  1. Microsoft Azure

To get started, we click the shell icon in the toolbar to access the already provided shell:

Shell icon

We can also install the shell in our local machines using the instructions contained here.

Once the shell is up and running, we can create a resource group using this command:

     $ az group create --name=<group-name> --location=<location>

We then create a cluster using:

       --resource-group=<group-name> --name=<cluster-name>

After the cluster is created, we can get credentials for the cluster using this command:

    $ az acs Kubernetes get-credentials --resource-group=<group-name> --name=<cluster-name>

One can find further instructions in the Azure documentation.

  1. Installing Kubernetes locally

To use minikube, we need hypervisor installed on our machines.

The minikube tool can be found here. Links to binaries for one's Operating System of choice are made available at the same link.

After installation, create a cluster and start it using this command:

     $ minikube start

We can pause it using:

     $ minikube pause

When done with it, we halt using:

     $ minikube stop

To remove the cluster, run:

$ minikube delete

More instructions can be found here.

The Kubernetes client

Denoted as kubectl, the Kubernetes Client is used for managing, controlling our clusters. It also helps us check the health of our clusters.

We can check a cluster version using:

$ kubectl version

We can check the health of the cluster using:

$ kubectl get componentstatuses

To list all nodes in a cluster, we run this command:

$ kubectl get nodes

We will get all the node names, their health statuses, and age.

Run this to get more information about a certain node:

$ kubectl describe nodes <node-name>

Common cluster components

We are going to look at a few components that make up a Kubernetes Cluster, namely:

  • Kubernetes Proxy
  • Kubernetes DNS
  • Kubernetes UI
  1. Kubernetes Proxy (kube-proxy) This enables services not in a cluster to communicate with those in a cluster through a network and a set of rules. Kubernetes achieves this using an object called the DaemonSet which makes the proxy run in every node in the cluster.

To see the proxies, we use this:

$ kubectl get daemonSets --namespace=kube-system kube-proxy

We can implement the kube-proxy in three modes:

  • User space - Here, the proxy process does not run in the kernel network but in a user process level hence its name. It's not recommended because it is a slow method.
  • iptables - Unlike the User space mode, this mode operates in the kernel, and it operates in a round-robin style of scheduling services in a cluster. It is not used when there are many services because its scheduling style may lead to slow performance.
  • IPVS - (IP Virtual Server) operates in the same manner as the iptables. It uses more efficient scheduling algorithms that reduce the delay time. Used where there are many services.

Read more on Kubernetes Proxy here.

  1. Kubernetes DNS Kubernetes runs a DNS server that provides easy identification of services in a cluster. It does so by assigning them names allowing us to access their functionality without getting to know their IP addresses.

We can view the DNS servers running by using this command:

$ kubectl get deployments --namespace=kube-system kube-dns

Read more on Kubernetes DNS here

  1. Kubernetes UI This is a web-based graphical user interface, and to see it, we use this command:
$ kubectl get deployments --namespace=kube-system Kubernetes-dashboard

We can then use the kubectl proxy to access the server on http://localhost:8001/api/v1/namespaces/Kubernetes-dashboard/services/https:Kubernetes-dashboard:/proxy/:

$ kubectl proxy

Read more on Kubernetes UI here

Conclusion

We have gone through an elementary introduction to Kubernetes clusters. View content on the links attached to get more insights.

Happy coding!


Peer Review Contributions by: Lalithnarayan C

Published on: Jun 3, 2021
Updated on: Jul 15, 2024
CTA

Start your journey with Cloudzilla

With Cloudzilla, apps freely roam across a global cloud with unbeatable simplicity and cost efficiency