Introduction to Kubernetes

To understand Kubernetes better let’s discuss an example of football. On a football field, the coach decides where each player will stand and with what qualities. Let’s say the person who is good with goalkeeping will be a goal keeps, the person who is good with attaching will be playing forward. All this orchestration of the player is done by either the coach. Kubernetes is exactly the same where the Kubernetes act as an orchestrator to manage the docker containers.

Kubernetes makes sure that all the required containers are available and suppose to be there to do their job. IN Kubernetes we tell the framework that these are the number of nodes that we want and the rest is handled by Kubernetes itself. It makes sure all the specified number of nodes are up and running. If any of the nodes go down or a scale-up is required k8s takes care of that.

K8s have some basic topic that we need to know before moving forward. These topics recalled K8s objects. In this post, I will stick to the definition and won’t be able to go into more detail.

Pods:

Pod is the basic execution unit of K8s application. The pod encapsulates the application, storage, network and other strategies that govern the containers. The pod can have one or more than one containers. The objective of the Pod is to run the single instance of the given application if you want multiple instances of the application then you need to add more pods.

Service:

An object that acts as an abstraction in running the set of pods a network service. The service is responsible in ensuring that all the network is available between them for proper communication but that decoupling is also enabled.

Namespace:

K8s provide multiple namespaces through which we can classify different resources based on the similar features they have. The namespace is a way to divide the cluster resource between multiple users.

To connect to k8s

1. Before you do that you need to PIM if you have that otherwise, it won’t work

2. Get the configuration from az and to do that you need to run this command. This command will get the config from the az and populate that in the config file as a context. So that, later on, you can switch the context in power shell and connect to it. The name of the resource group should be the same as where you created the culture

az aks get-credentials –resource-group myResourceGroup –name myAKSCluster

 

3. Once you are done that you can see if the configuration is updated or not (which it will be but we will just look at it to get more information). You can also verify it by running the command to get the current context. The command is as follows

Kubectl config current-context

4. Now if you want to connect to the host you need to first open a proxy with the kubectl. The command to do that is

Kubeclt proxy

5. After that, you can open any browser and type this

http://localhost:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/overview?namespace=_all

 

6. To get a list of all the context the command is

Kubectl config get-contexts

7. kubectl exec -it {containerid} -n {namespace} powershell (to access the power shell)